1 | initial version |
You could use boundingRect() to get bounding box for a contour. See tutorial here
Using the above bounding Rect you can save the image like
Rect R=boundingRect(contour[i]); // Get bounding box for contour i
Mat ROI=src(R); //Set ROI on source image
imwrite("croped.jpg",ROI); //save ROI image
2 | No.2 Revision |
You could use boundingRect() to get bounding box for a contour. See tutorial here
Using the above bounding Rect you can save the image like
Rect R=boundingRect(contour[i]); // Get bounding box for contour i
Mat ROI=src(R); //Set ROI on source image
imwrite("croped.jpg",ROI); imwrite("cropped.jpg",ROI); //save ROI image