Subversion Repositories OpenCV2-Cookbook

Compare Revisions

Last modification

Ignore whitespace Rev 3 → Rev 5

/trunk/Chapter 07/blobs.cpp
32,7 → 32,7
cv::imshow("Binary Image",image);
 
// Get the contours of the connected components
std::vector<std::vector<cv::Point>> contours;
std::vector<std::vector<cv::Point> > contours;
cv::findContours(image,
contours, // a vector of contours
CV_RETR_EXTERNAL, // retrieve the external contours
40,7 → 40,7
 
// Print contours' length
std::cout << "Contours: " << contours.size() << std::endl;
std::vector<std::vector<cv::Point>>::const_iterator itContours= contours.begin();
std::vector<std::vector<cv::Point> >::const_iterator itContours= contours.begin();
for ( ; itContours!=contours.end(); ++itContours) {
 
std::cout << "Size: " << itContours->size() << std::endl;
59,7 → 59,7
// Eliminate too short or too long contours
int cmin= 100; // minimum contour length
int cmax= 1000; // maximum contour length
std::vector<std::vector<cv::Point>>::const_iterator itc= contours.begin();
std::vector<std::vector<cv::Point> >::const_iterator itc= contours.begin();
while (itc!=contours.end()) {
 
if (itc->size() < cmin || itc->size() > cmax)
166,4 → 166,4
 
cv::waitKey();
return 0;
}
}