Skip to content

senxor

senxor

Top-level package for Senxor devices.

Senxor(interface, *, auto_open=True)

Bases: SenxorHelperMixin, Generic[TDevice]

Parameters:

Name Type Description Default

interface

TInterface

The interface of the senxor.

required

auto_open

bool

Whether to open the senxor automatically, by default True.

True

device property

Get the device instance.

name property

Get the name of the device.

is_streaming property

Whether the senxor is in the stream mode.

is_connected property

Whether the senxor is connected.

get_shape()

Get the frame shape(height, width) of the senxor.

Returns:

Type Description
tuple[int, int]

The frame shape(height, width) of the senxor.

disable_all_filters()

Disable all filters inside the senxor.

This method will set the following filters to disabled:

  • STARK
  • MMS KXMS
  • MMS RA
  • Median
  • Temporal

See related fields .help attribute to get more information about the filters.

get_filters_status()

Get the status of all filters.

Returns:

Type Description
dict[str, bool]

The status of all filters. Available keys:

  • stark
  • mms_kxms
  • mms_ra
  • median
  • temporal

The value is True if the filter is available in current device and enabled.

get_fw_version()

Get the firmware version string.

The firmware version is a string of the format "major.minor.build".

Returns:

Type Description
str

The firmware version string.

Examples:

>>> senxor.get_fw_version()
"4.5.12"

get_frame_rate_divider()

Get the frame rate divider.

The frame rate divider is determined by the FRAME_RATE_DIVIDER field.

The frame rate is calculated as: frame_rate = FPS_MAX / FRAME_RATE_DIVIDER. When FRAME_RATE_DIVIDER is 0, the maximum frame rate (FPS_MAX) is used.

Note: The actual maximum frame rate depends on device performance and is typically around 30 fps. Due to variations in frame transmission, avoid using this calculated value for precise frame rate measurement. Instead, calculate the actual frame rate from the timestamps of received frames.

Returns:

Type Description
int

The frame rate divider.

set_frame_rate_divider(divider)

Set the frame rate divider.

The frame rate divider is determined by the FRAME_RATE_DIVIDER field. The frame rate is calculated as: frame_rate = FPS_MAX / FRAME_RATE_DIVIDER. When FRAME_RATE_DIVIDER is 0, the maximum frame rate (FPS_MAX) is used.

Note: The actual maximum frame rate depends on device performance and is typically around 30 fps.

Parameters:

Name Type Description Default
divider
int

The frame rate divider to set.

required

get_module_gain()

Get the module gain setting.

The module gain defines the common amplification of the signal generated by each pixel in the SenXor array. Increased amplification improves signal to noise ratio but limits the range of scene temperatures that can be reported.

Returns:

Type Description
str

The module gain setting as a string. Possible values:

  • "1.0" (default, maximum gain)
  • "auto" (automatic gain selection: 1.0, 0.5, or 0.25 based on input signal)
  • "0.25" (quarter gain)
  • "0.5" (half gain)

set_module_gain(gain)

Set the module gain setting.

Parameters:

Name Type Description Default
gain
int

The module gain setting as an integer. Possible values:

  • 0: 1.0 (default, maximum gain)
  • 1: auto (automatic gain selection: 1.0, 0.5, or 0.25 based on input signal)
  • 2: 0.25 (quarter gain)
  • 3: 0.5 (half gain)
required

get_senxor_type()

Get the senxor type.

Returns:

Type Description
str

The senxor type.

get_module_type()

Get the module type.

Returns:

Type Description
str

The module type.

get_mcu_type()

Get the MCU type.

Returns:

Type Description
str

The MCU type.

get_production_year()

Get the production year.

Returns:

Type Description
int

The production year.

get_production_week()

Get the production week.

Returns:

Type Description
int

The production week.

get_manuf_location()

Get the manufacturing location.

Returns:

Type Description
int

The manufacturing location.

get_serial_number()

Get the serial number.

Returns:

Type Description
int

The serial number as an integer.

get_sn()

Get the SN code string in hex format.

The SN code is a hex string of 12 characters, the format is: YYWWLLSSSSSS, where:

  • YY is the production year (from 2000 to 2099).
  • WW is the production week.
  • LL is the manufacturing location.
  • SSSSSS is the serial number (from 000000 to 999999).

Returns:

Type Description
str

The SN code string in hex format.

get_module_name()

Get the module name.

Returns:

Type Description
str

The module name. Possible values:

  • "Cougar" (62x80)
  • "Panther" (120x160)
  • "Cheetah" (50x50)

get_sensitivity()

Get the sensitivity.

Multiplicative factor applied to the temperature readout of every pixel, allowing correction of the sensitivity.

Returns:

Type Description
float

The sensitivity.

set_sensitivity(value)

Set the sensitivity.

Multiplicative factor applied to the temperature readout of every pixel, allowing correction of the sensitivity.

Parameters:

Name Type Description Default
value
float

The sensitivity to set.

required

get_emissivity()

Get the emissivity.

Emissivity value (percent) to be used in the conversion of raw data captured from SenXor to the temperature data that is readout through the SPI interface. The reset value reflects the emissivity of the black body source used for factory calibration of the camera module. If the target object is known to have a different emissivity, programming the correct value will lead to an accurate readout of the absolute temperature.

Returns:

Type Description
float

The emissivity.

set_emissivity(value)

Set the emissivity.

Emissivity value (percent) to be used in the conversion of raw data captured from SenXor to the temperature data that is readout through the SPI interface. The reset value reflects the emissivity of the black body source used for factory calibration of the camera module. If the target object is known to have a different emissivity, programming the correct value will lead to an accurate readout of the absolute temperature.

Parameters:

Name Type Description Default
value
float

The emissivity to set.

required

get_offset()

Get the offset correction.

Temperature offset correction. This specifies a temperature offset applied to every pixel in the data frame.

Units: K(or °C) Range: -12.8 K to +12.7 K

Returns:

Type Description
float

The offset correction.

set_offset(value)

Set the offset correction.

Temperature offset correction. This specifies a temperature offset applied to every pixel in the data frame.

Units: K(or °C) Range: -12.8 K to +12.7 K

Parameters:

Name Type Description Default
value
float

The offset correction to set.

required

get_otf()

Get the OTF.

A multiplicative factor applied to each pixel's value before the frame is output. This is used to correct for size-of-source optical phenomena.

Resolution: 0.01 Range: -1.28 to +1.27

Returns:

Type Description
float

The OTF.

set_otf(value)

Set the OTF.

A multiplicative factor applied to each pixel's value before the frame is output. This is used to correct for size-of-source optical phenomena.

Resolution: 0.01 Range: -1.28 to +1.27

Parameters:

Name Type Description Default
value
float

The OTF to set.

required

get_stark_enable()

Get the STARK enable flag.

Returns:

Type Description
bool

Whether the STARK filter is available in current device and enabled.

set_stark_enable(enabled)

Set the STARK enable flag.

Parameters:

Name Type Description Default
enabled
bool

The STARK enable flag to set.

required

get_mms_kxms_enable()

Get the MMS KXMS enable flag.

Returns:

Type Description
bool

Whether the MMS KXMS filter is available in current device and enabled.

set_mms_kxms_enable(enabled)

Set the MMS KXMS enable flag.

Parameters:

Name Type Description Default
enabled
bool

The MMS KXMS enable flag to set.

required

get_mms_ra_enable()

Get the MMS RA enable flag.

Returns:

Type Description
bool

Whether the MMS RA filter is available in current device and enabled.

set_mms_ra_enable(enabled)

Set the MMS RA enable flag.

Parameters:

Name Type Description Default
enabled
bool

The MMS RA enable flag to set.

required

get_median_enable()

Get the median enable flag.

Returns:

Type Description
bool

Whether the median filter is available in current device and enabled.

set_median_enable(enabled)

Set the median enable flag.

Parameters:

Name Type Description Default
enabled
bool

The median enable flag to set.

required

get_temporal_enable()

Get the temporal enable flag.

Returns:

Type Description
bool

Whether the temporal filter is available in current device and enabled.

set_temporal_enable(enabled)

Set the temporal enable flag.

Parameters:

Name Type Description Default
enabled
bool

The temporal enable flag to set.

required

get_adc_enabled()

Whether the raw ADC data is enabled.

This flag is determined by the ADC_ENABLE field. When it is 1, the read method will return the raw ADC data.

Returns:

Type Description
bool

Whether the raw ADC data is enabled.

set_adc_enabled(enabled)

Set the raw ADC data enabled flag.

If the raw ADC data is enabled, the read method will return the raw ADC data. If you are not sure whether you need to use the raw ADC data, do not modify this value.

Parameters:

Name Type Description Default
enabled
bool

Whether to enable the raw ADC data.

required

open()

Open the senxor. If the senxor is already connected, do nothing.

close()

Close the senxor. If the senxor is not connected, do nothing.

on(event, listener)

on(event: Literal['open', 'close'], listener: Callable[[], None]) -> Callable[[], None]
on(
    event: Literal["error"], listener: Callable[[Exception], None]
) -> Callable[[], None]
on(
    event: Literal["data"], listener: Callable[[np.ndarray | None, np.ndarray], None]
) -> Callable[[], None]

Register a listener for an event.

Parameters:

Name Type Description Default
event
Literal['open', 'close', 'data', 'error']

The event to register the listener for.

required
listener
Callable

The listener to register.

required

Returns:

Type Description
Callable[[], None]

The function to clear the listener.

Notes

Be careful with the thread safety of the listener. If the listener is not thread-safe, it may cause unexpected behavior.

start_stream()

Start the stream mode.

stop_stream()

Stop the stream mode.

refresh_all()

Refresh the all registers and fields. This method will read all registers and update all fields.

Then use self.regs.cache and self.fields.cache to get the cached values you want.

Examples:

>>> senxor.refresh_all()
>>> senxor.regs.cache
{177: 0, 0: 0, 1: 0, ...}
>>> senxor.fields.cache
{"SW_RESET": 0, "DMA_TIMEOUT_ENABLE": 0, ...}

read(*, block=True)

read(*, block: Literal[False]) -> tuple[np.ndarray | None, np.ndarray | None]
read(*, block: Literal[True] = True) -> tuple[np.ndarray | None, np.ndarray]

Read a frame from the Senxor and return (header, frame).

  • header : np.ndarray[uint16], 1-D
    • Frame metadata; see the documentation for layout details.
  • frame : np.ndarray, 2-D, shape (height, width)
    • If ADC_ENABLE = 1 → dtype = uint16, values are raw ADC counts.
    • If ADC_ENABLE = 0 → dtype = float32, values are temperature in °C.

Parameters:

Name Type Description Default
block
bool

Whether to block the read operation until a frame is available. If False, if no frame is available, return None immediately.

True

Returns:

Type Description
tuple[ndarray | None, ndarray | None]

The frame data, as a tuple of two numpy arrays. The first array is the header data, the second array is the frame data.

If block=False and no frame is available, return (None, None).

Raises:

Type Description
RuntimeError

If the senxor is not in the stream mode or single capture mode.

SenxorAckTimeoutError

If the read operation timeout due to other reasons.

read_reg(reg)

Read the value from a register.

Notes
  • You need to know the register name or address to use this method.
  • For a more modern and editor-friendly approach, use senxor.regs.REG_NAME to benefit from autocompletion.
  • If you want to read multiple registers at once, read_regs is more efficient as it only communicates with the device once.

Parameters:

Name Type Description Default
reg
int | RegisterName

The register to read from, specified as an integer address or a register name.

required

Returns:

Type Description
int

The value read from the register.

Raises:

Type Description
ValueError

If the register is not readable.

Examples:

>>> senxor.read_reg(senxor.regs.EMISSIVITY)
95
>>> senxor.read_reg("EMISSIVITY")
95
>>> senxor.read_reg(0xCA)
95
>>> senxor.read_reg(202)
95

read_regs(regs)

Read the values from multiple registers at once.

Note: This method is more efficient than reading one register one by one. Warning: On some devices with older firmware, this method may cause the device to hang.

Parameters:

Name Type Description Default
regs
list[int | RegisterName]

The list of registers to read from, specified as a list of register names, integer addresses, or Register instances.

required

Returns:

Type Description
dict[int, int]

The dictionary of register addresses and their values.

Raises:

Type Description
ValueError

If a register is not readable.

Examples:

>>> senxor.regs_read([0xB1, 0xB2, 0xB3, 0xB4])
{177: 0, 178: 0, 179: 0, 180: 0}

write_reg(reg, value)

Write a value to a register.

Parameters:

Name Type Description Default
reg
int | RegisterName

The register to write to, specified as a register name, integer address, or Register instance.

required
value
int

The value to write to the register (0-0xFF).

required

Returns:

Type Description
Any

The result of the write operation, as returned by the interface.

Raises:

Type Description
ValueError

If the register is not writable or the value is out of range.

Examples:

>>> senxor.write_reg("EMISSIVITY", 0x5F)
>>> senxor.write_reg(0xCA, 0x5F)
>>> senxor.write_reg(senxor.regs.EMISSIVITY, 0x5F)

get_field(field)

Get the value of a field.

Parameters:

Name Type Description Default
field
(FieldName, str)

The field to get the value of.

required

Returns:

Type Description
int

The value of the field.

set_field(field, value)

Set the value of a field.

Parameters:

Name Type Description Default
field
FieldName

The field to set the value of.

required
value
int

The value to set the field to.

required

connect(device=None, *, auto_open=True, **kwargs)

connect(device: SerialPort, *, auto_open: bool = True) -> Senxor[SerialPort]
connect(device: None, *, auto_open: bool = True) -> Senxor[SerialPort]

Connect to a Senxor device.

Parameters:

Name Type Description Default

device

ListPortInfo | None

The device to connect to, by default None If None, the first serial device is connected.

None

auto_open

bool

Whether to automatically open the device, by default True

True

**kwargs

Additional arguments to pass to the Senxor constructor.

{}

Returns:

Type Description
Senxor

The Senxor device.

Raises:

Type Description
ValueError

If the device type is not supported.

Examples:

>>> from senxor import list_senxor, connect
>>> devices = list_senxor("serial")
>>> senxor = connect(devices[0])
>>> senxor.open()

list_senxor(interface='serial', **kwargs)

list_senxor() -> list[SerialPort]
list_senxor(interface: Literal['serial']) -> list[SerialPort]

List available Senxor devices.

Parameters:

Name Type Description Default

interface

Literal['serial']

The interface type to list devices for, by default "serial"

'serial'

**kwargs

Additional arguments for backward compatibility.

{}

Returns:

Type Description
Sequence[IDevice]

A list of available Senxor devices.

Raises:

Type Description
ValueError

If the interface type is not supported.