
image, contours, hierarchy = cv2findContours(image, mode, method[, contours[, hierarchy[, offset ]]])
findContours( InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset=Point());
findContours( InputOutputArray image, OutputArrayOfArrays contours, int mode, int method, Point offset=Point());
检测轮廓方法(mod):
表示一条轮廓的方法(method):
void drawContours(InputOutputArray image, InputArrayOfArrays contours, int contourIdx, const Scalar& color, int thickness=1, int lineType=8, InputArray hierarchy=noArray(), int maxLevel=INT_MAX, Point offset=Point() )
函数参数详解:
1、获取包围对象的垂直矩阵
2、获取包围对象的最小圆
3、获取包围对象的多边形
4、获得包围对象的凸包
原理
5、轮廓中的所有点
一个想法:先取得轮廓,然后新建一个图像,在新图像上画出轮廓以及填充的图像,遍历这幅图像,如果有颜色就是在轮廓内。
另一个方法1
另一个方法2
6、最小面积的外接矩形(可倾斜)
minAreaRect(InputArray points);
7、可倾斜椭圆(见上)
fitEllipse(InputArray points);
8、轮廓内连通区域的面积和长度
double contourArea(InputArray contour, bool oriented=false )
double arcLength(InputArray curve, bool closed);
9、判断一个点是否在一个多边形内
pointPolygonTest
double pointPolygonTest(InputArray contour, Point2f pt, bool measureDist)
用于测试一个点是否在多边形中
当measureDist设置为true时,若返回值为正,表示点在多边形内部,返回值为负,表示在多边形外部,返回值为0,表示在多边形上。
当measureDist设置为false时,若返回值为+1,表示点在多边形内部,返回值为-1,表示在多边形外部,返回值为0,表示在多边形上。
10、比较两个形状的相似性
原理: OpenCV提供的一个根据计算比较两张图像Hu不变距的函数,函数返回值代表相似度大小,完全相同的图像返回值是0,返回值最大是1。这可以用在在一堆照片中搜索出两张相同或相同程度最大的图像。
double cvMatchShapes(const void object1, const void object2, int method, double parameter = 0);
以上就是关于帮忙解释一下opencv代码,看不懂,希望每句都解释一下,谢谢啦!全部的内容,包括:帮忙解释一下opencv代码,看不懂,希望每句都解释一下,谢谢啦!、vs多次运行opencv时间不一致、实现抖音视频抖动效果---OpenCV-Python开发指南(53)等相关内容解答,如果想了解更多相关内容,可以关注我们,你们的支持是我们更新的动力!
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)