lepton3

package module
v0.0.0-...-22311c1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2021 License: Apache-2.0 Imports: 15 Imported by: 10

README

lepton3

This package implements a robust, efficient Go interface to the FLIR Lepton 3 thermal cameras. Care is taken to avoid memory allocations in the critical path where possible to maximise performance.

Usage

A reasonably simple example of how to use the package can be found in the leptonutil subdirectory. This is a utility which captures frames from the camera and optionally saves them to PNG files.

To build leptonutil for the Raspberry Pi:

$ export GOARCH=arm
$ export GOARM=7
$ cd leptonutil
$ go build    # not install!

Further information

The data sheet for the camera contains a wealth of useful information. It can be found here: http://www.flir.com/uploadedFiles/OEM/Products/LWIR-Cameras/Lepton/Lepton-3-Engineering-Datasheet.pdf

Documentation

Index

Constants

View Source
const (
	FrameCols     = 160
	FrameRows     = 120
	FramesHz      = 9
	BytesPerFrame = packetsPerFrame * vospiDataSize
	Brand         = "flir"
	Model         = "lepton3"
	Model35       = "lepton3.5"
)
View Source
const (
	FFCShutterModeManual   = cci.FFCShutterModeManual
	FFCShutterModeAuto     = cci.FFCShutterModeAuto
	FFCShutterModeExternal = cci.FFCShutterModeExternal
)
View Source
const (
	ShutterTempLockoutStateInactive = cci.ShutterTempLockoutStateInactive
	ShutterTempLockoutStateHigh     = cci.ShutterTempLockoutStateHigh
	ShutterTempLockoutStateLow      = cci.ShutterTempLockoutStateLow
)
View Source
const (
	FFCNever    = "never"
	FFCImminent = "imminent"
	FFCRunning  = "running"
	FFCComplete = "complete"
)

These are the valid values for the Telemetry.FFCState field.

Variables

View Source
var Big16 big16

Big16 translates big endian 16bits words but everything larger is in little endian.

It implements binary.ByteOrder.

Functions

func NewRawFrame

func NewRawFrame() []byte

NewRawFrame returns a correctly sized byte slice for holding a single Lepton 3 frame.

func ParseRawFrame

func ParseRawFrame(raw []byte, out *cptvframe.Frame, edgePixels int) error

ParseRawFrame converts a byte slice containing a raw Lepton 3 frame into a cptvframe.Frame. The result is writing into the Frame provided.

func ParseTelemetry

func ParseTelemetry(raw []byte, t *cptvframe.Telemetry) error

ParseTelemetry converts a slice containing raw Lepton 3 telemetry data into a Telemetry struct.

Types

type BadFrameErr

type BadFrameErr struct {
	Cause error
}

func (*BadFrameErr) Error

func (e *BadFrameErr) Error() string

type Celsius

type Celsius = devices.Celsius

func CelsiusFromFloat

func CelsiusFromFloat(c float64) Celsius

CelsiusFromFloat creates a new Celsius from a floating point value. This is used for temperature fields in FFCMode.

type FFCMode

type FFCMode = cci.FFCMode

type FFCShutterMode

type FFCShutterMode = cci.FFCShutterMode

type Lepton3

type Lepton3 struct {
	// contains filtered or unexported fields
}

Lepton3 manages a connection to an FLIR Lepton 3 camera. It is not goroutine safe.

func New

func New(spiSpeed int64) (*Lepton3, error)

New returns a new Lepton3 instance.

func (*Lepton3) Close

func (d *Lepton3) Close()

Close stops streaming of packets from the camera and closes the SPI device connection. It must only be called if streaming was started with Open().

func (*Lepton3) FPS

func (l *Lepton3) FPS() int

func (*Lepton3) GetCustomerPartNum

func (d *Lepton3) GetCustomerPartNum() (string, error)

The OEM customer part number, which may or may not actually be useful

func (*Lepton3) GetFFCModeControl

func (d *Lepton3) GetFFCModeControl() (*FFCMode, error)

GetFFCModeControl returns the parameters and state relating to FFC.

func (*Lepton3) GetModel

func (d *Lepton3) GetModel() (string, error)

Get the camera model. lepton or lepton3.5

func (*Lepton3) GetPartNum

func (d *Lepton3) GetPartNum() (string, error)

The OEM part number, which is distinct between lepton versions. Lepton 3: 500-0726-01 Lepton 3.5: 500-0771-01 See https://www.flir.es/globalassets/imported-assets/document/lepton-3-3.5-datasheet.pdf

func (*Lepton3) GetSerial

func (d *Lepton3) GetSerial() (uint64, error)

Get the camera serial number

func (*Lepton3) GetSoftwareVersion

func (d *Lepton3) GetSoftwareVersion() (LeptonSoftwareRevision, error)

The software and dsp revisions, which we can use to try and determine what version of the lepton module we have.

func (*Lepton3) GetTLinearEnabled

func (d *Lepton3) GetTLinearEnabled() (bool, error)

Whether or not TLinear is enabled. It is enabled by default on radiometric lepton modules (2.5, 3.5), and trying to see if it is enabled on a lepton 3.0 gives an error, enabling us to determine reliably if we have a radiometry enabled lepton module.

func (*Lepton3) IsRadioMetricLeptonModel

func (d *Lepton3) IsRadioMetricLeptonModel() bool

func (*Lepton3) NextFrame

func (d *Lepton3) NextFrame(outFrame []byte) error

NextFrame returns the next frame from the camera into the raw frame slice.

The output slice is provided (rather than being created by NextFrame) to minimise memory allocations.

NextFrame should only be called after a successful call to Open(). Although there is some internal buffering of camera packets, NextFrame must be called frequently enough to ensure frames are not lost.

func (*Lepton3) Open

func (d *Lepton3) Open() error

Open initialises the SPI connection and starts streaming packets from the camera.

func (*Lepton3) ResX

func (l *Lepton3) ResX() int

func (*Lepton3) ResY

func (l *Lepton3) ResY() int

func (*Lepton3) RunFFC

func (d *Lepton3) RunFFC() error

RunFFC forces the camera to run a Flat Field Correction recalibration.

func (*Lepton3) SetAutoFFC

func (d *Lepton3) SetAutoFFC(auto bool) error

func (*Lepton3) SetFFCModeControl

func (d *Lepton3) SetFFCModeControl(mode *FFCMode) error

SetFFCModeControl sets the parameters and state relating to FFC. To avoid strange behaviour, it is important to call this with a FFCMode based on a recent return from GetFFCModeControl.

Lepton 3 camera defaults:

&FFCMode{
    FFCShutterMode:          FFCShutterModeAuto
    ShutterTempLockoutState: ShutterTempLockoutStateInactive
    VideoFreezeDuringFFC:    true
    FFCDesired               <dynamic state, no default>
    ElapsedTimeSinceLastFFC: <dynamic state, no default>
    DesiredFFCPeriod:        5 * time.Minute
    ExplicitCommandToOpen:   true
    DesiredFFCTempDelta:     CelsiusFromFloat(3.0)
    ImminentDelay:           52
}

func (*Lepton3) SetLogFunc

func (d *Lepton3) SetLogFunc(log func(string))

func (*Lepton3) SetRadiometry

func (d *Lepton3) SetRadiometry(enable bool) error

SetRadiometry enables or disables radiometry mode. If enabled, the camera will attempt to automatically compensate for ambient temperature changes.

func (*Lepton3) Snapshot

func (d *Lepton3) Snapshot() ([]byte, error)

Snapshot is convenience method for capturing a single frame. It should *not* be called if streaming is already active.

type LeptonSoftwareRevision

type LeptonSoftwareRevision struct {
	Gpp_major uint8
	Gpp_minor uint8
	Gpp_build uint8
	Dsp_major uint8
	Dsp_minor uint8
	Dsp_build uint8
	Reserved  [2]uint8
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL