Cost-effective Thermal Camera

by arjun2000ananth in Circuits > Raspberry Pi

1999 Views, 12 Favorites, 0 Comments

Cost-effective Thermal Camera

download.jpg
images.jpg
images (1).jpg
anB8h.jpg
  • 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

PCB Development

Screenshot (38).png
Screenshot (39).png
Screenshot (37).png
  • 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.

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.

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

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
  • Then run: git clone https://github.com/adafruit/Adafruit_Python_GPIO.... which will download the Adafruit package to your Raspberry Pi
  • Move inside the directory: cd Adafruit_Python_GPIO
  • And install setup by running the command: sudo python setup.py install
  • Now install scipy and pygame : sudo apt-get install -y python-scipy python-pygame
  • Finally, install the color library by issuing the command: sudo pip install colour Adafruit_AMG88xx

Enabling I2C Interface

  • Issue the command: sudo raspi-config
  • Click on the Advanced options and select I2C and then enable it and select Finish
  • Reboot the Pi to succesfully enable I2C
  • Make sure that you have enabled Camera and VNC interfaces too

Wiring the Sensor and Camera

  • You should connect only 4 pins of AMG8833 to Pi and leave the IR pin.
  • 5V supply and ground can be connected to GPIO pins 1 and 6
  • SDA and SCL are wired to pin 4 and 5 of the Pi.
  • Login to raspberry with ssh
  • run: sudo i2cdetect -y 1
  • You should see "69" on the 9th column if not there is some issue in wiring the sensor with Pi.
  • Finally connect the pi camera v2 to the camera slot in the raspberry pi

Heat Mapping

Heat mapping of AMG8833 with Raspberry Pi

Image Processing

  • Temperature Mapping
    1. 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
    2. When the sensor is initiated, the lowest temperature is mapped to 0(Blue) and the highest temperature to 1023(Red)
    3. All other temperatures in between are assigned correlated values within the interval
    4. The sensor output is 1 x 64 array which is resized to a matrix.
  • Interpolation
    1. 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
    2. Interpolation works by constructing new data points between a set of known points however accuracy decreases.
  • Numbers to images
    1. Numbers ranging from 0 to 1023 in 32 x 32 matrix are converted into decimal code in the RGB colour model.
    2. From the decimal code, it is easy to generate the image with a function from SciPy library
  • Resizing with anti-aliasing
    1. 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.
    2. It has anti-aliasing filter which will smooth out the edges between the pixels when enlarged up
  • Transparent Image overlay
    1. The digital image and heat image are then blended to one final image adding them with 50% transparency each.
    2. When images from two sensors with a parallel distance between them are fused, they won't completely overlap
    3. Finally, Minimum and Maximum Temperature measures by AMG8833 is displayed with overlaying text on display

Code and PCB Files

  • I have attached the testing and final code for the project below.

Conclusion

Cost-effective Thermal Camera with Raspberry Pi

  • 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.