[英]How to use convexHull function of openCV in iOS objective C?
I am someone who is new to openCV and has been trying to use convexhull function in the openCV library for an app (objective-C being used), I need to know what is the input format of function arguments, it's pretty confusing. 我是一个刚接触openCV的人,一直在尝试为应用程序使用openCV库中的凸包函数(正在使用object-C),我需要知道函数参数的输入格式是什么,这非常令人困惑。 And does this function return the points in a sequence? 这个函数是否按顺序返回点? Like, if I use addLineToPoint to draw a bezierpath of this hull, is it possible? 就像,如果我使用addLineToPoint绘制此外壳的bezierpath,可以吗?
Some sample code for you: 一些适合您的示例代码:
std::vector<cv::Point> points;
//fill that vector with your points
std::vector<cv::Point> hull;
if (points.size()) {
cv::convexHull(points, hull);
}
cv::Size size = cv::Size(w, h);
//some size for the matrix where you will draw your convex hull
cv::Mat hullMask = Mat::zeros(size, CV_8UC1);
int hull_count = (int)hull.size();
if (hull_count) {
const cv::Point* hull_pts = &hull[0];
cv::fillPoly(hullMask, &hull_pts, &hull_count, 1, cv::Scalar(255));
}
This code will help you to create convex hull and draw it. 此代码将帮助您创建凸包并进行绘制。
Here you can find complete documentation for that function. 在这里您可以找到该功能的完整文档。 It will return points in a sequence according to the "clockwise" argument. 它将根据“顺时针”参数按顺序返回点。 By default it will be counter-clockwise. 默认情况下,它将是逆时针方向。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.