
I just started learning OpenCv. I wanted to crop a portion of the image, which is text surrounded by a red circle. can you guys help me find a solution, like all the methods that i have to follow to crop it. I tried a few things and cut the red circle and kept it in the rug.
while(1) { capture>>img0; imshow("original", img0); imwrite("original.jpg", img0); cv::inRange(img0,cv::Scalar(0,0,100),cv::Scalar(76,85,255),img1); imshow("threshold.jpg", img1); imwrite("threshold.jpg", img1); // find the contours vector< vector<Point> > contours; findContours(img1, contours, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_NONE); Mat mask = Mat::zeros(img1.rows, img1.cols, CV_8UC1); drawContours(mask, contours, -1, Scalar(255), CV_FILLED); Mat crop(img0.rows, img0.cols, CV_8UC3); crop.setTo(Scalar(255,255,255)); img0.copyTo(crop, mask); normalize(mask.clone(), mask, 0.0, 255.0, CV_MINMAX, CV_8UC3); imshow("mask", mask); imshow("cropped", crop); imwrite("mask.jpg", mask); imwrite("cropped.jpg", crop); if(waitKey(30)=='27') { break; } } return 0;`[original image[cropped image][1]`
From this image, I wanted to crop the text alone. help me find a solution by sharing me with methods or steps.
Thank you in advance