0

I have 2 thread. Thread 1 to get streaming from camrea IP and thread 1 will process those stream. I hope two thread run parallel but it's not. thread 2 is not reached.

def thread_get_image():
    count = 0
    while cap.isOpened():
        ret, frame = cap.read()
        t = datetime.datetime.now()
        if ret:
            count += 1
            path = "data/{}.jpg".format(count)
            cv2.imwrite(path, frame)
            queueImage.put((path, t))
        else:
            break
        time.sleep(0.05)
    cap.release()
    cv2.destroyAllWindows
def thread_processing():
    while not queueImage.empty():
         do_something()
         time.sleep(0.05)
t1 = threading.Thread(target=thread_get_image())
t1.start()

t2 = threading.Thread(target=thread_processing())
t2.start()
  • 1
    You called the function `target=thread_get_image()` instead of referenced the function `target=thread_get_image`. – tdelaney Jul 27 '20 at 02:37

1 Answers1

0

You have to do the following at the end of your code:

t1.join()
t2.join()