OpenCV的minEllipse函数(求轮廓的外接椭圆)一定要判断输入点是否大于5个

来源:互联网 发布:windows地图可以卸载吗 编辑:程序博客网 时间:2024/06/05 14:20

如题,如果不判断,是要报错的,如下图所示


OpenCV Error: Incorrect size of input array (There should be at least 5 points to fit the ellipse) in cv::fitEllipse, file C:\builds\master_PackSlave-win32-vc11-shared\opencv\modules\imgproc\src\shapedescr.cpp, line 379

正确使用的代码如下

 // 求轮廓的外接椭圆          if (contours[i].size() > 5) //使用前一定要判断是否大于5个点,小于5个点要报错          {              minEllipse[i] = fitEllipse(Mat(contours[i]));          }  

-------------------------------------------
欢迎大家加入图像识别技术交流群:271891601,另外,特别欢迎成都从事图像识别工作的朋友交流,我的QQ号2487872782

0 0