Ask Your Question

# Revision history [back]

Since you already compute the bounding box of the contours, you can do something like this

std::vector<cv::Mat> contour_rois;
for(int i = 0; boundRect.size(); i++)
{
cv::Mat roi( binaryImg, boundRect[i]);
contour_rois.push_back(roi);
}