0

I need help with this code below:

cv2.imshow('test',img) error: (-215:Assertion failed) size.width>0 && size.height>0 in function 'cv::imshow'

Thanks in advance

import urllib.request
import cv2
import numpy as np

url='http://192.168.0.177:8080/video'

while True:
    imgResp=urllib.request.urlopen(url)
    imgNp=np.array(bytearray(imgResp.read()),dtype=np.uint8)
    img=cv2.imdecode(imgNp,-1)

    cv2.imshow('test',img)
    if ord('q')==cv2.waitKey(10):
        exit()

1 Answers1

0

It seems your img is empty. Try adding println(img.shape) before imshow. If it gives an error there is no valid image.

You should add code to check if an image has been successfully retrieved, and only display those images.

J.D.
  • 4,511
  • 2
  • 7
  • 20