cv2.rectangle(img, (240, 0), (480.2, 375), (0, 255, 0), 2)

报错:
Traceback (most recent call last):
  File "/root/anaconda3/lib/python3.8/site-packages/IPython/core/interactiveshell.py", line 3418, in run_code
    exec(code_obj, self.user_global_ns, self.user_ns)
  File "<ipython-input-10-5766022a9827>", line 1, in <module>
    cv2.rectangle(img, (240, 0), (480.2, 375), (0, 255, 0), 2)
cv2.error: OpenCV(4.5.2) :-1: error: (-5:Bad argument) in function 'rectangle'
> Overload resolution failed:
>  - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
>  - Can't parse 'pt2'. Sequence item with index 0 has a wrong type
>  - Can't parse 'rec'. Expected sequence length 4, got 2
>  - Can't parse 'rec'. Expected sequence length 4, got 2

原因是中间的坐标不能有小数。。。。
把480.2换成480 就好了

Logo

为开发者提供学习成长、分享交流、生态实践、资源工具等服务,帮助开发者快速成长。

更多推荐