Skip to content

groupgets/pylepton

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

35 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

pylepton (this software no longer works)

Quick and dirty pure python library for capturing images from the Lepton over SPI (for example, on a Raspberry PI).

Requires cv2 and numpy modules, if you don't have them already. On a Debian-based system you can probably do this:

$ sudo apt-get install python-opencv python-numpy

You can run the examples in the working directory, but a distutils setup is included to install into site-packages for distribution:

$ sudo python setup.py install

Example usage

import numpy as np
import cv2
from pylepton import Lepton

with Lepton() as l:
  a,_ = l.capture()
cv2.normalize(a, a, 0, 65535, cv2.NORM_MINMAX) # extend contrast
np.right_shift(a, 8, a) # fit data into 8 bits
cv2.imwrite("output.jpg", np.uint8(a)) # write it!

Image data from capture() is 12-bit, non-normalized (raw sensor data). Here we contrast extend it since the bandwidth tends to be narrow.

capture() returns a tuple that includes a unique frame ID, as lepton frames can update at ~27 Hz, but only unique ones are returned at ~9 Hz. Currently, this is just a simple sum, but ideally this will turn into a real frame ID from telemetry once this feature is implemented.

Note also that the Lepton contructor can take as an optional argument the SPI device on which to find the Lepton. If in your system that device is /dev/spidev0.1, you can instantiate lepton as such:

...
with Lepton("/dev/spidev0.1") as l:
  ...

Example programs

pylepton_overlay

Requires python-picamera, a Raspberry PI, and compatible camera such as http://www.adafruit.com/products/1367

$ sudo apt-get install python-picamera

$ pylepton_overlay --help
Usage: pylepton_overlay [options]

Options:
  -h, --help            show this help message and exit
  -f, --flip-vertical   flip the output images vertically
  -a ALPHA, --alpha=ALPHA
                        set lepton overlay opacity

To get a 100% lepton overlay (note camera installation still required):

$ pylepton_overlay -a 255

pylepton_capture

Note that this program will output any image format that opencv knows about, just specify the output file format extension (e.g. output.jpg or output.png)

$ pylepton_capture --help
Usage: pylepton_capture [options] output_file[.format]

Options:
  -h, --help           show this help message and exit
  -f, --flip-vertical  flip the output image vertically

To capture a png file named output.png:

$ pylepton_capture output.png

Important Note

GroupGets does not provide coding, firmware, or software support of any kind and will not respond to related requests. All software and firmware provided by GroupGets are offered solely as examples or potential starting points. These repositories may be outdated and are not guaranteed to function as intended.

We do not accept returns or offer replacements due to issues related to software, firmware, or code compatibility.

The software is provided "AS IS", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and non-infringement. In no event shall the authors or copyright holders be liable for any claim, damages, or other liability, whether in an action of contract, tort, or otherwise, arising from, out of, or in connection with the software or the use or other dealings in the software.

About

Quick and dirty pure python library for interfacing with FLIR lepton

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages