i have code for detect edge using opencv and c++; there is envelop with a stamp. now i want draw rectangle in stamp. blue area is the stamp . how it do? is this possibe? pic is here
https://docs.google.com/document/d/1tldQ1J_simAaxSVN58sqjtjQZnCS8e8wBHOK0WlnHtQ/edit?usp=sharing[
^]
my code is below. sorry for bad english
#include "opencv2/highgui/highgui.hpp"
#include <iostream>
#include "opencv2/imgproc/imgproc.hpp"
#include <cv.h>
#include <highgui.h>
#include <stdlib.h>
#include <stdio.h>
using namespace cv;
using namespace std;
int thresh = 180;
int max_thresh = 200;
Mat img_rgb,img_gray,img_bw,canny_output,drawing;
RNG rng(12345);
int main(int argc, char* argv[])
{
VideoCapture cap(0);
if (!cap.isOpened()) {
cout << "Cannot open the video cam" << endl;
return -1;
}
double dWidth = cap.get(CV_CAP_PROP_FRAME_WIDTH); double dHeight = cap.get(CV_CAP_PROP_FRAME_HEIGHT);
cout << "Frame size : " << dWidth << " x " << dHeight << endl;
namedWindow("MyVideo",CV_WINDOW_AUTOSIZE);
cap.set(CV_CAP_PROP_FRAME_WIDTH, 320);
cap.set(CV_CAP_PROP_FRAME_HEIGHT, 240);
Mat captureframe,con,threshold_output;
vector<vector><point> > contours; vector<vec4i> hierarchy;
while (1)
{
Mat frame;
bool bSuccess = cap.read(frame);
cvtColor(frame,frame,CV_RGB2GRAY);
vector<vector><point> > contours;
vector<vec4i> hierarchy;
Canny( frame, canny_output, thresh, thresh*2, 3 );
cv::dilate(canny_output, canny_output, cv::Mat(), cv::Point(-1,-1));
findContours( canny_output, contours, hierarchy, CV_RETR_TREE, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
drawing = Mat::zeros( canny_output.size(), CV_8UC3 );
vector<point> approxShape;
for(size_t i = 0; i < contours.size(); i++){
approxPolyDP(contours[i], approxShape, arcLength(Mat(contours[i]), true)*0.04, true);
drawContours(drawing, contours, i, Scalar(255, 0, 0), CV_FILLED); }
cv::namedWindow("Canny");
cv::imshow("Canny",canny_output);
cv::namedWindow("Fill");
cv::imshow("Fill",drawing);
if (!bSuccess) {
cout << "Cannot read a frame from video stream" << endl;
break;
}
imshow("MyVideo", frame);
if (waitKey(30) == 27) {
cout << "esc key is pressed by user" << endl;
break;
}
}
return 0;
}