Reputation: 1
I am trying to do some real-time image processing by openCV with videos from web-camera and thermal-camera. I am using multi-threadings methods: one threading for one camera. The simplified code is given below.
I have confirmed this code works fine for two web cameras (one laptop build-in cam and a Logitech web cam), it also works fine for a thermal camera standing alone (infiray xtherm 2). However, when I tried to take the combination of 1 webcam and 1 thermal camera, I got significant latency on the thermal camera frames. This latency automatically disappeared after I turned off the web-cam preview window.
import cv2
import threading
def simpleVideo(camName, camInd):
cv2.namedWindow(camName)
cam= cv2.VideoCapture(camInd, cv2.CAP_DSHOW)
while(True):
ret, frame=cam.read()
cv2.imshow(camName, frame)
if cv2.waitKey(1) == 27: # exit on ESC
break
cam.release()
cv2.destroyWindow(camName)
camT = threading.Thread(target=simpleVideo, args=('cam',0,))
# thermT = threading.Thread(target=simpleVideo, args=('therm',1,))
camT.start()
# thermT.start()
I would like to have synchronised frames between webcam and thermal camera with reasonable frame rate, hence one can detect the hot spot within the viewrange in real time.
I am quite new in openCV and multi-threadings. I appreciate anyone can offer me some help (or other approches). Thanks in advance.
Upvotes: 0
Views: 124