OpenCV错误:(-215:声明失败)VScn :: contains(scn)&& VDcn :: contains(dcn)&& VDepth ::在函数"CvtHelper"中包含(深度) [英] OpenCV Error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper'

查看:1390
本文介绍了OpenCV错误:(-215:声明失败)VScn :: contains(scn)&& VDcn :: contains(dcn)&& VDepth ::在函数"CvtHelper"中包含(深度)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Traceback (most recent call last):
File "demo.py", line 132, in 
     `result = find_strawberry(image)`
File "demo.py", line 63, in find_strawberry
`image = cv2.cvtColor(image, cv2.COLOR_BGR2RGB)`
cv2.error: OpenCV(3.4.2) /Users/travis/build/skvark/opencv-python/opencv/modules/imgproc/src/color.hpp:253: error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'CvtHelper'

我个人在这个问题上花费了很多时间,因此认为与将其发布到Stackoverflow有关.

I personally have spent a lot of time on this question, hence thought relevant to post it on Stackoverflow.

问题取自: llSourcell/Object_Detection_demo_LIVE

推荐答案

即使我有同样的问题,解决方案也很简单.请记住一件事,如果图像的RGB值在0-255的范围内,请确保这些值不是数据类型"float".由于OpenCV仅在值范围为0-1时才考虑浮动.如果发现浮点值大于1,则会截断该值,并认为浮点仅存在于0-1之间.因此,产生了这样的错误.因此,如果值介于0-255之间,则将数据类型转换为uint8.

Even I had the same problem, and the solution was quiet easy. Remember 1 thing, if the RGB values of your image lie in the range of 0-255, make sure the values are not of data type 'float'. As OpenCV considers float only when values range from 0-1. If it finds a float value larger than 1 it clips off the value thinking floats only exists between 0-1. Hence such errors generated. So convert the data type to uint8 if values are from 0-255.

image = image.astype('uint8')

选中此 Kaggle内核,以了解更多有关

Check this Kaggle Kernel to learn more about it

这篇关于OpenCV错误:(-215:声明失败)VScn :: contains(scn)&& VDcn :: contains(dcn)&& VDepth ::在函数"CvtHelper"中包含(深度)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆