I have developed a device that can be attached to a drone and can live-stream a blended frame made of the thermographic image showing thermal radiation and regular photography with visible light.
The platform consists of a small single-boarded computer, a thermal camera sensor, and a regular camera module.
This project aims to examine the possibilities of a low-cost thermal imaging platform for detecting damages in solar panel which is characterized by heat signatures.
Supplies
Raspberry Pi 3B+
Panasonic AMG8833 grid-eye
Pi Camera V2
Laptop with VNC viewer
Step 1: PCB Development
The PCB board for Panasonic grid-eye sensor can be designed with help of Auto-desk EAGLE.
The .brd file is developed similar to the Adafruit AMG8833 module with slight modifications
Then the PCB can be printed with PCB manufacturers and I used pcbway.com, where my first order was completely free of charge.
I found that PCB soldering was completely different from the soldering I knew as it involved surface mounted devices, so I went to another PCB manufacturer and got my PCB soldered with the sensor.
Step 2: Software Devopment
The code is written in Thonny, a python Integrated Development Environment.
The procedure behind the project was to connect the pi camera and install associated software.
The next step was to connect the thermal sensor to correct GPIO pins and install the Adafruit Library for utilizing the sensor.
Adafruit library contained script for reading the sensor and mapping the temperatures to colors however, moving images it created couldn't be implemented
Therefore code was rewritten to a format supporting image processing, mainly for fusing two frames together.
Step 3: Reading the Sensors
To gather data from thermal camera ADAFRUIT library was utilised, which allows fo reasy reasing the sensors with command readpixels(), generating an array containing temepratures in degree Celsius measured from sensors seperate elements.
For the Pi camera, the function command picamera.capture() generates an image with specified output file format
In order to suit rapid processing a lower resolution was set to 500 x 500 pixels
Step 4: Thermal Sensor Setup
Firstly, we have to install the Adafruit Library and python packages
Open the command prompt and run: sudo apt-get update which will update you Pi
Then issue the command: sudo apt-get install -y build-essential python-pip python-dev python-smbus git
Move into the directory Adafruit_AMG88xx_python/examples
issue the command : sudo python thermal_cam.py
I have attached the code for heat mapping AMG8833 below.
Step 8: Image Processing
Temperature Mapping
To visualize the thermal data, the temperature values are mapped into a color gradient, ranging from blue to red with all other colours in between
When the sensor is initiated, the lowest temperature is mapped to 0(Blue) and the highest temperature to 1023(Red)
All other temperatures in between are assigned correlated values within the interval
The sensor output is 1 x 64 array which is resized to a matrix.
Interpolation
The resolution of the Thermal sensor is fairly low, 8 x 8 pixels, so cubic interpolation is used to increase the resolution to 32 x 32 which results in matrix 16 times larger
Interpolation works by constructing new data points between a set of known points however accuracy decreases.
Numbers to images
Numbers ranging from 0 to 1023 in 32 x 32 matrix are converted into decimal code in the RGB colour model.
From the decimal code, it is easy to generate the image with a function from SciPy library
Resizing with anti-aliasing
To resize 32 x 32 image to 500 x 500 in order to match the resolution of Pi camera, PIL (Python Image Library) is used.
It has anti-aliasing filter which will smooth out the edges between the pixels when enlarged up
Transparent Image overlay
The digital image and heat image are then blended to one final image adding them with 50% transparency each.
When images from two sensors with a parallel distance between them are fused, they won't completely overlap
Finally, Minimum and Maximum Temperature measures by AMG8833 is displayed with overlaying text on display
Step 9: Code and PCB Files
I have attached the testing and final code for the project below.
Thus a thermal Camera has been built with Raspberry Pi and AMG8833.
The final video has been embedded in this post
It can be observed that the temperature changes instantaneously as I get the lighter near the setup and the flame of the lighter has been accurately detected by the sensor.
Hence this project can be further developed for fever detection in people entering a room which will be very helpful in this COVID19 crisis.