解决error: (-215:Assertion failed) _src.empty() in function ‘cv::cvtColor‘

解决error: -215:Assertion failed !_src.empty in function 'cv::cvtColor'

problem lies in

In the OpenCV environment, when running the code, it appears:

error: -215:Assertion failed  !_src.empty in function 'cv::cvtColor'

insert image description here
The reason is: No object resource in cv::cvtColor

solve

Locate the line where the code problem is located, and find that imgRGB is not passed in the image. The incoming imageinsert image description here
of my code is passed in from the camera. Continue to locate the cap here, and change 1 to 0
( the built-in camera of the notebook is 0, and the USB external camera is 0). is 1 )
insert image description here

Summarize

The idea of ​​​​solving the same error is also different. The essence of this error is that the cv2 resource is empty . I am here to define the problem of the camera, and the corresponding can have path pictures, video problems, etc.
insert image description here
insert image description here

Guess you like

Origin blog.csdn.net/weixin_50679163/article/details/124347212