Ask Your Question

Revision history [back]

The following code snippet works here

// This vector contains your original data
// The second one will contain the selected ones
vector<Rect> contours, filtered;
// Now apply the thresholding
for(size_t i=0; i<contours.size(); i++){
   double area = contourArea(contours[i]);
   if( (area < 65.0) || (area > 1000.0)  ){
      filtered.push_back(contours[i]);
   }
}

My guess is that your are incorrectly using the erase function.

The following code snippet works here

// This vector contains your original data
// The second one will contain the selected ones
vector<Rect> contours, filtered;
// Now apply the thresholding
for(size_t i=0; i<contours.size(); i++){
   double area = contourArea(contours[i]);
   if( if( (area > 65.0) && (area < 65.0) || (area > 1000.0) 1000.0))  ){
      filtered.push_back(contours[i]);
   }
}

My guess is that your are incorrectly using the erase function.