Acquire and Analyze Images from FLIR Ax5 Thermal Infrared Camera
This example shows how to acquire, preview, and analyze images from a FLIR Ax5 series thermal infrared camera in multiple ways.
This example uses a FLIR A35 camera, but is expected to work with other cameras in the Ax5 series with minor modifications.
Requirements:
Image Acquisition Toolbox™
Image Processing Toolbox™
Image Acquisition Toolbox Support Package for GenICam™ Interface
FLIR Ax5 GigE Vision® Thermal Infrared Camera
FLIR GenTL Producer included with the Spinnaker SDK
Gigabit Ethernet network adapter with jumbo frame support
Connect to Camera and Configure Acquisition
Create a connection to the FLIR Ax5 using the gentl
adapter with the videoinput
function. Then, get the source properties of the videoinput
object.
vid = videoinput("gentl",1,"Mono14")
Summary of Video Input Object Using 'FLIR Systems AB FLIR AX5(00:11:1c:02:7a:ef)'. Acquisition Source(s): FLIR AX5(00:11:1c:02:7a:ef)_Stream_0 is available. Acquisition Parameters: 'FLIR AX5(00:11:1c:02:7a:ef)_Stream_0' is the current selected source. 10 frames per trigger using the selected source. 'Mono14' video data to be logged upon START. Grabbing first of every 1 frame(s). Log data to 'memory' on trigger. Trigger Parameters: 1 'immediate' trigger(s) on START. Status: Waiting for START. 0 frames acquired since starting. 0 frames available for GETDATA.
src = getselectedsource(vid);
Since the default bit depth is 8-bit, set the preview data to full bit depth. Otherwise, MATLAB® shows only half of the data received from the camera.
vid.PreviewFullBitDepth = "on";
Configure Camera Properties
The FLIR A35 camera returns an image with a bit depth of 14 bits. Configure the camera to provide image data in temperature linear mode with high temperature resolution.
src.CMOSBitDepth = "bit14bit"; src.TemperatureLinearMode = "On"; src.TemperatureLinearResolution = "High";
Specify the atmospheric and object parameters. For measurement accuracy, these parameters must be configured correctly before acquiring images. For more information about these parameters, refer to the camera manual.
src.AtmosphericTemperature = 298; src.ObjectEmissivity = 1.0; src.ReflectedTemperature = 298;
The temperature resolution constant is used to convert image data to °C. Set its value to 0.04 or 0.4, depending on the value of the TemperatureLinearResolution
property. Refer to the camera manual for the appropriate values of the temperature resolution constant.
switch src.TemperatureLinearResolution case "High" k = 0.04; case "Low" k = 0.4; end
Acquire and Display Image from Camera Then Save As RGB Image
Acquire an image from the camera using the getsnapshot
function.
img = getsnapshot(vid);
Convert the captured image data to °C using the ax5degC
helper function with the temperature resolution value k
. The helper functions used in this example are attached as supporting files in the same directory as this example file.
imgC = ax5degC(img,k);
Specify the temperature range of the display color limits in °C.
tempRange = [22 70];
Display the thermal image using the thermalImageShow
helper function with the specified temperature range and units. You can click anywhere on the image to show the temperature information of that pixel.
thermalImageShow(imgC,tempRange,"\circC");
Convert the temperature intensity image to an RGB image using the thermal2rgb
helper function with the specified temperature range and colormap. Save the converted image as an image file.
RGB = thermal2rgb(imgC,tempRange,parula);
imwrite(RGB,"thermalImageRGB.png")
Acquire and Display Video from Camera
Configure the camera's FramesPerTrigger
acquisition property to capture 20 images.
vid.FramesPerTrigger = 20;
Acquire image data using the getdata
function.
start(vid) frames = getdata(vid,vid.FramesPerTrigger);
Convert the captured image data to °C using the ax5degC
helper function with the temperature resolution value k.
framesC = ax5degC(frames,k);
Display the sequence of acquired image frames using the montage
function with the previously specified temperature range.
montage(framesC,DisplayRange=tempRange)
Convert the frames to RGB and apply the parula colormap.
frameSize = vid.ROIPosition; numFrames = size(framesC,4); framesRGB = zeros(frameSize(4)-frameSize(2),frameSize(3)-frameSize(1),3,numFrames); for frame = 1:numFrames framesRGB(:,:,:,frame) = thermal2rgb(framesC(:,:,:,frame),tempRange,parula); end
Display the sequence of acquired image frames in color with the colormap applied.
montage(framesRGB)
Show Live Preview from Camera
Show an interactive live preview from the camera using the ax5Preview
helper function. The live images from the camera are converted to °C and shown in the preview window. You can click anywhere in the live preview image to view temperature information for the selected pixel.
ax5Preview(vid);
See Also
videoinput
| getdata
| montage
| imshow