Find squares and save the region of interest
Here is a part of the code I got from opencv sample code:https://github.com/opencv/opencv/blob/master/samples/cpp/squares.cpp
static void drawSquares( Mat& image, const vector<vector<Point> >& squares )
{
//cout << "square size " << squares.size();
for( size_t i = 0; i < squares.size(); i++ )
{
const Point* p = &squares[i][0];
int n = (int)squares[i].size();
//cout << "square size " << n;
//dont detect the border
if (p-> x > 3 && p->y > 3){
// printf("x value %u y value %u\n",p-> x,p-> y);
polylines(image, &p, &n, 1, true, Scalar(255,255,0), 3, LINE_AA);
}
}
imshow(wndname, image);
}
I want to save (imwrite) only the detected squares out of the whole image
I tried printing out x and y value of p but it only gives me the only a corner pixel value of the square. Could anyone please help how to save the squares only?