Products > Thermal Imaging
Python Script For PI
OutoftheBox:
Looking to use a thermal camera and raspberry pi zero 2w for a project. I have it working, with Les Wright's PyThermalCamera python script. The raw.py script is close to what i want as it appears to have less lag, doesn't have thermal data overlay, and appears to have a sharper image then the tc001v4.2.py version. However, the raw isn't scalable or capable of full screen and has the duplicate green data below. Is there an easy script to create this... im a noob in python? Thanks for any help!
Amish Technician:
Have you seen this project? The overlays can be turned off, and it can go full screen.
https://www.eevblog.com/forum/thermal-imaging/rasbpi-and-topdon-tc001-(guinea-pig)-tester-requested/
G28:
--- Quote from: OutoftheBox on December 14, 2023, 05:31:43 pm ---Looking to use a thermal camera and raspberry pi zero 2w for a project. I have it working, with Les Wright's PyThermalCamera python script. The raw.py script is close to what i want as it appears to have less lag, doesn't have thermal data overlay, and appears to have a sharper image then the tc001v4.2.py version. However, the raw isn't scalable or capable of full screen and has the duplicate green data below. Is there an easy script to create this... im a noob in python? Thanks for any help!
--- End quote ---
What exactly are you looking for the Python script to do ?
The 2nd Python script has integer scaling and if you want that added to the 1st script, that is fairly easy.
You can also eliminate the 2nd-subframe fairly easily.
Python is slow and single threaded so you won't get it to go faster than the raw.py script which doesn't mine any of the thermal data.
If those are the only 2 functions you want, that is easy, especially if you don't want to change scale while in use, just static sized video playback.
G28:
--- Quote from: OutoftheBox on December 14, 2023, 05:31:43 pm ---Looking to use a thermal camera and raspberry pi zero 2w for a project. I have it working, with Les Wright's PyThermalCamera python script. The raw.py script is close to what i want as it appears to have less lag, doesn't have thermal data overlay, and appears to have a sharper image then the tc001v4.2.py version. However, the raw isn't scalable or capable of full screen and has the duplicate green data below. Is there an easy script to create this... im a noob in python? Thanks for any help!
--- End quote ---
OutOfTheBox and those that are interested.
Here is the raw script modified to:
- split the frame into the separate image and thermal sub frames
- only display the image frame
- scale the window and image sub-frame to 3X native resolution
- apply the JET colormap so image sub-frame is no longer monochrome
Hope this helps.
--- Code: ---#!/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()
--- End code ---
OutoftheBox:
Thank you all for the replies! You guys are amazing. I was able to get it working. This is a really cool community
Navigation
[0] Message Index
[#] Next page
Go to full version