/LeptonVid

Lepton 3 SPI / GPIO streaming console application

Primary LanguageCBSD 2-Clause "Simplified" LicenseBSD-2-Clause

LeptonVid

FLIR Lepton 3 SPI / GPIO streaming console application

This program is a very simple tool to retrieve frames/pictures from FLIR Lepton 3 modules and print them on standard output.

There are many tools like this over there but I found many of them to have very big frame syncronization issues that I've not been able to fix.

This application was written for use on RaspberryPi 0 W boards connecting the Lepton 3 Module (with an adapter/breakout board) trough SPI port. To achieve the maximum performances and avoid synchronization issues I'm using an extra GPIO pin on which I received a VSYNC interrupt signal from the Lepton 3 module itself (see chapter 4.2.3.3.3 Frame Synchronization).

As suggested by Luke van Horn in his project is better to increase SPI device buffer size to increase overall performances (on RPi0W boards)) adding spidev.buffer=131072 to /boot/cmdline.txt

Usage

Once compiled the tool act as a typical Unix console application; typing LeptonVid -? will print out the usage as follows:

[-f frames] 
[-F frames timeout] 
[-D startup delay] 
[-p port] 
[-s bitrate] 
[-i strip frame delimiters] 
[-r reset Lepton on startup]
[-w gpio pin]

frames: is the number of frames the application will retrieve from the module, please note that only valid frames are taken into account. Omitting this option will cause LeptonVid to run forever.

frames timeout: allows to specify the timeout time in microseconds of the ioctl() read function which gather the frame data from the module (default value is set to 65535 microseconds).

startup delay: time to wait before interacting with camera module in seconds. Please note that official documentation states that the internal module initialization and calibration procedure will take not less than 5 seconds (default timeout value is 5 seconds).

port: allows to specify which device to use (default value is /dev/spidev0.0).

bitrate: SPI bus port bitrate in Hz (default value is set to 16MHz).

strip frame delimiters: when specified this option remove frame delimiters (i.e. F, EF tags printed before and after the frame body).

reset on startup: using this option will force Lepton module to be reset on application startup.

gpio pin: using this option to change the Raspebbery Pi pin used to input the VSYNC signal coming from Lepton module. Please note that we are using WiringPi pin enumeration standard sequence (default value is set to 6)

Wirings

As mentioned above this program requires Raspberry Pi board to be connected to Lepton module trough SPI bus. Please refer to official Raspberry Pi and FLIR Lepton Module (or/and support/breakout board vendor) pinout before proceed on wiring. Please note also that two more connections are required to get the application working these are:

  • I2C bus
  • VSYNC connection

I2C bus connection is required to enable commands to be issued to Lepton Module. VSYNC connection is needed to enter Lepton module VSYNC output into one of Raspberry Pi GPIO pin without this connection the frame synchronization will be impossibile and the application will fail. The default Raspberry Pi pin expected to be connected is pin 22 (pin 6 in WiringPi sequence). Where to pick the VSYNC output on Lepton module depends on support board design. If you are using PURE Egingeering Lepton Breakout Board this output is an exposed pad labeled GPIO3 placed on the back side of the board itself (yes you have to solder a wire on it).

lepton_breakout_board (Back)

Build

To create build this application simply clone this repo on your Raspberry Pi board and run make.sh. Please note that this application need a fresh install of WiringPi (I had several problems running it with stock WiringPi found on Raspbian), if you notice some problem in running the application try reinstalling this library.

Advanced use

I'm using this application to provide a stream of the image to a remote PC where is shown trough another simple application. The easiest way to do this (on Raspberry Pi as on any other Linux environment) is to use netcat command in this way:

LeptonVid | nc -k -l -p 5002

Now connecting on the port 5002 of your RPi board you can fetch the stream ad use it as you like.

References

Usefult repositories with Lepton 3 module software (running on Raspberry Pi):

  1. https://github.com/novacoast/Lepton-3-Module
  2. https://github.com/lukevanhorn/Lepton3
  3. Official FLIR Lepton 3 module support
  4. Official FLIR Lepton SDK

Groupgets campaigns:

Raspberry resources: