总结几个今天在使用opencv时遇到的几个小错误分享给大家,希望我们的opencv之路走得容易一点,hhh。
-
RuntimeError: Expected object of scalar type Float but got scalar type Double for argument #4 'mat1’
这个错误是由于本该是float类型的输入,却成了double的输入,我们只需要修改下输入类型即可
代码:
tensor.type(troch.float)
-
TypeError: Expected Ptr cv::UMat for argument '%s’
这个问题是传入的参数不对。原本传入到cv2中的image需要是numpy.array类型,如果传入别的类型的参数就会出现这个错误。
本文分享了在使用OpenCV过程中遇到的两个常见错误及其解决方案。一是RuntimeError:Expected object of scalar type Float but got scalar type Double for argument #4 'mat1',解决方法是修改输入类型为float。二是TypeError:Expected Ptr<cv::UMat> for argument '%s',解决方法是确保传入cv2的image参数为numpy.array类型。
&spm=1001.2101.3001.5002&articleId=108580926&d=1&t=3&u=96dc582e8d6046eeacdcd2fb1b772ef0)
2万+

被折叠的 条评论
为什么被折叠?



