1 | initial version |
@uraqtlee You can do like this,
#include "opencv2/imgproc/imgproc.hpp"
#include <opencv2/highgui/highgui.hpp>
#include <iostream>
using namespace cv;
using namespace std;
int main()
{
VideoCapture cam(0); //change index accordingly
if(!cam.isOpened())
{
cout<<"error camera failed to open ! "<< endl;
return -1;
}
while(1)
{
Mat img, img_roi, mask;
bool success = cam.read(img);
if(!success)
{
cout<<"error cannot read image ! "<<endl;
return -1;
}
img.copyTo(mask);
int width = img.cols;
int height = img.rows;
Rect roi(width/2 - 100, height/2 - 100, 200, 200); // set roi for rectangle according to your choice
rectangle(img, roi, Scalar(255,0,0), 2, 8, 0); // draw rectangle using above roi
img_roi = mask(roi);
imshow("img", img); // showing orignal image with rectangle
imshow("img_roi", img_roi); // showing image in the rectangle
//now process img_roi image for further text detection processing.
if (waitKey(3) == 27)
break;
}
}