0

I am try to use convexHull to set the sequence of my points. But the result is just wrong.

//image_points_queue.push_back(original_image_points);
vector<cv::Point2f> image_points = {
    { 585, 543 },
    { 643, 749 },
    { 767, 501 },
};

convexHull(image_points, image_points, false);

image_points comes to be "767, 501", "643, 749", "767, 501". I don't have any idea about it . Please help.

Tony Luo
  • 110
  • 1
  • 9
  • Can you provide a [mcve]? This works as expected for me (no duplicates, correct points). Probably you're doing something else in your code that provides wrong results. – Miki Mar 14 '16 at 12:55
  • Do you run the code in Linux? Please see my comment below. It went wrong in Windows. – Tony Luo Mar 15 '16 at 06:26
  • I'm on Windows 8.1. I don't think it's platform dependent. You probably have some other code that messes up with this snippet. – Miki Mar 15 '16 at 13:15
  • 1
    Actually that is the only code I ran for test. And the only change I did to make it work is using another vector as result. – Tony Luo Mar 16 '16 at 03:49

2 Answers2

1

I use another vector for the result and the code works just fine.

vector<cv::Point2f> result_points;
vector<cv::Point2f> image_points = {
    { 585, 543 },
    { 643, 749 },
    { 767, 501 },
};

convexHull(image_points, result_points, false);

I am using Windows 10. Not sure whether it is platform dependent.

Tony Luo
  • 110
  • 1
  • 9
-1

It basically gives a closed hull so the starting point and ending point would be same. so you need to ignore the last point of the hull.

AdityaIntwala
  • 2,536
  • 1
  • 17
  • 17