【发布时间】:2018-04-03 16:58:14
【问题描述】:
我有一个输入图像,想在找到的所有轮廓上绘制椭圆。我正在使用 python-opencv 并收到以下错误。谁能帮我这个?我知道绘制椭圆,但不确定如何绘制图像中每个检测到的对象。我是这个领域的新手,因此请原谅我的愚蠢问题。
OpenCV Error: Incorrect size of input array (There should be at least 5 points to fit the ellipse) in cv::fitEllipse, file
C:\bld\opencv_1498171314629\work\opencv-3.2.0\modules\imgproc\src\shapedescr.cpp, line 358
Traceback (most recent call last):
File "D:/project/test.py", line 41, in <module>
ellipse = cv2.fitEllipse(contours[0])
cv2.error: C:\bld\opencv_1498171314629\work\opencv-
3.2.0\modules\imgproc\src\shapedescr.cpp:358: error: (-201) There should be
at least 5 points to fit the ellipse in function cv::fitEllipse
【问题讨论】:
-
请按照您创建此帐户时的建议阅读并遵循帮助文档中的发布指南。 Minimal, complete, verifiable example 适用于此。在您发布 MCVE 代码并准确描述问题之前,我们无法有效地帮助您。我们应该能够将您发布的代码粘贴到文本文件中并重现您描述的问题。
-
错误信息是不言自明的,不是吗?
-
@Piglet,是的。但我仍然在努力解决这个问题。
-
在确保点数至少为 5 之后,您只适合椭圆。只需将 fitEllipse 调用放入 if 语句中
标签: python python-3.x opencv computer-vision opencv-contour