Sensor API Class¶
-
class
pychronos.sensors.
api
¶ Abstract class defining the API to an image sensor.
-
baseIso
¶ int – The ISO number of the image sensor at normal (0dB) gain.
-
cfaPattern
¶ str – String describing the color filter array pattern, or None for monochrome sensors.
-
getColorMatrix
(cTempK=5500)¶ Return the color correction matrix for this image sensor.
A color matrix is required to convert the image sensor’s bayer filter data into sRGB color space. If the image sensor is characterized under multiple lighting conditions, the matrix which best matches the provided color temperature should be returned.
Parameters: cTempK (int, optional) – The color temperature (degrees Kelvin) of the CIE D-series illuminant under which the color matrix will be used (default 5500K). Returns: - The matrix coefficients for the 3x3 matrix converting the camera
- color space into sRGB. The matrix coefficients are stored in row-scan order.
Return type: List[float]
-
getCurrentExposure
()¶ Return the current image sensor exposure time.
Returns: The current exposure time in seconds. Return type: float
-
getCurrentGain
(gain)¶ Return the current analog gain of the image sensor
-
getCurrentGeometry
()¶ Return the current frame size of the image sensor
Returns: frameGeometry
-
getCurrentPeriod
()¶ Return the current frame period of the image sensor.
Returns: Current frame period in seconds Return type: float
-
getExposureRange
(fSize, fPeriod)¶ Return a tuple with the minimum and maximum exposure at a given frame size
Parameters: - fSize (
frameGeometry
) – The frame size at which the exposure range is being requested. - fPeriod (float) – The frame period for which the exposure range is being requested.
Returns: - A tuple of (min, max) exposure periods in seconds, or zero to
indicate that te exposure period is not limited.
Return type: (float, float)
Raises: ValueError
– If fSize is not a valid resolution for the image sensor.- fSize (
-
getMaxGeometry
()¶ Return the maximum frame geometry supported by the image sensor
Returns: frameGeometry
-
getPeriodRange
(fSize)¶ Return a tuple with the minimum and maximum frame periods at a given frame size
Parameters: fSize ( frameGeometry
) – The frame size for which the frame period limits are being requested.Returns: - A tuple of (min, max) frame periods in seconds, or zero to
- indicate that the frame period is not limited.
Return type: (float, float) Raises: ValueError
– If fSize is not a valid resolution for the image sensor.
-
getSupportedExposurePrograms
()¶ Return a tuple of the supported exposure programs.
-
getWhiteBalance
(cTempK=5500)¶ Return the white balance matrix for this image sensor.
A white balance is required to equalize the sensitivity of each channel of the bayer filter data to achieve white. If the image sensor is characterized under multiple lighting conditions, the white balance which best matches the provided color temperature should be returned.
Parameters: cTempK (int, optional) – The color temperature (degrees Kelvin) of the CIE D-series illuminant under which the white balance will be used (default 5500K). Returns: - An array containing the gains for the Red, Green and Blue channels
- to achieve white balance at the desired lighting temperature.
Return type: List[float]
-
hIncrement
¶ int – The minimum step size, in pixels, for changes in horizontal resolution
-
hMin
¶ int – The minimum horizontal resolution, in pixels, of the image sensor
-
isValidResolution
(fSize)¶ Test if the provided geometry is supported by the iamge sensor.
Parameters: fSize ( frameGeometry
) – The resolution to test for support.Returns: True if fSize is a supported resolution, and False otherwise. Return type: bool
-
loadAnalogCal
()¶ Load stored analog calibration data from a file, if supported
-
maxGain
¶ int – The maximum gain supported by the sensor as a multiplier of baseIso.
-
name
¶ str – The name of the image sensor.
-
reset
(fSize=None)¶ Perform a reset of the image sensor and bring it into normal operation.
This function may be called either to initialzie the image sensor, or to restart it if the sensor is already running. After a reset, the expected state of the image sensor is to be operating at full-frame resolution, the maximum framerate, nominal (0dB) gain and a 180-degree shutter angle.
This function returns no value, but may throw an exception if the initialization procedure failed.
Parameters: fSize ( frameGeometry
, optional) – The initial video geometry to set after initializing the image sensor, or use the maximum active video by default.
-
saveAnalogCal
()¶ Write analog calibration data from a file, if supported
-
setExposureProgram
(expPeriod)¶ Configure the sensor to operate in normal exposure mode.
When in normal exposure mode, the image sensor is free running and will capture frames continuously with the desired exposure period. This function may be called to enter the standard exposure program or to update the exposure time.
This function is mandatory for all image sensors.
Parameters: expPeriod (float) – The exposure time of each frame, in seconds.
-
setFramePeriod
(fPeriod)¶ Configure the frame minimum period of the image sensor
Parameters: fPeriod (float) – The frame period to configure on the image sensor. Raises: ValueError
– If fPeriod is not a valid frame period at the current resolution.
-
setFrameTriggerProgram
(expPeriod, numFrames=1)¶ Configure the sensor to operate in frame trigger mode.
When in frame trigger mode, the image sensor is inactive until a rising edge of the frame trigger is detected, after which the image sensor will capture a fixed number of frames and then return to an idle state until the next rising edge is detected.
Parameters: - expPeriod (float) – The exposure time of each frame, in seconds.
- numFrames (int, optional) – The number of frames to acquire after each risng edge (default: 1)
Raises: ValueError
– If expPeriod is not a valid exposure time at the current resolution.NotImplementedError
– If frame trigger mode is not supported by the image sensor.
-
setGain
(gain)¶ Configure the analog gain of the image sensor
-
setHdrExposureProgram
(expPeriod, numIntegration=2)¶ Configure the sensor to operate in high dynamic range mode
When in high dynamic range mode, the image sensor combines multiple integration periods to achieve a non-linear response to incoming sensitivities.
Parameters: - expPeriod (float) – The total exposure time of each frame, in seconds.
- numIntegrations (int, optional) – The number of integration periods to apply for HDR mode. (default: 2)
Raises: ValueError
– If expPeriod is not a valid exposure time at the current resolution.ValueError
– If numIntegration is not supported by the image sensor.NotImplementedError
– If high dynamic range mode is not supported by the image sensor.
-
setResolution
(fSize)¶ Configure the resolution and frame geometry of the image sensor.
Parameters: fSize ( frameGeometry
) – Frame size and geometry to configure.Raises: ValueError
– If fSize is not a valid resolution for the image sensor.
-
setShutterGatingProgram
()¶ Configure the sensor to operate in shutter gating mode.
When in shutter gating mode, the image sensor is inactive until the trigger signal is asserted. Once asserted the exposure duration is controlled by the active period of the trigger signal. Frame readout begins on the falling edge of the trigger signal, after which the sensor becomes idle again until the next rising edge of the trigger.
Raises: NotImplementedError
– If shutter gating is not supported by the image sensor.
-
startAnalogCal
()¶ Perform the automatic analog sensor calibration at the current settings.
Any analog calibration that the sensor can perform without requiring any extern user setup, such as covering the lens cap or attaching calibration jigs, should be performed by this call.
Yields: float – The sleep time, in seconds, between steps of the calibration procedure. Examples
This function returns a generator iterator with the sleep time between the steps of the analog calibration procedure. The caller may use this for cooperative multithreading, or can complete the calibration sychronously as follows:
>>> for delay in sensor.startAnalogCal(): >>> time.sleep(delay)
-
vIncrement
¶ int – The minimum step size, in pixels, for changes in vertical resolution
-
vMin
¶ int – The minimum vertical resolution, in pixels, of the image sensor
-
Frame Geometry Class¶
-
class
pychronos.sensors.
frameGeometry
(hRes, vRes, hOffset=0, vOffset=0, vDarkRows=0, bitDepth=12, minFrameTime=None)¶ Container to express the geometry of images recorded from an image sensor.
-
hRes
¶ int – Horizontal resolution, in pixels, of the recorded image.
-
vRes
¶ int – Vertical resolution, in pixels, of the recorded image.
-
hOffset
¶ int – Horizontal offset from the top left of the sensor to the first recorded pixel.
-
vOffset
¶ int – Vertical offset from the top left of the sensor to the first recorded pixel.
-
vDarkRows
¶ int – Number of optical dark rows to be recorded and appended to the top of the image.
-
bitDepth
¶ int – Number of bits recorded per pixel from the image sensor.
-
minFrameTime
¶ float – Minimum time recording time per frame at this resolution settings.
-
pixels
()¶ Compute the number of pixels in a recorded image.
Returns: Number of pixels in the image. Return type: int
-
size
()¶ Compute the size in bytes of a recorded image.
Returns: Size of bytes of a recorded image. Return type: int
-