Assertion failed) VScn::contains(scn) && VDcn::contains(dcn) && VDepth::contains(depth) in function

这只是意味着该图像不存在,尝试使用绝对路径。如果无效再尝试以下方案:

解决方案非常简单。请记住一件事,如果图像的RGB值在0-255的范围内,请确保这些值不是数据类型“ float”。由于OpenCV仅在值范围为0-1时才考虑float。如果发现浮点值大于1,则会认为该浮点仅存在于0-1之间,因此会截断该值。因此产生了这样的错误。因此,如果值介于0-255之间,则将数据类型转换为uint8。
image = image.astype('uint8')

frame = np.asarray(frame, dtype=np.uint8)


# Our operations on the frame come here
gray = cv2.cvtColor(frame, cv2.COLOR_BGR2GRAY)

# Display the resulting frame
cv2.imshow('frame',gray)
if cv2.waitKey(1) & 0xFF == ord('q'):
    break
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章