Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

you can sort the vector<vector<Point>> contours by the x-coord of the boundingRect

// from left to right
bool sort_by_x(const vector<Point> &ca, const vector<Point> &cb) {
    return boundingRect(ca).x < boundingRect(cb).x;
}

sort(contours.begin(), contours.end(), sort_by_x);