senxor.utils
senxor.utils¶
Utilities for Senxor devices.
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. |
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()
remap(image, in_range=None, out_range=None, dtype=np.uint8)
¶
Remap image intensity to a desired range and data type using NumPy.
It's equivalent to normalize(..., dtype=np.uint8).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
|
ndarray
|
The image to remap. |
required |
|
tuple | None
|
The input range of the image. If |
None
|
|
tuple | None
|
The output range of the image. |
None
|
|
Any
|
The data type of the image. |
uint8
|
Returns:
| Type | Description |
|---|---|
ndarray
|
The remapped image. |