Brief Summary
This video tutorial provides a step-by-step guide on measuring temperature using thermal images, videos, and cameras with Python and OpenCV. It covers the differences between Gray8 and Gray16 image formats, measuring temperature from thermal images and videos, and using a thermal camera for real-time temperature measurement.
- Understanding Gray8 vs Gray16 thermal images
- Measuring temperature from thermal images and videos
- Measuring temperature using a thermal camera in real-time
Introduction
The video introduces a tutorial on measuring temperature from thermal images, videos, and cameras using Python and OpenCV. It is part two of an infrared vision basic course, and it's recommended to watch the previous class for understanding infrared images and the technology behind them. The class is divided into four steps: understanding Gray8 and Gray16 images, measuring temperature from a thermal image, measuring temperature from a thermal video, and measuring temperature from a thermal camera.
Step 1: Thermal Imaging Formats - Gray8 vs. Gray16
This section explains the difference between Gray8 and Gray16 image formats, which are essential for working with thermal images. RGB images have three channels (red, green, blue), with pixel values between 0 and 255 per channel, codified using 8 bits (one byte). Thermal images are represented in grayscale, needing only one channel to represent pixel values between black (0) and white (255). To measure temperature, a Gray16 thermal image is needed, which uses 16 bits (0 to 65,535 values) to codify temperature information in each pixel value. The tutorial then demonstrates how to open a Gray16 thermal image in Python using OpenCV, convert it to a Gray8 image, and apply a colour map for visualisation. The cv2.IMREAD_ANYDEPTH
flag is crucial to prevent RGB conversion when opening the image.
Step 2: Measuring your First Temperature from a Thermal Image
This part of the tutorial focuses on measuring the temperature of a pixel in a thermal image. The process involves importing the necessary libraries (NumPy and OpenCV), opening the Gray16 thermal image, and defining the pixel coordinates. The video uses a specific formula for the RGM Vision thermal camera to convert pixel values from Kelvin to Celsius or Fahrenheit. The Gray16 image is converted to Gray8 for display, and a pointer is drawn to indicate the selected pixel. The temperature value is then displayed on both the Gray16 and Gray8 images.
Step 3: Measuring Temperature from a Thermal Video
The tutorial explains how to measure temperature from a thermal video by simulating a video using a sequence of Gray16 images. It involves importing libraries such as NumPy, OpenCV, os
, and argparse
. The video sequence path is selected using argparse
. A mouse pointer is created to dynamically select pixel values in each frame. The frame rate is controlled using the cv2.waitKey
function, and the video loops through each frame, opens the Gray16 image, calculates the temperature, converts the frame to Gray8, and displays the temperature and pointer on the frame. The frame rate for the RGM Vision thermal camera is 8 FPS, requiring a wait time of 125 milliseconds.
Step 4: Measuring Temperature from a Thermal Camera
This section guides on measuring temperature in real-time using a thermal camera. It involves importing OpenCV and NumPy, creating mouse pointer coordinates, and setting up the thermal camera using the cv2.VideoCapture
function. The camera index is specified, and on Windows, the cv2.CAP_DSHOW
flag is used to indicate the Direct Show backend. The thermal camera resolution is set, and the camera is configured as a Gray16 source, preventing RGB compression. A while
loop continuously reads frames from the camera, gets temperature values from the mouse pointer, calculates the temperature, converts the Gray16 frame to Gray8, and displays the temperature and pointer on the screen.