opencv中如何判断一个点是否在一个多边形中
2013-08-01 15:46
726 查看
pointPolygonTest()函数可以实现这个功能。
!
double cvPointPolygonTest(const CvArr* contour, CvPoint2D32f pt, int measure_dist)
参数:contour,多边形。 pt将要判断的点。measure_dist 如果为真,则返回的double类型是点距离轮廓的最近的距离。如果为假,返回的值无意义。
参考资料opencv2refman.pdf 297页。
下面为英文原文。
pointPolygonTest
Performs a point-in-contour test.
C++: double pointPolygonTest(InputArray contour, Point2f pt, bool measureDist)
Python: cv2.pointPolygonTest(contour, pt, measureDist) ! retval
C: double cvPointPolygonTest(const CvArr* contour, CvPoint2D32f pt, int measure_dist)
Python: cv.PointPolygonTest(contour, pt, measure_dist) ! float
Parameters
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.
The function determines whether the point is inside a contour, outside, or lies on an edge (or coincides with a vertex). It
returns positive (inside), negative (outside), or zero (on an edge) value, correspondingly. When measureDist=false
, the return value is +1, -1, and 0, respectively. Otherwise, the return value is a signed distance between the point and
the nearest contour edge.
See below a sample output of the function where each image pixel is tested against the contour.
!
double cvPointPolygonTest(const CvArr* contour, CvPoint2D32f pt, int measure_dist)
参数:contour,多边形。 pt将要判断的点。measure_dist 如果为真,则返回的double类型是点距离轮廓的最近的距离。如果为假,返回的值无意义。
参考资料opencv2refman.pdf 297页。
下面为英文原文。
pointPolygonTest
Performs a point-in-contour test.
C++: double pointPolygonTest(InputArray contour, Point2f pt, bool measureDist)
Python: cv2.pointPolygonTest(contour, pt, measureDist) ! retval
C: double cvPointPolygonTest(const CvArr* contour, CvPoint2D32f pt, int measure_dist)
Python: cv.PointPolygonTest(contour, pt, measure_dist) ! float
Parameters
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.
The function determines whether the point is inside a contour, outside, or lies on an edge (or coincides with a vertex). It
returns positive (inside), negative (outside), or zero (on an edge) value, correspondingly. When measureDist=false
, the return value is +1, -1, and 0, respectively. Otherwise, the return value is a signed distance between the point and
the nearest contour edge.
See below a sample output of the function where each image pixel is tested against the contour.
相关文章推荐
- 如何判断一个点是否在多边形内部ne?
- 如何判断一个点是否在多边形内部?
- 如何判断一个点是否在多边形内?
- openlayers2 开发如何判断一个marker所在的点是否在一个多边形内部
- 如何判断一个指定的经纬度点是否落在一个多边形区域内?
- 在Android里如何判断一个指定的经纬度点是否落在一个多边形区域内
- 如何判断一个指定的经纬度点是否落在一个多边形内
- 如何判断一个点是否在一个多边形内部+三角形有向面积公式
- 如何判断一个点是否在一个多边形内部(有向面积)
- 如何判断一个点是否在多边形内部还是外部
- [转]如何判断一个点是否在一个多边形内部
- 如何判断一个指定的经纬度点是否落在一个多边形内
- 如何判断一个点是否在一个多边形内部
- 如何判断一个指定的经纬度点是否落在一个多边形区域内?
- 如何判断一个点是否在一个多边形内部(转)
- java 如何判断一个数是否为2的整数次幂
- 如何判断一个点是否在三角形内部
- 请教一个问题,Android应用运行时在调用某个API(比如相机)时,系统如何判断这个应用是否具备相应的权限?
- 如何判断一个Socket是否断开?
- 判断一个点是否在多边形内部,射线法思路,C#实现