STATE Variables

STATE Variables

The following table lists the so-called STATE variables implemented in the ApBase library, DevWare, and related software. STATE variables control the operation of the software, mainly the image processing. STATE variables can be set by commands or Python statements in initialization files, and by various APIs supported by the software such as the ApBase API, the DevWare COM interface, and the DevWare plug-in interface. The data type of a variable is either integer or string. (Non-integer numbers are string-valued for the purposes of the APIs.) Most variables have a corresponding control on the DevWare user interface (UI).

The ini file command to set a STATE variable is STATE= variable [(0 | 1)], value. The value is interpreted as an integer or a string according to the name of the variable.
"[(0 | 1)]" is the optional parameter for those STATE variables that on duplicated per-context; see below under "per-Context variables".

The Python functions to get and set STATE variables are apbase.getstate( variable ), and apbase.setstate( variable , value ). The return value from getstate() will be an integer or a string according to the specific variable. The data type of the value passed to setstate() must be int or str according to the variable.

It is possible to set a variable with a name of your choosing. The software will store the value, which can be retrieved later. This is useful with software extensions such as DevWare plug-ins and user-defined toolbars. For example, parameter values used by a plug-in could be set in ini files like native DevWare settings. The STATE= ini command will always create a string-valued variable if the variable is not yet defined. The Python setstate() function can create either a integer-valued or string-valued variable depending on the data type of the value parameter.

Note on per-Context variables; some ColorPipe variables are duplicated per-context - those are noted by "Duplicated per-context." in their description.
Their value can optionally be set per-context only via an INI file version; the format is STATE =  variable (0 | 1), value.
For Python functions and through ApBase, the STATE value is set per the sensor's currently active context.



2 Floating-point values

STATE Variable Name, Description

Value

STATE Variable Name, Description

Value

Display Zoom Percent
Corresponds to Zoom In/Out buttons on the DevWare toolbar. Value is zoom factor * 100. The following settings are special cases: 12 will be 12.5% (1/8 exactly), 6 will be 6.25% (1/16 exactly) and 3 will be 3.125% (1/32 exactly).

3 to 1600 (default = 100)

Reset Image Fifo
Reset the image FIFOs on the demo board.

 0 or 1

Filter
Corresponds to Filter selection on the Data Interpretation page.

Note that the value(s) presented on the Data Interpretation page change depending on the output format in use. For example, Bayer as compared to YCBCR as compared to SuperCell - all will have a different list of possible Filter choices.
This in turn changes the corresponding value for the "Filter" state.

The method of determining the state value is to use DevWare to set the output format that you're using, and then go to the "Data Interpretation" dialog in the "Control" dialog.
Starting at 0, count down until you find the filter that you want to apply.

For example, if your output format is Bayer, selecting a Filter state of "Bayer Grayscale" would be 3.

Note; the set of Filters can be set via the "CFA Pattern" STATE command, listed below.

0 to n

Subimage
Which subimage to display if there are more than one. 0 means main image, 1 means post-view image, 2 means thumbnail image.

0, 1 or 2

Current Subimage
Returns subimage is being displayed if there are more than one. 0 means main image, 1 means post-view image, 2 means thumbnail image.

0, 1 or 2

Subimage Merge
Whether to inset the subimage in the main image.

0 or 1

X Offset
Sets the Bayer pattern horizontal offset. 0 means first column is G1/B, 1 means R/G2. Corresponds to Horizontal skip checkmark on the Data Interpretation page.

0 or 1

Y Offset
Sets the Bayer pattern vertical offset. 0 means first row is G1/R, 1 means B/G2. Corresponds to Vertical skip checkmark on the Data Interpretation page.

0 or 1

Auto Offset
Set X Offset and Y Offset automatically. Corresponds to Automatic checkmark on the Data Interpretation page.

0 or 1

Gb-B Swap
Swap Gb and B pixels in a Bayer image.

0 or 1

Byte Swap
Swap adjacent bytes in the input image.

0 or 1

True Black Enable
Enable black level (a.k.a. pedestal) subtraction from raw Bayer data. Corresponds to Subtract True Black controls on the Data Interpretation page.

0 , 1 , or 2 (automatic)

True Black Level
Black level, as a fraction of the True Black Scale. Normally loaded automatically from sensor registers. Corresponds to True Black value on the Data Interpretation page.

Integer

True Black Scale
Usually either 1024 or 4096, indicates whether True Black Level is expressed as a 10-bit or 12-bit value.

Integer

Active True Black
Black level scaled to the decompressed image depth.

Integer

ALTM Enable
Enable Adaptive Local Tone Mapping algorithm. This intelligently reduces an HDR image of 16 bits or more to 12 bits for the software color pipeline.

Note; use "HDR" version of STATE variables when ALTM is enabled. For example, "HDR Black Correct" instead of "Black Correct".

Duplicated per-context.

0 or 1

ALTM Min Percent
Minimum percentile.

Duplicated per-context.

double float

ALTM Peak Percent
Maximum percentile.

Duplicated per-context.

double float

ALTM Sharp S
Sharpening strength.

Duplicated per-context.

double float

ALTM Lo Gamma
Low light region Gamma.

Duplicated per-context.

double float

ALTM Hi Gamma
High light region Gamma.

Duplicated per-context.

double float

ALTM Min Factor
Minimum factor.

Duplicated per-context.

double float

ALTM Dark Floor
Minimum dark factor.

Duplicated per-context.

Integer

ALTM Smooth Level
Normally less than 1.0.

Duplicated per-context.

double float

BitDepth Decomp
The decompressed image depth.

Integer

Compress
Image data compression, usually of mono or Bayer data. 0 means no compression, 1 means MIPI compression with simple predictor, 2 means a-Law, 3 means companding, 4 means MIPI compression with advanced predictor, 5 means MIPI packing.

0 to 5

Companding
Set the custom companding table.  Provide a string with the required format and appropriate values;

Bits_in [in_knee_point_1 in_knee_point_2 in_knee_point_n] Bits_out [out_knee_point_1 out_knee_point_2 out_knee_point_n]

  • Bits_out maximum is 24.

  • Max number of knee points is 16.

  • Knee points must be increasing in value.

  • Number of Knee points must be the same for Bits_in and Bits_out.

  • In cases where the original depth is shifted (e.g. 20->16), account for this by shifting the knee point values.

  • Use the STATE command "Compress, 3" to enable companding.

Issuing the STATE command with no data will reset/disable the custom companding table.

Example: STATE = Companding, 12 [2048 3040 4000] 20 [2048 65536 1048576]

string

Deinterlace Mode
Sets de-interlacing method when displaying the output from an interlaced sensor. 0 means don't de-interlace, 1 means top field comes out first, 2 means bottom field comes out first, 3 means automatically determine appropriate mode. Corresponds to De-Interlacing controls on the Data Interpretation page.

0, 1, 2 or 3

Descramble Mode
Descramble imager data from AR1011, AR1411.

0 or 1

Special Pixel Mode
Remove special pixels from image for AR1011, AR1411.

0 or 1

Trigger Width
Set the trigger width for AR1011, AR1411.

Integer

Active Area Crop
Crop dark rows and columns on AR1011, AR1411.

0 or 1

AI Repack
Arrange image data in to grid of images for array imagers.

0 or 1

Auto Luma Range
Enable automatic determination of the range of Y values in the YCbCr output of the sensor. Corresponds to the Automatic checkmark under Luma Range on the Data Interpretation page.

0 or 1

Luma Lo
Value to use as the black Y value when automatic luma range is off. Corresponds to the Black value on the Data Interpretation Page.

0 to 255

Luma Hi
Value to use as the white Y value when automatic luma range is off. Corresponds to the White value on the Data Interpretation Page.

0 to 255

Dynamic Range LSB
The least significant bit of the input data to use when limiting the dynamic range used in the image processing.

Integer

Dynamic Range MSB
The most significant bit of the input data to use when limiting the dynamic range used in the image processing.

Integer

Unswizzle Mode
Sets the unswizzling operation to be performed on the data coming from the demo board. Swizzling refers to rearrangement of the data bits on most headboards. 0 means no unswizzling, 1 means unswizzle on the camera if possible, 2 means unswizzle in software on the host, and 3 means set the best mode automatically. Corresponds to the Bayer Bit-Unswizzling controls on the Data Interpretation page.

0, 1, 2 or 3

Orientation
Re-orient the output image. 0 means do nothing, 1 means horizontal mirror, 2 means vertical flip, 3 means rotate 180°.

0, 1, 2 or 3

Output Channel
Strip all but the specified color channel from the final RGB image so the user can see the red, green or blue channels in isolation. 0 means show all channels (normal mode), 1 means show red only, 2 means show green only, 3 means show blue only. Corresponds to Display Color Channel control on Data Interpretation page.

0, 1, 2 or 3

Output BwColor
Convert the final RGB image to black & white. Useful when used in conjunction with the Output Channel feature. 0 means color, 1 means black & white. Corresponds to the control on the Data Interpretation page.

0 or 1

Color Correction
Enable color correction and gamma correction for Bayer data. This must be enabled for White Balance to work. Corresponds to the Color Correction and White Balance check on the SW Color Correction page.

Duplicated per-context.

0 or 1

Gamma Correction
Gamma correction value for Bayer data * 100. 45 means 0.45. Corresponds to Gamma control on SW Color Correction page.
Note; when ALTM is enabled, "Gamma Correction" is ignored - use "HDR Gamma Correction" instead.



Duplicated per-context.

1 to 125 (default = 45)

Black Correct
Sets a black correction amount, for Bayer data, that darkens the blacks in the image for a better appearance. Corresponds to Black Correction control on SW Color Correction page.
Note; when ALTM is enabled, "Black Correct" is ignored - use "HDR Black Correct" instead.


Duplicated per-context.

0 to 20

Gamma Table Reset
Reset the custom gamma table.

1

Gamma Table Select
Select the custom gamma table or the gamma table generated from Gamma Correction and Black Correct settings. Setting this to 1 selects the custom table, so Gamma Correction and Black Correct have no effect.

0 or 1

Gamma Table
Add or change an entry in the custom gamma table. The parameters are two integers, the input value and output value.

Input output

Contrast
Sets contrast enhancement factor for Bayer data * 20. A factor of 1.0 (contrast = 20) means no enhancement. 25 means a factor of 1.25. Corresponds to Contrast control on SW Color Correction page.

Note; when ALTM is enabled, "Contrast" is ignored - use "HDR Contrast" instead.

20 to 40 (default = 25)

Saturation
Set saturation enhancement factor for Bayer data * 10. A factor of 1.0 (saturation = 10) means no saturation boost. 0 means black & white image. Corresponds to Saturation Correction control on SW Color Correction page.

Duplicated per-context.

0 to 20

Aperture Enable
Enable software aperture correction (sharpening) on Bayer data. Corresponds to Aperture Correction checkmark on SW Color Correction page.

Duplicated per-context.

0 or 1

Aperture
Set aperture correction (sharpening) amount for Bayer data. Corresponds to Aperture Correction slider on SW Color Correction page.

Duplicated per-context.

-4 to 16

All HW Gain
Returns a list of all gain values supported by the device. Useful for gain sweeps.

String (read-only)

All Global Gain
Returns a list of all gain values supported by the device. Useful for gain sweeps.

String (read-only)

Software Gain
Gain applied to Bayer data * 1000. Corresponds to Software Gain control on Exposure page.

1000 to 100000 (default = 1000)

Minimum Global Gain
Limit analog gain.  Gain * 1000.  Corresponds to Analog Gain control on Exposure page.

Default = 1000

Show Min Gain As 1 
Show minimum recommended gain as 1.0. This will change the gain values shown below to be relative to the recommended minimum gain.

0 or 1

Gain Table Reset
Reset the custom gain table.

1

Gain Table Select
Select the custom gain table tuning registers defined by the "Gain Table" STATE setting. Setting this to 1 selects the custom table.

0 or 1

Gain Table 
Set tuning registers for the gain and the gain register, and optionally up to 12 tuning addresses and tuning data values.
You can only set whole registers with that table (not bitfields).

"gain" = double float
All others are integers

Master Clock
Inform DevWare of the sensor's pixel array clock frequency, in Hz. Setting this variable does not change the actual clock. This value must be set correctly for the frame rate computations, exposure controls and software auto exposure features to work properly. Normally DevWare can detect the clock rate automatically via the DEMO2 board. Corresponds to the Sensor Array Clock Speed value on the Options dialog.

Integer

Detect Master Clock
Set to 1 to trigger DevWare to re-detect the sensor array clock frequency, it returns to 0 by itself after the detection. The detection won't work if the sensor is not putting out images, so you may want to set this trigger at the end of the [Demo Initialization] section of an INI file if the sensor was brought out of a standby or non-streaming state. Corresponds to the Detect button on the Options dialog.

1

Pixel Clock Polarity
Specify which edge of PIXCLK to sample the data. Corresponds to PIXEL_CLOCK_POLARITY setting from the sensor data (.xsdat or .sdat) file No UI.

0 (falling) or 1 (rising)

Pixel Clock
Get and Set the Pixel Out clock, in Hz.

Integer

Input Clock
Get and Set the Input clock, in Hz.  Corresponds to the XMCLK value in the baseboard (Demo2X or Demo3) value in Sensor Control / Diagnostics.

Integer

Die Temperature
Get the temperature value; only applies to sensors that have that feature.

String (read-only)

Die Temperature Calib
Get the temperature calibration status; 0 or 1 (fail / pass).

String (read-only)

Auto Exposure
Enable software auto exposure algorithm used for Bayer sensors that don't have built-in AE. The following variables control the software AE. This variable corresponds to the Auto Exposure check marks on the Exposure and Auto Exposure pages.

0 or 1

Auto Exposure Target
Relative image brightness that auto exposure should "aim for." When auto exposure is on, this is a brightness control. Corresponds to Target control on Auto Exposure page.

1 to 100 (default = 50)

Auto Exposure Stability
Hysteresis window around Target. Corresponds to Stability control on Auto Exposure page.

0 to 40 (default = 5)

Auto Exposure Speed
Sets how long it should take, in 1/10ths of seconds, for the AE to settle. 30 means three seconds. No UI.

Default = 30

Auto Exposure Minimum FPS
Reciprocal of maximum exposure time. 0 means allow any exposure time up to the maximum supported by the sensor. Corresponds to Exposure Limit control on Auto Exposure page.

0 to 30

Auto Exposure Flicker Filter
Enable anti-flicker in AE and set frequency. 0 means off. 60 means constrain exposure time to multiples of 1/120 second. 50 means constrain exposure time to multiples of 1/100 second. Corresponds to Flicker Filter control on Auto Exposure page.

0, 50 or 60

Auto Exposure Soft Limit
Try to keep exposure time below 1/softlimit (or frame readout time, whichever is greater) unless doing so would require more than Soft Gain Limit gain. No UI.

Integer (default = 33)

Auto Exposure Soft Gain Limit
Maximum gain AE should use before slowing down the frame rate * 10. Corresponds to Soft Gain Limit control on Auto Exposure page.

10 to 100 (default = 40)

Auto Exposure Software Gain Limit
Set the maximum allowed software gain that the AE will use * 10. Default is 100. Corresponds to Software Gain Limit control on Auto Exposure page.

10 to 150 (default = 100)

Auto Exposure Gain Limit
Set the maximum per-channel hardware gain that AE will use * 10. Non-HDR modes.

integer

Auto Exposure Minimum Gain
Set the minimum per-channel hardware gain that AE will use * 10. Non-HDR modes.

integer

Auto Exposure Minimum Global Gain
Set the minimum global hardware gain that the AE will use * 10. Non-HDR modes.

integer (usually default = 10, meaning 1.0X gain)

Auto Exposure Global Gain Limit
Set the maximum global hardware gain that the AE will use * 10. Non-HDR modes.

integer

Auto Exposure Gain Limit HDR
Set the maximum per-channel hardware gain that AE will use * 10. HDR modes.

integer

Auto Exposure Minimum Gain HDR
Set the minimum per-channel hardware gain that AE will use * 10. HDR modes.

integer

Auto Exposure Minimum Global Gain HDR
Set the minimum global hardware gain that the AE will use * 10. HDR modes.

integer

Auto Exposure Global Gain Limit HDR
Set the maximum global hardware gain that the AE will use * 10. HDR modes.

integer

Auto Exposure Post HDR Gain Limit
Set the the post-HDR gain limit variable that the AE will use * 10. HDR modes.

integer

Auto Exposure Freeze Gains
1 means AE will not change the analog gains. 0 means it may. Corresponds to Freeze Gains checkmark on Exposure page.

0 or 1

Auto Exposure Fade Saturation
Automatically reduce saturation in high gain situation to reduce appearance of image noise. Corresponds to Fade Saturation checkmark on Auto Exposure page.

0 or 1

Auto Exposure Fade Aperture
Automatically reduce sharpening in high gain situation to reduce appearance of image noise. Corresponds to Fade Aperture Correction checkmark on Auto Exposure page.

0 or 1

Auto Exposure Fade Target
Automatically reduce brightness target in high gain situation to prevent excessive gain. Corresponds to Fade Exposure Target checkmark on Auto Exposure page.