Posted on

Using a ThermApp Camera with a Raspberry Pi-3

In this tutorial, I’ll show you how to install the software required to use the ThermApp thermal camera with the Pi. Once installed, you will be able to display thermal images using a standard video player such as VLC, mplayer, etc.

Start with a fresh download of the latest Raspbian operating system. These instructions are based on the build dated 17/1/2017.

NB: some of these steps will take quite a while to complete, so please be patient.

Open a Terminal Session and start by updating and upgrading the image as follows:

sudo apt-get update &&  apt-get upgrade

When finished, reboot the Pi by typing: reboot

Install a couple of dependencies as follows:

sudo apt-get install -y bc  libncurses5-dev libusb-1.0-0-dev

Next you need to find the correct kernel headers for your Pi. To do that, type uname -a

You should see a result that begins  similar to:

Linux raspberrypi 4.4.38-v7+

In this case the headers we need are called linux-headers-4.4.38-v7+ and you should open a browser and visit the site below to locate and download them:

https://niksula.hut.fi/~mhiienka/Rpi/linux-headers-rpi/

When the download completes, change to the Downloads directory by typing:

cd ~/Downloads

Now you can install the headers by typing:

sudo dpkg -i linux-headers-4.4.38-v7+_4.4.38-v7+-2_armhf.deb

NB: make sure you amend the line above to show the kernel version used on your Pi, as reported by uname earlier.

The next step is to download and install the linux loopback kernel module v4l2loopback. To install this, enter the following commands in a Terminal Session:

git clone https://github.com/umlaeute/v4l2loopback.git

When complete, change to the v4l2loopback directory and build the module as follows:

cd ~/v4l2loopback

sudo make && make install

The next step is to install ThermApp as follows:

cd ~

git clone https://github.com/encryptededdy/ThermAppCam.git

Once this has downloaded, install using the following:

cd ~/ThermAppCam/thermapp

./make.sh

That completes the main installation so the next step is to install a video player so you can view the camera output on the Pi screen. I suggest you use VLC as it’s free and works well. To install VLC type the following from a Terminal Session:

sudo apt-get install vlc

To make operation a bit simpler I suggest you create a script file to load the loopback module and start the ThermApp. To do that type the following commands:

cd ~

sudo nano thermal.sh

This will open a text editor where you should enter the following:

sudo modprobe videodev

cd ~/v4l2loopback

sudo insmod ./v4l2loopback.ko

cd  ~/ThermAppCam/thermapp

sudo ./thermapp

Now press Control-X and answer Y to save the new file.

Make the script executable by typing:

sudo chmod +x thermal.sh

Use the Pi file manager to drag a copy of thermal.sh to the desktop. To start the camera, double-click on the desktop link and choose Execute in Terminal to start the camera. Once the calibration is complete, open VLC from the Sound & Video menu. Choose Media – Open Capture Device. Set the Capture mode to Video camera and Video device name to /dev/video0.

 

That’s it!

 

Mike – G4WNC

 

10 thoughts on “Using a ThermApp Camera with a Raspberry Pi-3

  1. Thanks for this Mike

    Further to discussions, I have uploaded the 2.2GB zipped file to

    https://mega.nz/#!vpJnWKoQ!UMOT4bxDzaxHmhrJPM_jBQEwcFZaHl0c6yvGCyyfMEs

    This contains a copy of the OS image you provided, as per above, plus a short readme text file that identifies some of the earlier contributors to the work.

    1. Hey Giles I tried downloading your zip file but this OS image is not working at all on my raspberry pi 3. It even partitions the sd card and makes the card un-usable. Any recommendations? Also where did you get the code to get the mplayer-thermal.sch file?

  2. I don’t want to run video on the pi, just capture an image occasionally for upload to a website. Is there a tutorial somewhere on how to achieve that?

  3. Got down to ./make.sh Mike but this looks a bit fatal to me, not that I know anything about C

    root@raspberrypi:~/ThermAppCam/thermapp# ./make.sh
    main.c: In function ‘main’:
    main.c:137:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
    for(int i = 0; i < PIXELS_DATA_SIZE; i++){
    ^
    main.c:137:5: note: use option -std=c99, -std=gnu99, -std=c11 or -std=gnu11 to compile your code
    main.c:141:13: error: redefinition of ‘i’
    for(int i = 0; i < 50; i++){
    ^
    main.c:137:13: note: previous definition of ‘i’ was here
    for(int i = 0; i < PIXELS_DATA_SIZE; i++){
    ^
    main.c:141:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
    for(int i = 0; i < 50; i++){
    ^
    main.c:145:9: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
    for(int j = 0; j < PIXELS_DATA_SIZE; j++){
    ^
    main.c:150:13: error: redefinition of ‘i’
    for(int i = 0; i < PIXELS_DATA_SIZE; i++){
    ^
    main.c:141:13: note: previous definition of ‘i’ was here
    for(int i = 0; i < 50; i++){
    ^
    main.c:150:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
    for(int i = 0; i < PIXELS_DATA_SIZE; i++){
    ^
    main.c:156:13: error: redefinition of ‘i’
    for(int i = 0; i < PIXELS_DATA_SIZE; i++){
    ^
    main.c:150:13: note: previous definition of ‘i’ was here
    for(int i = 0; i < PIXELS_DATA_SIZE; i++){
    ^
    main.c:156:5: error: ‘for’ loop initial declarations are only allowed in C99 or C11 mode
    for(int i = 0; i < PIXELS_DATA_SIZE; i++){

    1. Hi Kris,

      Sorry to hear you’re having problems. I only put this together as a favour for a colleague and I’m not into thermal imaging so this is not being maintained. However, I suspect this is due to the wrong version of the C compiler. The Old Raspbian Jessie used GCC 4.9 whereas Stretch has upgraded to GCC 5. The following link has some ideas on how to revert to an earlier compiler.

      Downgrade GCC

      Good luck!

      Mike – G4WNC

  4. Hey Mike ,

    College student here trying to utilize the thermapp with the raspberry pi 3. I made it all the way to the end but when I try to execute the thermal.sh it does nothing.

    1. I originally wrote the instructions for a friend of mine but thought I’d share here in case it was useful. I did this a while ago and don’t have any thermal imaging kit here to test it but I’ll see if I can help.
      However, I need a bit more information. When you say it does nothing, can you describe more precisely what happens? Something must happen even if it’s just the cursor moving to the next line.

      Look forward to hearing from you. Mike

      1. So I installed everything and when I got to the end where I am supposed to execute in terminal the screen blinks once I click and that is all that happens.

        1. Going to start over again from the beginning and see if it works when I try it again. Maybe I did something wrong towards the beginning

          1. Also I looked at Giles files and he has a thermal.sh and a mplayer-thermal.sch

Leave a Reply

Your email address will not be published. Required fields are marked *