How to sort std::vector<cv::Rect>?
Trying to sort ROI rectangles from left to right.
auto compare = [](const void* p1, const void* p2) -> int
{
const int* p1x = &(((const cv::Rect*)p1)->width);
const int* p2x = &(((const cv::Rect*)p2)->width);
return (*p2x) - (*p1x);
};
qsort(&vec, vec.size(), sizeof(cv::Rect), compare);
But ->width
gives the wrong values.