pointPolygonTest对于使用opencv的边界不能正常工作?

2024-10-03 23:27:30 发布

您现在位置:Python中文网/ 问答频道 /正文

我正在尝试pointPolygontest的功能,我想检查边界和内部和外部的点。在

形成功能的自由裁量权 双点多边形测试(输入阵列轮廓,点2F点,布尔测量列表)

参数:

contour – Input contour.

pt – Point tested against the contour.

measureDist – If true, the function estimates the signed distance from the point to the nearest contour edge. Otherwise, the function only checks if the point is inside a contour or not. 

当measureDist=false时,返回值为+1、-1和0,相应地,t返回正(内部)、负(外部)或零(在边上)值。在

现在我测试了下面的代码来测试多边形的边,但没有得到ecpexted的结果。在

代码如下:

^{pr2}$

输出是

[[0.0, 0.0], [0.0, 200.0], [200.0, 200.0], [200.0, 0.0]]
-1.0
-1.0
-1.0
 1.0

也就是说3个肉汤在外面,最后一个在里面,但我的理解是所有的肉汤都应该是0.0

那么,什么是错误??在


Tags: the代码功能列表function多边形轮廓point
1条回答
网友
1楼 · 发布于 2024-10-03 23:27:30

我很想繁衍后代。您可以检查轮廓值以及-1.0和1.0的原因。在

[199, 2; 199, 198; 198, 199; 2, 199; 2, 201; 200, 201; 201, 200; 201, 2]

试试看

^{pr2}$

而不是

points = [[0.0*r, 0.0*r], [0.0*r,2.0*r], [2.0*r,2.0*r], [2.0*r,0.0*r] ]

在pointPolygon(实例0,0或400400)中,边界通常被省略,不会像预期的那样返回0,而是返回-1

相关问题 更多 >