OpenCV C++ how to know the number of contours per row for sorting?
问题 I have a binary image: In this image I can easily sort the contours that I found from top to bottom and from left to right using the overloaded std::sort . I first sort from top to bottom via: sort(contours.begin(), contours.end(), top_to_bottom_contour_sorter()); Then I sort from left to right by: for (int i = 0; i < contours.size(); i = i + no_of_contours_horizontally) { sort(i, i + no_of_contours_horizontally, left_to_right_contour_sorter); } Where top_to_bottom and left_to_right are