I have an array of std::vector<cv::Point> that looks like-
[49, 500]
[49, 129]
[441, 501]
[49, 374]
[440, 374]
[440, 259]
[440, 128]
[49, 260]
Let consider array elements as [x, y]. Now I need to get 4 elements from the array having-
- lowest x with highest y
- lowest x with lowest y
- highest x with lowest y
- highest x with highest y
currently, I am using functions to sort based on conditions and then fetch a point.
bool SortForMinXMaxY(const Point & a, const Point &b)
{
return (a.x < b.x || a.y > b.y) ;
}
What should be the standard approach with C++ and OpenCV to achieve the goal?