ARClassProject/MarkerTracker.cpp
//  A function to check if a contour is a good candidate
A function to check if a contour is a good candidate
A function to check if a contour is a good candidate
bool MarkerTracker::checkContourCondition(const Contour &contour_approx, const cv::Mat &image_bgr, const int &kNumOfCorners) {
  const cv::Rect bounding_rectangle = cv::boundingRect(contour_approx);
  const int marker_size = bounding_rectangle.area();
  const int kImageSize = image_bgr.rows*image_bgr.cols;
  const int kMarkerSizeMin = (int)(kImageSize*0.01);
  const int kMarkerSizeMax = (int)(kImageSize*0.99);
  const bool is_contour_valid = (marker_size > kMarkerSizeMin)
  && (marker_size < kMarkerSizeMax)
  && contour_approx.size() == kNumOfCorners
  && cv::isContourConvex(contour_approx);
  return is_contour_valid;
}
bool MarkerTracker :: checkContourCondition ( const Contour & contour_approx , const cv :: Mat & image_bgr , const int & kNumOfCorners ) { const cv :: Rect bounding_rectangle = cv :: boundingRect ( contour_approx ) ; const int marker_size = bounding_rectangle . area ( ) ; const int kImageSize = image_bgr . rows * image_bgr . cols ; const int kMarkerSizeMin = ( int ) ( kImageSize * 0.01 ) ; const int kMarkerSizeMax = ( int ) ( kImageSize * 0.99 ) ; const bool is_contour_valid = ( marker_size > kMarkerSizeMin ) && ( marker_size < kMarkerSizeMax ) && contour_approx . size ( ) == kNumOfCorners && cv :: isContourConvex ( contour_approx ) ; return is_contour_valid ; }
A function to check if a contour is a good candidate
A function to check if a contour is a good candidate
// Get a bounding rectangle of the approximated contour // Filter bad contours