我完全不知道为什么在查看文档后我无法用OpenCV绘制椭圆.
首先我使用的是CV 2.4.9
>>> cv2.__version__
'2.4.9'
>>>
Run Code Online (Sandbox Code Playgroud)
其次,我试图使用以下内容:
>>> help(cv2.ellipse)
Help on built-in function ellipse in module cv2:
ellipse(...)
ellipse(img, center, axes, angle, startAngle, endAngle, color[, thickness[,
lineType[, shift]]]) -> None or ellipse(img, box, color[, thickness[, lineType
]]) -> None
Run Code Online (Sandbox Code Playgroud)
我的椭圆看起来像如下:
cx,cy = 201,113
ax1,ax2 = 37,27
angle = -108
center = (cx,cy)
axes = (ax1,ax2)
cv2.ellipse(frame, center, axes, angle, 0 , 360, (255,0,0), 2)
Run Code Online (Sandbox Code Playgroud)
但是,运行会给我以下内容
>>> cv2.ellipse(frame,center,axes,angle,0,360, (255,0,0), 2)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: ellipse() takes at most 5 arguments (8 given)
>>>
Run Code Online (Sandbox Code Playgroud)
救命?
编辑:
我想将以下内容用作框架
cap = cv2.VideoCapture(fileLoc)
frame = cap.read()
Run Code Online (Sandbox Code Playgroud)
显然,可以使用以下方法修复它
pil_im = Image.fromarray(frame)
cv2.ellipse(frame,center,axes,angle,0,360,(255,0,0), 2)
pil_im = Image.fromarray(raw_image)
pil_im.save('C:/Development/export/foo.jpg', 'JPEG')
Run Code Online (Sandbox Code Playgroud)
has*_*abi 18
我有同样的问题,我解决了它.我无法运行它的第一行代码是:
cv2.ellipse(ellipMask, (113.9, 155.7), (23.2, 15.2), 0.0, 0.0, 360.0, (255, 255, 255), -1);
Run Code Online (Sandbox Code Playgroud)
我发现轴(以及中心)必须是整数元组,而不是浮点数.所以下线还行!
cv2.ellipse(ellipMask, (113, 155), (23, 15), 0.0, 0.0, 360.0, (255, 255, 255), -1);
Run Code Online (Sandbox Code Playgroud)
我认为你应该采用其他值的正确格式.
以下是Opencv网站的链接:http: //answers.opencv.org/question/30778/how-to-draw-ellipse-with-first-python-function/
| 归档时间: |
|
| 查看次数: |
7335 次 |
| 最近记录: |