Python Object detection screen not responding

I have the python code here
import cv2
import matplotlib.pyplot as plt
import cvlib as cv
import urllib.request
import numpy as np
from cvlib.object_detection import draw_bbox
import concurrent.futures

url='http://192.168.43.73/cam-hi.jpg'
im=None

def run1():
cv2.namedWindow("live transmission", cv2.WINDOW_AUTOSIZE)
while True:
img_resp=urllib.request.urlopen(url)
imgnp=np.array(bytearray(img_resp.read()),dtype=np.uint8)
im = cv2.imdecode(imgnp,-1)

    cv2.imshow('live transmission',im)
    key=cv2.waitKey(5)
    if key==ord('q'):
        break
        
cv2.destroyAllWindows()

def run2():
cv2.namedWindow("detection", cv2.WINDOW_AUTOSIZE)
while True:
img_resp=urllib.request.urlopen(url)
imgnp=np.array(bytearray(img_resp.read()),dtype=np.uint8)
im = cv2.imdecode(imgnp,-1)

    bbox, label, conf = cv.detect_common_objects(im)
    im = draw_bbox(im, bbox, label, conf)

    cv2.imshow('detection',im)
    key=cv2.waitKey(5)
    if key==ord('q'):
        break
        
cv2.destroyAllWindows()

if name == 'main':
print("started")
with concurrent.futures.ProcessPoolExecutor() as executer:
f1= executer.submit(run1)
f2= executer.submit(run2)
i am using python spyder how ever there are two screens the live one totally works fine while the detection objective one doesnt work it says not responding any idea?

s2

I think it goes somewhere wrong before the imshow() call. What does cv.detect_common_objects() return? Are the variables set or null? Verify that img_resp is not empty

There are different ways to do object detection, you could try different methods

This topic was automatically closed 180 days after the last reply. New replies are no longer allowed.