Camera Class

class pychronos.camera(sensor, onChange=None)
backlightEnabled

bool – True if the LCD on the back of the camera is lit. Can be set to False to dim the screen and save a small amount of power.

batteryChargeNormalized

float – Estimated battery charge, with 0% being fully depleted and 100% being fully charged.

batteryChargePercent

float – Estimated battery charge, with 0.0 being fully depleted and 1.0 being fully charged.

batteryVoltage

float – A measure of the power the removable battery is putting out, in volts. A happy battery outputs between 12v and 12.5v. This value is graphed on the battery screen on the Chronos.

cameraApiVersion

str – Version string of the pychronos module

cameraDescription

str – Descriptive string assigned by the user

cameraFpgaVersion

str – Version string of the FPGA bitstream that is currently running

cameraIdNumber

int – Unique camera number assigned by the user

cameraMaxFrames

int – The maximum number of frames the camera’s memory can save at the current resolution.

cameraMemoryGB

int – Amount of video memory attached to the FPGA in GiB

cameraModel

str – Camera model number

cameraSerial

str – Unique camera serial number

cameraTallyMode

str – Mode in which the recording LEDs should operate.

Parameters:
  • 'on' – All recording LEDs on the camera are turned on.
  • 'off' – All recording LEDs on the camera are turned off.
  • 'auto' – The recording LEDs on the camera are on whenever the status property is equal to ‘recording’.
colorMatrix

list(float) – The 9 matrix coefficients for the 3x3 color matrix converting the image sensor color space into sRGB. The coefficient values are stored in row-scan order.

config

Return a configuration dictionary of all saveable parameters

currentGain

int – The current gain of the image sensor as a linear multiplier of sensorIso.

currentIso

int – The ISO number of the image sensor at the current current gain.

dateTime

str – The current date and time in ISO-8601 format.

exposureMax

int – The maximum possible time, in nanoseconds, that the image sensor is capable of exposing a frame for at the current resolution and framePeriod.

exposureMin

int – The minimum possible time, in nanoseconds, that the image sensor is capable of exposing a frame for at the current resolution and framePeriod.

exposureMode

str – Mode in which frame timing and exposure should operate.

Parameters:
  • 'normal' – Frame and exposure timing operate on fixed periods and are free-running.
  • 'frameTrigger' – Frame starts on the rising edge of the trigger signal, and exposes the frame for a fixed exposure period. Once readout completes, the camera will wait for another rising edge before starting the next frame. In this mode, the framePeriod property constrains the minimum time between frames.
  • 'shutterGating' – Frame starts on the rising edge of the trigger signal, and exposes the frame for as long as the trigger signal is held high. Once readout completes, the camera will wait for another rising edge before starting the next frame. In this mode the exposurePeriod property has no effect and the framePeriod property constrains the minimum time between frames.
exposureNormalized

float – The current exposure time as a percentage between exposureMin and exposureMax.

exposurePercent

float – The current exposure time as a percentage between exposureMin and exposureMax.

exposurePeriod

int – Minimum period, in nanoseconds, that the image sensor is currently exposing frames for.

externalPower

bool – True when the AC adaptor is present, and False when on battery power.

externalStorage

dict – The currently attached external storage devices and their status. The sizes of the reported storage devices are in units of kB.

Examples

>>> print(json.dumps(camera.externalStorage, indent=3))
{
    "mmcblk1p1": {
        "available": 27831008,
        "mount": "/media/mmcblk1p1",
        "used": 3323680,
        "device": "/dev/mmcblk1p1",
        "size": 31154688
    }
}
framePeriod

int – The time, in nanoseconds, to record a single frame.

frameRate

float – The estimated estimated recording rate in frames per second (reciprocal of framePeriod).

ioDelayTime

Property alias of the ioMapping.delay.delayTime value

ioInputConfigIo1

Input 1 config such as threshhold

ioInputConfigIo2

Input 2 config such as threshhold

ioMapping

Configuration for the IO block - this is a dictionary of IO components and what their inputs are configured to

ioMappingCombAnd

combinatorial block AND input (out = ((Or1 | Or2 | Or3) ^ XOr) & And)

ioMappingCombOr1

combinatorial block OR input 1 (out = ((Or1 | Or2 | Or3) ^ XOr) & And)

ioMappingCombOr2

combinatorial block OR input 2 (out = ((Or1 | Or2 | Or3) ^ XOr) & And)

ioMappingCombOr3

combinatorial block OR input 3 (out = ((Or1 | Or2 | Or3) ^ XOr) & And)

ioMappingCombXor

combinatorial block XOR input (out = ((Or1 | Or2 | Or3) ^ XOr) & And)

ioMappingDelay

delay block configuration

ioMappingIo1

output driver 1 configuration

ioMappingIo2

output driver 2 configuration

ioMappingShutter

Shutter (signal to timing block) configuration

ioMappingStartRec

Start recording (signal to record sequencer) configuration

ioMappingStopRec

Stop or end recording (signal to record sequencer) configuration

ioMappingToggleClear

Toggle block configuration (out = False on rising edge of input)

ioMappingToggleFlip

Toggle block configuration (out = not out on rising edge of input)

ioMappingToggleSet

Toggle block Set configuration (out = True on rising edge of input)

ioStatusSourceIo1

input 1 current value

ioStatusSourceIo2

input 2 current value

ioStatusSourceIo3

input 3 current value

minFramePeriod

int – The minimum frame period, in nanoseconds, at the current resolution settings.

networkHostname

str – hostname to be used for dhcp requests and to be displayed on the command line.

powerOnWhenMainsConnected

bool – Set to True to have the camera turn itself on when it is plugged in. The inverse of this, turning off when the charger is disconnected, is achieved by setting the camera to turn off at any battery percentage. For example, to make the camera turn off when it is unpowered and turn on when it is powered again - effectively only using the battery to finish saving - you could make the following call – api.set({ ‘powerOnWhenMainsConnected’:True, ‘saveAndPowerDownWhenLowBattery’:True, ‘saveAndPowerDownLowBatteryLevelPercent’:100.0 }).

recMaxFrames

int – A limit on the maximum number of frames for the recording sequencer to use.

recMode

str – Mode in which the recording sequencer stores frames into video memory.

Parameters:
  • 'normal' – Frames are saved continuously into a ring buffer of up to recMaxFrames in length until the recording is terminated by the recording end trigger.
  • 'segmented' – Up to recMaxFrames of video memory is divided into recSegments number of ring buffers. The camera saves video into one ring buffer at a time, switching to the next ring buffer at each recording trigger.
  • 'burst' – Frames are saved continuously as long as the recording trigger is active.
recPreBurst

int – The number of frames leading up to the trigger rising edge to save when in ‘burst’ recording mode.

recSegments

int – The number of segments used by the recording sequencer when in ‘segmented’ recording mode.

resolution

dict – Resolution geometry at which the image sensor should capture frames.

The optional hOffset and vOffset parameters allow the user to select where on the sensor to position the frame when operating at a cropped resolution. If not provided when setting, the camera will attempt to centre the cropped image on the image sensor.

When setting resolution, the minFrameTime may be optionally provided to allow the image sensor to better tune itself for the desired frame period. When omitted, it is assumed that the sensor will tune itself for its maximum framerate.

Parameters:
  • hRes (int) – Horizontal resolution of the catpured image, in pixels.
  • vRes (int) – Vertical resolution of the captured image, in pixels.
  • hOffset (int, optional) – Horizontal offset, in pixels, from the top left of the full frame at which the first pixel will be read out.
  • vOffset (int, optional) – Vertical offset, in pixels, from the top left of the full frame at which the first pixel will be read out.
  • vDark (int, optional) – The number of vertical dark rows to read out.
  • minFrameTime (float, optional) – The minimum frame time, in seconds, that the image sensor is capable of recording frames when at this resolution configuration.
saveAndPowerDownLowBatteryLevelNormalized

float – Equivalent to saveAndPowerDownLowBatteryLevelPercent, but based against batteryChargeNormalized which is always 1% of batteryChargePercent.

saveAndPowerDownLowBatteryLevelPercent

float – Turn off the camera if the battery charge level, reported by batteryChargePercent, falls below this level. The camera will start saving any recorded footage before it powers down. If this level is too low, the camera may run out of battery and stop before it finishes saving.

saveAndPowerDownWhenLowBattery

bool – Should the camera try to turn off gracefully when the battery is low? The low level is set by saveAndPowerDownLowBatteryLevelPercent (or saveAndPowerDownLowBatteryLevelNormalized). The opposite of powerOnWhenMainsConnected. See powerOnWhenMainsConnected for an example which sets the camera to turn on and off when external power is supplied.

sensorBitDepth

int – Number of bits per pixel sampled by the image sensor.

sensorColorPattern

str – String describing the color filter array pattern of the image sensor.

Example

A typical 2x2 Bayer pattern sensor would have a value of ‘GRBG’. Meanwhile, monochrome image sensors should have a value of ‘mono’.

sensorHIncrement

int – Minimum step size allowed, in pixels, for changes in the horizontal resolution of the image sensor.

sensorHMax

int – Maximum horizontal resolution, in pixels, of the active area of the image sensor.

sensorHMin

int – Minimum horizontal resolution, in pixels, of the active area of the image sensor.

sensorIso

int – ISO number of the image sensor with nominal (0dB) gain applied.

sensorMaxGain

int – Maximum gain of the image sensor as a linear muliplier of the sensorISO.

sensorName

str – Descriptive name of the image sensor.

sensorPixelRate

float – Maximum throughput of the image sensor in pixels per second.

sensorVDark

int – Maximum vertical resolution, in pixels, of the optical black regions of the sensor.

sensorVIncrement

int – Minimum step size allowed, in pixels, for changes in the vertical resolution of the image sensor.

sensorVMax

int – Maximum vertical resolution, in pixels, of the active area of the image sensor.

sensorVMin

int – Minimum vertical resolution, in pixels, of the active area of the image sensor.

setOnChange(handler)

Install an on-change handler to be called whenever properties are modified.

To report changes in state or configuration, properties with the notify attribute set will invoke a callback handler with the name of the property and its new value.

Parameters:handler (callable) – Callback method to invoke whenever a property is changed.
shutterAngle

float – The angle in degrees for which frames are being exposed relative to the frame time.

softReset(bitstream=None)

Reset the camera and initialize the FPGA and image sensor.

Parameters:bitstream (str, optional) – File path to the FPGA bitstream to load, or None to perform only a soft-reset of the FPGA.
Yields:float – The sleep time, in seconds, between steps of the reset procedure.

Examples

This function returns a generator iterator with the sleep time between steps of the reset procedure. The caller can perform a complete reset as follows:

>>> state = camera.softReset()
>>> for delay in state:
>>>    time.sleep(delay)
softTrigger()

Signal a soft trigger event to the recording sequencer.

startCalibration(blackCal=False, analogCal=False, zeroTimeBlackCal=False)

Begin one or more calibration procedures at the current settings.

Black calibration takes a sequence of images with the lens cap or shutter closed and averages them to find the black level of the image sensor. This value can then be subtracted during playback to correct for image offset defects.

Analog calibration consists of any automated image sensor calibration that can be performed quickly and autonomously without any setup from the user (eg: no closing of the aperture or calibration jigs).

Parameters:
  • blackCal (bool, optional) – Perform a full black calibration assuming the user has closed the aperture or lens cap. (default: false)
  • analogCal (bool, optional) – Perform autonomous analog calibration of the image sensor. (default: false)
  • zeroTimeBlackCal (bool, optional) – Perform a fast black calibration by reducing the exposure time and aperture to their minimum values. (default: false)
Yields:

float – The sleep time, in seconds, between steps of the calibration procedure.

Example

This function returns a generator iterator with the sleep time between steps of the calibration procedures. The caller may use this for cooperative multithreading, or can complete the calibration sychronously as follows:

>>> state = camera.startCalibration(blackCal=True)
>>> for delay in state:
>>>    time.sleep(delay)
startCustomRecording(program)

Program the recording sequencer and start recording.

This variant of startRecording takes a recording program as a list of seqprogram classes describing the steps for the recording sequencer to takes as frames are acquired from the image sensor.

Parameters:program (list of seqprogram) – List of recording sequencer commands to executed for this recording.
Yields:float – The sleep time, in seconds, between steps of the recording program.

Example

This function returns a generator iterator with the sleep time between the steps of the recording procedure. The caller may use this for cooperative multithreading, or can complete the calibration sychronously as follows:

>>> state = camera.startRecording()
>>> for delay in state:
>>>    time.sleep(delay)
startRecording(mode=None)

Program the recording sequencer and start recording.

Parameters:mode (str, optional) – One of ‘normal’, ‘segmented’ or ‘burst’ to override the current recMode property when starting the recording.
Yields:float – The sleep time, in seconds, between steps of the recording.

Example

This function returns a generator iterator with the sleep time between the steps of the recording procedure. The caller may use this for cooperative multithreading, or can complete the calibration sychronously as follows:

>>> state = camera.startRecording()
>>> for delay in state:
>>>     time.sleep(delay)
startWhiteBalance(hStart=None, vStart=None)

Begin the white balance procedure.

Take a white reference sample from the live video stream, and compute the white balance coefficients for the current lighting conditions.

Parameters:
  • hStart (int, optional) – Horizontal position at which the white reference should be taken.
  • vStart (int, optional) – Veritcal position at which the white reference should be taken.
Yields:

float – The sleep time, in seconds, between steps of the white balance procedure.

Example

This function returns a generator iterator with the sleep time between the steps of the white balance procedure. The caller may use this for cooperative multithreading, or can complete the calibration sychronously as follows:

>>> state = camera.startWhiteBalance()
>>> for delay in state:
>>>     time.sleep(delay)
state

str – The current operating state of the camera.

Parameters:
  • 'idle' – The camera is powered up and operating, but not doing anything.
  • 'reset – The camera is in the process of resetting the FPGA and image sensor.
  • 'blackCal' – The camera is currently calibrating using a dark reference image.
  • 'analogCal' – The camera is currently performing analog calibration of the image sensor.
  • 'recording' – The camera is running a recording program to save images into video memory.
stopRecording()

Terminate a recording if one is in progress.

wbCustom

list(float) – The Red, Green and Blue gain coefficients last computed by startWhiteBalance().

wbMatrix

list(float) – The Red, Green and Blue gain coefficients to achieve white balance.