如何在iOSobjective C中使用openCV的convexHull函数?

How to use convexHull function of openCV in iOS objective C?

我是openCV的新手,一直在尝试将openCV库中的convexhull函数用于应用程序(objective-C正在使用),我需要知道函数参数的输入格式是什么,这很令人困惑。这个函数 return 是序列中的点吗?比如,如果我使用 addLineToPoint 来绘制这个船体的 bezierpath,这可能吗?

一些示例代码供您参考:

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));
}

此代码将帮助您创建并绘制凸包。

Here 您可以找到该功能的完整文档。它将根据 "clockwise" 参数按顺序 return 点。默认为逆时针。