I am using the function findContours in a previoulsy set ROI using the overload operator of Mat. The contours get extracted fine, but their coordinates are not global, they merley belong to the ROI. So when i want to draw them into a image, they all get drawn in the Rectangle defining my ROI. I think i just miss something fundamental here. Anyone got an idea?
Here is the code snippet.
Mat roi(img_grad, inflated_rect);
findContours( roi, canidates, hierarchy, CV_RETR_EXTERNAL, CV_CHAIN_APPROX_SIMPLE, Point(0, 0) );
for(int i = 0; i < canidates.size(); ++i) {
drawContours(mat, canidates, i, Scalar(0,0,255), 1, CV_AA, hierarchy, 1, Point(0,0));
}
findContoursreturns coordinates relative to your ROI.So you should shift all points by the ROI offset (notice the last parameter):
or get another ROI for drawing: