无力吐槽下 opencv 关于 ptyhon cv2.rectangle 出现的 “TypeError: function takes exactly 4 arguments (2 given)” 错误

当我看到这个错误的时候,我一直核对我的参数数量是否正确,但是找来找去就是有4个变量,还想是不是opencv版本什么问题,后来只能查下资料,才发现原来是因为左上点坐标和右下点坐标需要是整数的问题。。。不是我没想到考虑到坐标需要整数,因为我用了//(地板除)我一直没有理解好它,我以为它的结果返回的就是整数的商,可是其实如果使用它的数据存在浮点数,那么它会返回浮点数而不是整数。

错误代码:

python cv2.rectangle error: TypeError: function takes exactly 4 arguments (2 given)

修改后正确代码:

python cv2.rectangle error: TypeError: function takes exactly 4 arguments (2 given)

 

参考资料:https://github.com/opencv/opencv/issues/17940

 

相关文章:

  • 2021-08-26
  • 2022-12-23
  • 2021-07-21
  • 2021-07-06
  • 2021-08-17
  • 2021-08-31
  • 2021-07-28
  • 2022-01-22
猜你喜欢
  • 2021-09-02
  • 2022-12-23
  • 2021-09-22
  • 2022-12-23
  • 2021-11-22
  • 2022-01-15
  • 2022-12-23
相关资源
相似解决方案