Reading lepton in MATLAB using MATLAB support package for Raspberry Pi

1,172 views
Skip to first unread message

Sina D

unread,
Sep 9, 2015, 3:46:18 PM9/9/15
to Flir Lepton
Hi everyone,

I want to read Lepton's module in MATLAB r2015a. I am using a Raspberry Pi model B which I have attached it to my PC using Ethernet cable.
In MATLAB's support package for Raspberry Pi, I could find a command to read and write from/to SPI device.
I know that Lepton's module data could be read through SPI, however, I dont know what kind of data I should write and how to read. (Actually my background is in mechanical engineering and I am totally new to working with micro-controllers and electronics stuff.
could anybody help me with this? 
my exact question would be: what data do i need to write on SPI and what kind of variable should I define to read the date from SPI?

MATLAB's command for writing and reading through SPI is as following:

  • dataOut = writeRead(dev,dataIn,precision)
Thanks a lot,
Sina

robert hyde

unread,
Feb 2, 2016, 6:31:23 AM2/2/16
to Flir Lepton
Any progress with this? I have a similar project

Mahdi Hussein

unread,
Feb 2, 2016, 10:51:17 PM2/2/16
to Flir Lepton
It is not possible to read SPI data fast enough using the Matlab command writeRead (on raspberry Pi or Arduino etc).

To read a complete frame from the Lepton you have to read data within a relatively tight window of time. It's simply not possible to do this directly from Matlab.

You must program a microprocessor or raspberry Pi or equivalent to read and store a complete frame from the Lepton then send this complete frame over to Matlab.

Kurt Kiefer

unread,
Feb 5, 2016, 5:13:04 PM2/5/16
to Flir Lepton
Matlab's USB webcam support should work with the PureThermal 1 FLIR Lepton board ... the onboard MCU does the work of keeping up with the SPI data stream and sends complete frames out as USB video.

Ron

unread,
Apr 5, 2016, 7:33:30 AM4/5/16
to Flir Lepton
You must program a microprocessor or raspberry Pi or equivalent to read and store a complete frame from the Lepton then send this complete frame over to Matlab.
 
Is this the only solution to transfer the data to Matlab? Is there any tutorial how to achieve this? It would be very helpful.
 
I've seen this in another thread on here: https://groups.google.com/forum/#!topic/flir-lepton/JJVf4crDpYw 
 
Is there any possibility to get this done on a raspberry pi? I try to avoid buying the PureThermal 1 FLIR Lepton board.
 
Thank you very much in advance.
 
Ron

Mahdi Hussein

unread,
Apr 6, 2016, 4:15:54 AM4/6/16
to Flir Lepton
Well yes you could write a C++ program on raspberry pi to send Lepton images over serial (UART) into Matlab.

At a bare minimum I think you would need to:
As far as I know there isn't code available that does specifically this. This wouldn't really be that advanced but it's probably not a programming task for a beginner...

If you have an Arduino Due laying around (which you probably don't) you could try the code near the end of that other thread. But really the easiest option would be to purchase a pure thermal 1 board.

Hope this helps 

Myles Syverud

unread,
Jan 22, 2018, 3:52:49 AM1/22/18
to Flir Lepton
Hello Mahdi,

I have been looking at your posts for frame grabbing. I am also familiar wit the purethermal. 

Using a simple readwrite from the rpi toolbox, I am seeing 

Elapsed time is 0.030957 seconds.

after reading a full vospi frame (164 bytes)

This timing should be sufficient for the lepton, I am curious why I am still not able to sync. 

Can you elaborate on why you think it is not fast enough?!\

Myles Syverud

unread,
Jan 27, 2018, 5:52:40 AM1/27/18
to Flir Lepton
It turns out the "read SPI" block on simulink doesn't generate code entirely properly. The lepton requires 16MHz for reading the data on SPI. The generated code (as of 2017b, while writing this) is hard coded at 50kHz (regardless of what the user selects in hardware configuration for the model). 

More can be found here

it is possible to modify the template files that simulink uses to generate c code (for a work around) - you just have to find them on your host computer!
Message has been deleted

Archana Gupta

unread,
Apr 24, 2019, 4:18:29 AM4/24/19
to Flir Lepton
Hello Myles,

I was kind of trying to do the same thing with Lepton 3.5 using pylepton .
But have issues with interfacing with Matlab.
Have you been successful in doing yours?

Archana Gupta

unread,
Apr 24, 2019, 4:24:32 AM4/24/19
to Flir Lepton
have you succeeded in finishing it?
I have a similar project.
Reply all
Reply to author
Forward
0 new messages