Has anyone got theirs to work on Linux? I had a cheaper 25hz aliexpress thermal to work with a pi zero 2w using python3 scripts from this forum. The lens did not work well for the project I am trying to adapt it to--so I upgraded to the new cam. However, I cant get the XH09 to work. The Xh09 will only display static for a moment and then turn a solid grey color on the display.
I am looking for the pi zero 2w to process the data and display it to a comp out video. I am looking to keep it at 50hz with minimal lag.
This is the code being used:
#!/usr/bin/env python3
import cv2
import numpy as np
import argparse
parser = argparse.ArgumentParser()
parser.add_argument("--device", type=int, default=0, help="Video Device number e.g. 0, use v4l2-ctl --list-devices")
args = parser.parse_args()
if args.device:
dev = args.device
else:
dev = 0
#init video
cap = cv2.VideoCapture('/dev/video'+str(dev), cv2.CAP_V4L)
#cap.set(cv2.CAP_PROP_CONVERT_RGB,False)
cap.set(cv2.CAP_PROP_CONVERT_RGB,0.0)
#we need to set the resolution here why?
'''
wright@CF-31:~/Desktop$ v4l2-ctl --list-formats-ext
ioctl: VIDIOC_ENUM_FMT
Index : 0
Type : Video Capture
Pixel Format: 'YUYV'
Name : YUYV 4:2:2
Size: Discrete 256x192
Interval: Discrete 0.040s (25.000 fps)
Size: Discrete 256x384
Interval: Discrete 0.040s (25.000 fps)
'''
scale = 3
width = (256 * scale)
height = (192 * scale)
name = 'Thermal'
cv2.namedWindow(name,cv2.WINDOW_GUI_NORMAL)
cv2.resizeWindow(name, width, height) # Scale window once to desired scale
while(cap.isOpened()):
# Capture frame-by-frame
ret, frame = cap.read()
if ret == True:
cv2.namedWindow(name,cv2.WINDOW_NORMAL)
imdata,thdata = np.array_split(frame, 2) # Split into individual sub-frames
imdata = cv2.cvtColor(imdata, cv2.COLOR_YUV2BGR_YUYV)
imdata = cv2.resize(imdata, (width, height), cv2.INTER_CUBIC)
imdata = cv2.applyColorMap(imdata, cv2.COLORMAP_JET)
cv2.imshow(name,imdata)
keyPress = cv2.waitKey(3)
if keyPress == ord('q'):
break
capture.release()
cv2.destroyAllWindows()