OpenCv 点多边形测试。如何提供轮廓作为输入?
我一直在尝试使用OpenCV函数:
double pointPolygonTest(InputArray轮廓,Point2f pt,boolmeasureDist)
我有一个由2D中的4个点(x1,y1)指定的轮廓,..., (x4,y4)。我想测试点 (x,y) 是在轮廓内部还是外部。但我似乎找不到任何参考如何正确指定轮廓作为函数的输入。
我尝试了以下实现,但没有得到正确的结果:
vector< Point2f > contour;
contour.push_back(Point2f(x1, y1));
contour.push_back(Point2f(x2, y2));
contour.push_back(Point2f(x3, y3));
contour.push_back(Point2f(x4, y4));
int inCont;
inCont = pointPolygonTest(contour, Point2f(x, y), false);
我错过了什么吗?
I've been trying to use the OpenCV function:
double pointPolygonTest(InputArray contour, Point2f pt, bool measureDist)
I have a contour specified by 4 Points in 2D (x1,y1), ..., (x4,y4). I want to test if a Point (x,y) is inside or outside of the contour. But I can't seem to find any reference how to specify the contours as input for the function correctly.
I've tried the following implementation without getting a correct result:
vector< Point2f > contour;
contour.push_back(Point2f(x1, y1));
contour.push_back(Point2f(x2, y2));
contour.push_back(Point2f(x3, y3));
contour.push_back(Point2f(x4, y4));
int inCont;
inCont = pointPolygonTest(contour, Point2f(x, y), false);
Am I missing something?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
函数对我来说没有任何问题(OpenCV 2.3.1):
输出:
Function works for me without any problem (OpenCV 2.3.1):
Output: