opencv画圆没转换成整数的各种报错,cv2.error: OpenCV(4.5.4-dev) :-1: error: (-5:Bad argument) in function ‘circle‘

出现背景:

拟合圆,得到拟合的圆心和半径后,使用opencv画圆时出现报错

报错信息:

  • 圆心半径画圆时,圆心坐标没转换成int
cv2.circle(im,(x,y),r,(0,0,255),2)
cv2.error: OpenCV(4.5.4-dev) :-1: error: (-5:Bad argument) in function 'circle'
> Overload resolution failed:
>  - Can't parse 'center'. Sequence item with index 0 has a wrong type
>  - Can't parse 'center'. Sequence item with index 0 has a wrong type
  • 圆心半径画圆时,半径没转换成int
cv2.circle(im,(x_int, y_int),r,(0,0,255),2)
cv2.error: OpenCV(4.5.4-dev) :-1: error: (-5:Bad argument) in function 'circle'
> Overload resolution failed:
>  - Argument 'radius' is required to be an integer
>  - Argument 'radius' is required to be an integer
  • 画圆心时,圆心坐标没转换成int
cv2.circle(im,(x,y),2,(0,255,0),3)
cv2.error: OpenCV(4.5.4-dev) :-1: error: (-5:Bad argument) in function 'circle'
> Overload resolution failed:
>  - Can't parse 'center'. Sequence item with index 0 has a wrong type
>  - Can't parse 'center'. Sequence item with index 0 has a wrong type
  • 在图上写文字时,定位坐标没转换成int
cv2.putText(im,  '(' + str(round(x))+',' + str(round(y)) + '),r:' + str(round(r)), (0,y) , cv2.FONT_HERSHEY_SIMPLEX,1,(0,255,0),1)
cv2.error: OpenCV(4.5.4-dev) :-1: error: (-5:Bad argument) in function 'putText'
> Overload resolution failed:
>  - Can't parse 'org'. Sequence item with index 1 has a wrong type
>  - Can't parse 'org'. Sequence item with index 1 has a wrong type

总结:

  • 在图片上画图时要保证相关坐标信息转换成像素对应的int整数,包括半径这样的参数
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

阿航626

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值