FFC in Python and SPI -> I2C

1,121 views
Skip to first unread message

Dale jason

unread,
May 16, 2015, 12:25:29 AM5/16/15
to flir-...@googlegroups.com
I have enjoyed using the pylepton code from https://github.com/kekiefer/pylepton.  I wonder if anyone knows how to issue a flat field command to the camera using python.  

Second I am trying to understand how to program the camera and have read its interface spec which describes the I2C interface to it.  However when using it on the Raspberry PI with the breakout module one talks to it using the SPI interface.  My question is how does the conversion from SPI to I2C happen?  Is there a smart processor on the breakout module that does it?  Can one ignore the SPI interface and using only the I2C of the Breakout or is that not optimal?

My goal is to make an IR motion sensor video camera where the Lepton is the IR sensor and the PI camera takes video based on the motion detection of animals in my back yard.  I currently use OpenCV with the Raspberry PI camera to look for motion and filter out motion not caused by animals.  However it is not perfect and I hope the addition of IR will improve the filtering.  Anyway I'm familiar with doing that in both C++ and Python.  But I prefer Python to begin with.  So that is why my questions above.

Thank you Dale Eason

sa...@pureengineering.com

unread,
May 16, 2015, 1:11:26 AM5/16/15
to flir-...@googlegroups.com
I don't think there is any way to talk spi to i2c.  on the pi board you have to wire up both the spi and the i2c(if you want to issue i2c commands) 

if you get a lepton with a shutter (i recommend) then you don't need to issue a ffc command, and you can ignore the i2c port and only use the spi to get the data. 

Also for animal detection, you most likely don't need to use openCV.  almost any basic % change in pixels calculation threshold might be all you need, basically since this is a thermal camera, only living things will be changing on the camera. 


 

Dale jason

unread,
May 16, 2015, 2:12:15 AM5/16/15
to flir-...@googlegroups.com
Well I already have the lepton without the shutter so I don't want an additional camera.  Thus the need for FFC control.

Actually any rapid temp changes can show up as motion.  There are many more than just caused by living things.  First example is the exhaust of my home heating system which exits the side of my house close to where I put the camera.  I bet I will discover others.

 
I'm very familiar with motion detection algorithms and have been using some complex ones that help ignore water waves on the bird bath and grass waving and leaf shadows in the wind.  May not need to be that elaborate with IR but I know how to do it anyway.  OpenCV can be used with C, C++, and Python so no problem there.  It is also useful for displaying and saving images and videos and I have done so with the FLIR Lepton.  So no problem there as well.  Just hoping to find a good way to provide FFC in python.  Looks like I will have to  implement it in python myself using the existing C code as a guide.

Here is what my current software does to capture motion on Raspberry PI.  Start the PI camera taking a video.  While that is running capture frames from the IR camera or the PI camera and look for motion.  If motion is found extend the time the video should run.  Loop until no motion is detected.  Save the video with a timestamp name on the PI and also transfer it to the in house server over wifi.  If no motion was found during the original video interval then do nothing with that video and overwrite it with the next one.  There are python libraries that let me control the RPI camera in real time and to also sample its video in parallel for addition motion detection.  That library which is only in Python is why I'm intereseted in staying python for this project and why the pylepton library is also of interest.

Dale

Dale jason

unread,
May 16, 2015, 2:16:11 AM5/16/15
to flir-...@googlegroups.com
aa said: I don't think there is any way to talk spi to i2c.  on the pi board you have to wire up both the spi and the i2c(if you want to issue i2c commands) 

Dale says:
right.  I'm not trying to talk SPI to I2C.  I was just wondering how the breakout converted SPI to I2c and if the I2C on the breakout was a direct link to the I2C on the Lepton camera.

sa...@pureengineering.com

unread,
May 16, 2015, 2:24:56 AM5/16/15
to flir-...@googlegroups.com
The breakout board does not do any conversion from i2c to spi.  It is a direct link to the lepton camera thus the need to have both interfaces connected on the pi board. 

Also something to note about the FFC command. you need to put a even thermal object in front of the camera to calibrate. it would be annoying to have to walk up to the camera with something each time you want to issue a ffc. you can build up something with a servo to move something in front then issue the FFC, then move it away. This way the process is automated. 

Second note. As the camera temperature changes you will want to issue the FFC command to keep the ideal image. it is not a one time thing.  In observing the shuttered lepton, it does a FFC every few minutes at room temperature. 

I think you may be able to avoid FFC completely for your application if you have a well factory calibrated lepton module. 

Dale jason

unread,
May 16, 2015, 2:30:37 AM5/16/15
to flir-...@googlegroups.com
sa said:
The breakout board does not do any conversion from i2c to spi.  It is a direct link to the lepton camera thus the need to have both interfaces connected on the pi board. 

Dale says:
Ok I understand that is a direct link.   Now I'm just curious how the SPI -> I2C happens to the camera.

I also thought I might have to put a servo on to assist the FFC operation.  Too bad the shutter version came out after I got the original.

Dale
Reply all
Reply to author
Forward
0 new messages