Camera control#
- class hs.control.Camera(input)#
The camera interface type.
This type can represent either a real camera (through a TCP or GigE connection) or a simulated image-based camera.
- classmethod __new__(*args, **kwargs)#
- get_bands()#
Get the current band selection.
Each entry is either a single band index (
int), a band range(start, end), or a stepped band range(start, end, step).
- get_bit_mode()#
Get the current bit mode.
- Returns:
The current bit mode as bits (8, 10, or 12).
- Return type:
- get_config()#
Get the hyperspectral camera configuration.
- Returns:
The configuration object.
- Return type:
- get_crop()#
Get the current crop settings.
The returned object exposes
max_width,max_height,current_width, andcurrent_heightattributes, all measured in pixels (the height values are bands).- Returns:
The current crop information.
- Return type:
- get_exposure()#
Get the exposure time in microseconds.
- Returns:
Exposure time in microseconds.
- Return type:
- get_framerate_list()#
Get the possible framerates.
- get_horizontal_binning()#
Get the horizontal binning factor.
- Returns:
The current horizontal binning factor.
- Return type:
- get_vertical_binning()#
Get the vertical binning factor.
- Returns:
The current vertical binning factor.
- Return type:
- get_wavelengths()#
Get the wavelengths of the camera’s spectral bands.
- set_analog_gain(value)#
Set Analog gain
- set_bands(value)#
Set the bands configuration.
Each entry is either a single band index (
int), a band range(start, end), or a stepped band range(start, end, step).
- set_bit_mode(bit_mode)#
- set_config(value)#
Set the hyperspectral camera configuration.
- Parameters:
value (HSCameraConfig) – The new configuration.
- Returns:
The actual set configuration.
- Return type:
- set_exposure(value)#
Set the exposure time.
- set_framerate(value)#
Set the current framerate.
- set_horizontal_binning(value)#
Set the horizontal binning factor.
- set_horizontal_crop(start, end)#
Set the horizontal crop boundaries.
- Parameters:
- Returns:
The actual set horizontal crop.
- Return type:
- set_vertical_binning(value)#
Set the vertical binning factor.
- stream(n_frames=None)#
Start camera stream.
Returns once the camera has accepted the connection and is streaming, so a camera that cannot start raises here rather than yielding a stream that ends immediately. A camera that has just stopped a stream needs a moment to release the video device; this waits that out, so back-to-back
CameraStream.stop()/stream()pairs need no delay in between, at the cost of the call occasionally taking a second to return.Buffering is configured on the camera through
stream_options, so it applies to pipelines built from this camera too, not just to streams started here.- Parameters:
n_frames (Optional[int]) – If set, the stream delivers at most this many frames before terminating on its own. Unless the stream is buffered with
on_full="block", frames can be evicted or skipped along the way, so the delivered frames are not necessarily consecutive. IfNone(the default), the stream runs untilCameraStream.stop()is called.
- __module__ = 'builtins'#
- stream_options#
The buffering configuration used by every stream this camera starts.
This covers
stream()as well as streams driven by anImagepipeline built from this camera, which have no other way to pass options.The returned object is a live view of the camera’s configuration, so individual fields can be assigned through it:
cam.stream_options.capacity = 64Assigning the property itself copies the values across, which is the convenient way to change several at once:
cam.stream_options = control.StreamOptions(capacity=64, on_full="block")- Type:
- class hs.control.CameraStream#
Type representing a regular two-dimensional frame stream.
- __enter__()#
- __exit__(_exc_type, _exc_value, _traceback)#
- __iter__()#
Implement iter(self).
- __next__()#
Implement next(self).
- dropped()#
Number of frames discarded locally because the buffer was full and the consumer had fallen behind.
Always
0for a buffered stream started withon_full="block". An unbuffered stream also counts the older frames each read skips. This is unrelated toFrameMeta.dropped, which reports frames lost between the camera and the host.- Return type:
- get_frame()#
Get a single frame from the stream.
- Returns:
The frame data as a 2D Numpy array and metadata.
- Return type:
tuple[FrameMeta, numpy.ndarray] | None
- Raises:
TimeoutError – If no frame arrives within
wait_timeout. The stream keeps running, so the call can be retried.
- stop()#
Stop the stream.
- __module__ = 'builtins'#
- class hs.control.HSCameraConfig#
Configuration options of a given camera.
These include invariants of the spectrograph and calibration parameters.
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- __module__ = 'builtins'#
- calibration#
Calibration parameters.
- spectrograph#
Spectrograph invariants.
- class hs.control.HSCameraSettings#
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- __module__ = 'builtins'#
- bands#
- exposure#
- horizontal_binning#
- horizontal_crop#
- vertical_binning#
- class hs.control.HorizontalCrop#
Horizontal cropping descriptor.
- __repr__()#
Return repr(self).
- __str__()#
Return str(self).
- __module__ = 'builtins'#
- end#
End pixel position.
- start#
Start pixel position.
- hs.control.list_devices(address)#
- class hs.control.StreamOptions(*, buffered=None, capacity=None, wait_timeout=None, on_full=None)#
How a camera buffers frames for its consumer.
Obtained from
Camera.stream_options, where it is a live view of that camera’s configuration: assigning a field takes effect immediately. Constructing one directly gives a detached value, useful for assigning several settings at once.- wait_timeout#
How long a read waits for a frame before raising
TimeoutError, which usually means the camera has stalled.- Type: