senxor
senxor¶
Top-level package for Senxor devices.
Senxor(interface, *, auto_open=True)
¶
Bases: SenxorHelperMixin, Generic[TDevice]
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
TInterface
|
The interface of the senxor. |
required |
|
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()
¶
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_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 |
|---|---|---|---|
|
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:
|
set_module_gain(gain)
¶
get_manuf_location()
¶
get_serial_number()
¶
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:
YYis the production year (from 2000 to 2099).WWis the production week.LLis the manufacturing location.SSSSSSis 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:
|
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)
¶
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 |
|---|---|---|---|
|
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)
¶
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)
¶
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)
¶
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)
¶
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)
¶
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)
¶
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)
¶
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 |
|---|---|---|---|
|
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 |
|---|---|---|---|
|
Literal['open', 'close', 'data', 'error']
|
The event to register the listener for. |
required |
|
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 |
|---|---|---|---|
|
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 |
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_NAMEto benefit from autocompletion. - If you want to read multiple registers at once,
read_regsis more efficient as it only communicates with the device once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
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 |
|---|---|---|---|
|
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 |
|---|---|---|---|
|
int | RegisterName
|
The register to write to, specified as a register name, integer address, or Register instance. |
required |
|
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)
¶
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 |
|---|---|---|---|
|
ListPortInfo | None
|
The device to connect to, by default None If None, the first serial device is connected. |
None
|
|
bool
|
Whether to automatically open the device, by default True |
True
|
|
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 |
|---|---|---|---|
|
Literal['serial']
|
The interface type to list devices for, by default "serial" |
'serial'
|
|
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. |