Close

Getting the Thermal Camera to Work

A project log for Thermal Watch

An attempt to design a watch that integrates a thermal camera, whilst remaining sleek.

joshua-elsdonJoshua Elsdon 08/03/2017 at 13:040 Comments

Okidoke, so the last couple of days have been spent getting the thermal camera to work correctly. This surprised me as there is decent sample code specifically for ChibiOS on the GroupGets Github. I am not entirely sure what was going wrong. My best guess was that there was a mixture of small bugs compounding each other, most likely in the set up of the GPIOs and the SPI port (as the default port in all the examples is the one that is driving the OLED). These bugs were sorted after many hours of perturbing the code. 

Once I have a buffer with the image in it's native 14bit integer type (padded to short ints) I needed to render this into an image that looks sensible. This was achieved by  using the min and the max values from the previous frame (ain't nobody got time to prescan the newest image), and then linearly interpolating between blue -> green -> red in RGB 565 format. The results looked nice, though I could only render half of the frames delivered from the camera due to the time it took to process this. 

Changing the maths from floating point to integer saved the day, later I will precalculate some nice looking colour lookup tables. I thought floating point would be fine as the STM32L432 has an FPU, but it turns out I will need to pull every drop of performance to render all frames on the higher resolution Lepton 3 I intend to use in the final design. 

I still need to implement scaling so I can fill the whole screen (and downscale on the new sensor). Likely I will only be able to achieve 4:3 scaling ratio, as this can be interpolated using only bit shifting. I will waste a few pixels, as this will give me a 90x120 image and the OLED is 96x128. I can probably think of some simple GUI to make use of the extra space. 

Any way I will be able to clean my code up for public release now that the core functionality is functional. Here is a picture for you all to enjoy! 

Discussions