Python Thread: Only One Python Thread Is Running
I'm working on the webcam using python and opencv, it seems that it lagged between reading the first one and the second one. So I want to use python thread to fix it. Here is my co
Solution 1:
According to the documentation, the target
argument to the Thread
constructor is
the callable object to be invoked by the run() method. Defaults to None, meaning nothing is called.
You are passing webcam0_read()
, which is not a callable. You are actually calling the webcam0_read
function, which is stuck in its while
loop and never returning. The rest of the code isn't even executing.
Change your target
arguments to webcam0_read
and webcam1_read
:
t0=Thread(target=webcam0_read)
t0.setDaemon(True)
t0.start()
t1=Thread(target=webcam1_read)
t1.setDaemon(True)
t1.start()
Post a Comment for "Python Thread: Only One Python Thread Is Running"