Quantcast
Channel: OpenCV Q&A Forum - Latest question feed
Viewing all articles
Browse latest Browse all 19555

convexHull clockwise parameter inverted ?

$
0
0
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 #include #include #include #include #include #include int main(int argc, char **argv) { std::vector 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: ![image description](/upfiles/1476445705939058.png) which appears to be clockwise unless its supposed to be traversed in descending order.

Viewing all articles
Browse latest Browse all 19555

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>