简体   繁体   中英

When I try to run my CV2 python code with droidcam I am getting error

cap = cv2.VideoCapture(0)
while True:
    success, img = cap.read()
    imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
    cv2.imshow("Application", img)
    cv2.waitKey(1)

it works well.

but it is throwing an error when I run same code with the help of droidcam

I change code to

cap = cv2.VideoCapture("http://192.168.43.1:4747/mjpegfeed?640x480")

and When I try to run my CV2 python code with droidcam I am getting error which is:

INFO: Created TensorFlow Lite XNNPACK delegate for CPU.
Traceback (most recent call last):
  File "test.tracker.py", line 29, in <module>
    imgRGB = cv2.cvtColor(img, cv2.COLOR_BGR2RGB)
cv2.error: OpenCV(4.5.3) /tmp/pip-req-build-afu9cjzs/opencv/modules/imgproc/src/color.cpp:182: error: (-215:Assertion failed) !_src.empty() in function 'cvtColor'

and I am using Ubuntu(Linux)

so Thank you in advance

for your help

The reason you are getting this error is because the img has the value of None . So http://192.168.43.1:4747/mjpegfeed?640x480 is not a valid path.

Try looking at How to parse mjpeg http stream from ip camera?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM