convexHull clockwise parameter inverted ?
Perhaps I'm misunderstanding the 3rd parameter to convexHull ? :
clockwise - Orientation flag. If it is true, the output convex hull is oriented clockwise. Otherwise, it is oriented counter-clockwise. The assumed coordinate system has its X axis pointing to the right, and its Y axis pointing upwards.
When I run the following code:
#include <iostream>
#include <vector>
#include <opencv2/core/base.hpp>
#include <opencv2/core/core.hpp>
#include <opencv2/calib3d.hpp>
#include <opencv2/imgproc.hpp>
#include <opencv2/highgui/highgui.hpp>
int main(int argc, char **argv)
{
std::vector<cv::Point2i> points, hull_points;
points.push_back(cv::Point2i(114, 22));
points.push_back(cv::Point2i(329, 245));
points.push_back(cv::Point2i(37, 98));
points.push_back(cv::Point2i(43, 272));
points.push_back(cv::Point2i(120, 150));
cv::convexHull(points, hull_points, false);
cv::Mat img(350, 460, CV_8UC3, cv::Scalar::all(0));
int no = 1;
for (auto it = hull_points.begin(); it != hull_points.end(); ++it)
{
cv::Point2i &pt = *it;
cv::circle(img, pt, 3, cv::Scalar(0, 255, 0), 1, cv::LINE_AA);
std::stringstream ss;
ss << no++ << ":(" << pt.x << "," << pt.y << ")";
cv::putText(img, ss.str(), cv::Point2i(pt.x+1, pt.y-1), CV_FONT_HERSHEY_COMPLEX_SMALL, 1.0, cvScalar(0, 255, 255), 1, CV_AA);
std::cout << ss.str() << " ";
}
std::cout << std::endl;
cv::imwrite("img.png", img);
}
I get the following image:
which appears to be clockwise unless its supposed to be traversed in descending order.