0
Good afternoon, guys! What’s up? So, I’m trying to connect a webcam per ip to the open cv, the webcam would be the camera on my phone and I’m using the Droid cam for that. It happens that I always come across this mistake:
Traceback (most recent call last):
File "c:/Users/uriel/Documents/Python/Project #1/droidcam.py", line 10, in <module>
cv2.imshow('IPWebcam',img)
cv2.error: OpenCV(4.2.0) C:\projects\opencv-python\opencv\modules\highgui\src\window.cpp:376: error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'
Here’s my full code:
import urllib.request
import cv2
import numpy as np
import time
URL = "http://xxx.xxx.x.xxx:xxxx/"
while True:
img_arr = np.array(bytearray(urllib.request.urlopen(URL).read()),dtype=np.uint8)
img = cv2.imdecode(img_arr,-1)
#imS = cv2.resize(img,(960, 540))
cv2.imshow('IPWebcam',img)
if cv2.waitKey(0):
break