0
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

Keval Shah
  • 45
  • 1
  • 8

1 Answers1

0

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?

Red
  • 26,798
  • 7
  • 36
  • 58
  • please edit and tell me what changes can I make to avoid this error. I am new to video streamming with droidcam and to cv2 – Keval Shah Apr 03 '22 at 16:38