解决error: (-215:Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function 'cv::CvtHelper的一种可能

 

错误发生于opencv颜色空间转换时:

 im_lab = cv2.cvtColor(im_bgr, cv2.COLOR_BGR2LAB)

根据上面第二个链接里的回答,数据不能是浮点型,只能是整型。但根据我的实验,float64会报如题的错误,但只要改成float32就可以运行。

im_bgr = im_bgr.astype(np.float64) # throws an error in the title
im_bgr = im_bgr.astype(np.float32) # runs without error

 

参考:

https://github.com/llSourcell/Object_Detection_demo_LIVE/issues/6

https://stackoverflow.com/questions/52739143/opencv-error-215assertion-failed-vscncontainsscn-vdcncontainsdcn

posted @ 2020-11-07 06:06  略略略——  阅读(2570)  评论(0编辑  收藏  举报