Camera control

typedef struct hv_camera_spectrograph hv_camera_spectrograph_t

Spectograph invariants.

These values are defined per camera-type and should not be changed.

typedef struct hv_camera_calibration hv_camera_calibration_t

Calibration parameters.

The user should generally not modify these values.

typedef struct hv_camera_config hv_camera_config_t

Configuration options of a given camera.

These include invariants of the spectrograph and calibration parameters.

typedef struct hv_camera hv_camera_t

The camera interface type.

This type can represent either a real camera (through a TCP or GigE connection) or a simulated image-based camera.

typedef struct hv_crop_info hv_crop_info_t

The cameras current cropping dimensions.

The vertical crop is the total height of the frame returned by the camera.

typedef struct hv_horizontal_crop hv_horizontal_crop_t

Horizontal cropping descriptor.

void hv_camera_config_free(hv_camera_config_t **config)

Free config object.

Parameters:

config – Owned config pointer.

void hv_camera_free(hv_camera_t **camera)

Free a camera handle previously returned by hv_camera_new or hv_camera_from_hs_image.

Parameters:

camera – Output box holding the camera to free. After return it becomes null.

int32_t hv_camera_from_hs_image(hv_hs_image_t *img, hv_camera_t **camera)

Create a camera from an in-memory hyperspectral image.

Parameters:
  • img – Boxed DynamicHSImage. The function takes ownership and frees the memory.

  • camera – Output pointer to receive the created camera handle.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_camera_get_bands(hv_camera_t const *camera, hv_band_list_t **bands)

Get the current band selection.

Parameters:
  • camera

  • bands – Band selection out pointer.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_camera_get_config(hv_camera_t const *camera, hv_camera_config_t **config)

Get the current camera configuration.

Parameters:
  • camera

  • config – Output pointer to receive the configuration.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_camera_get_crop(hv_camera_t const *camera, hv_crop_info_t **crop)

Get current cropping information.

Parameters:
  • camera

  • crop – Output pointer to receive the crop information.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_camera_get_exposure(hv_camera_t const *camera)

Get the exposure time.

Parameters:

camera – Camera pointer.

Return values:
  • -1 – Error

  • us – Exposure time in microseconds

float hv_camera_get_framerate(hv_camera_t const *camera)

Get the current framerate.

Parameters:

camera – Camera pointer.

Return values:
  • NaN – Error

  • fps – The framerate

int8_t hv_camera_get_horizontal_binning(hv_camera_t const *camera)

Get the horizontal binning factor.

Parameters:

camera – Camera pointer.

Return values:
  • -1 – Error

  • value – Binning factor (>=1)

int32_t hv_camera_get_hs_image(hv_camera_t const *camera, hv_hs_image_t **img)

Retrieve the current hyperspectral image from the camera.

Parameters:
  • camera

  • img – Output pointer to receive the DynamicHSImage.

Return values:
  • 0 – Ok

  • nonzero – Error

int8_t hv_camera_get_vertical_binning(hv_camera_t const *camera)

Get the vertical binning factor.

Parameters:

camera – Camera pointer.

Return values:
  • -1 – Error

  • value – Binning factor (>=1)

int32_t hv_camera_get_wavelengths(hv_camera_t const *camera, slice_boxed_float_t **wavelengths)

Get wavelengths.

int32_t hv_camera_new(char const *addr, hv_camera_t **camera)

Create a new camera instance connected to a device.

Parameters:
  • addr – Null-terminated string with camera address or identifier.

  • camera – Output pointer to receive the created camera handle.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_camera_set_bands(hv_camera_t const *camera, hv_band_list_t *bands, hv_band_list_t **bands_out)

Set the current band selection.

Parameters:
  • camera

  • bands – Band selection pointer. The function takes ownership and frees the corresponding memory.

  • bands_out – Output pointer to receive the applied band selection. The caller takes ownership of the returned object.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_camera_set_config(hv_camera_t const *camera, hv_camera_config_t const *config)

Apply a new camera configuration.

Parameters:
  • camera

  • config – Configuration to apply.

Return values:
  • 0 – Ok

  • nonzero – Error

int32_t hv_camera_set_exposure(hv_camera_t const *camera, uint32_t value)

Set the exposure time.

Parameters:
  • camera – Camera pointer.

  • value – Exposure time in microseconds.

Return values:
  • -1 – Error

  • us – The applied exposure time in microseconds

float hv_camera_set_framerate(hv_camera_t const *camera, float value)

Set the camera framerate.

Parameters:
  • camera – Camera pointer.

  • value – Desired framerate in frames per second.

Return values:
  • NaN – Error

  • fps – The applied framerate (may differ from requested)

int8_t hv_camera_set_horizontal_binning(hv_camera_t const *camera, uint8_t value)

Set the horizontal binning factor.

Parameters:
  • camera – Camera pointer.

  • value – Desired binning factor (>=1).

Return values:
  • -1 – Error

  • value – The applied binning factor

int32_t hv_camera_set_horizontal_crop(hv_camera_t const *camera, uint16_t start, uint16_t end, hv_horizontal_crop_t **crop_out)

Set the horizontal crop of the camera.

Parameters:
  • camera

  • start – Start index of the crop.

  • end – End index of the crop.

  • crop_out – Output pointer to receive the applied crop.

Return values:
  • 0 – Ok

  • nonzero – Error

int8_t hv_camera_set_vertical_binning(hv_camera_t const *camera, uint8_t value)

Set the vertical binning factor.

Parameters:
  • camera – Camera pointer.

  • value – Desired binning factor (>=1).

Return values:
  • -1 – Error

  • value – The applied binning factor

void hv_crop_info_free(hv_crop_info_t **crop)

Free crop info object.

Parameters:

crop – Crop info object.

void hv_horizontal_crop_free(hv_horizontal_crop_t **crop)

Free horizontal crop object.

Parameters:

crop – Crop object.

struct hv_camera_spectrograph
#include <hv-sdk.h>

Spectograph invariants.

These values are defined per camera-type and should not be changed.

Public Members

float_2_array_t spectral_range_nm

The spectral range in nm (min-max)

uint16_t sensor_crop_height

The height of the spectral range on the sensor (in pixels)

uint16_t sensor_crop_width

The width of the slit image on the sensor (in pixels)

struct hv_camera_calibration
#include <hv-sdk.h>

Calibration parameters.

The user should generally not modify these values.

Public Members

uint16_t crop_top

Top cropping offset in pixels.

uint16_t crop_left

Left cropping offset in pixels.

For some sensors, this is always 0.

struct hv_camera_config
#include <hv-sdk.h>

Configuration options of a given camera.

These include invariants of the spectrograph and calibration parameters.

Public Members

hv_camera_spectrograph_t spectrograph

Spectrograph invariants.

hv_camera_calibration_t calibration

Calibration parameters.

struct hv_crop_info
#include <hv-sdk.h>

The cameras current cropping dimensions.

The vertical crop is the total height of the frame returned by the camera.

Public Members

size_t max_width

The maximum crop width.

size_t max_height

The maximum crop height (bands)

size_t current_width

The current crop width.

size_t current_height

The current crop height (bands)

struct hv_horizontal_crop
#include <hv-sdk.h>

Horizontal cropping descriptor.

Public Members

uint16_t start

Start pixel position.

uint16_t end

End pixel position.

Band list

typedef struct hv_band_list hv_band_list_t

List of band selections.

typedef struct hv_band_list_item hv_band_list_item_t

A single band selection item.

If only start is non-negative, the selection is a single index. If end is non-negative, the selection is a range. If step is non-negative, the selection is a range with a step.

void hv_band_list_append(hv_band_list_t *list, int16_t start, int16_t end, int16_t step)

Append a band selection item to the list.

Parameters:
  • list – Band list to modify.

  • start – Inclusive start band index (or value if single index).

  • end – Inclusive end band index, or -1 for a single index.

  • step – Step between indices, or -1 for no step.

void hv_band_list_display(hv_band_list_t const *list)

Print a human-readable representation of the band list to stdout.

Parameters:

list – Band list to display.

void hv_band_list_free(hv_band_list_t **list)

Free band selection list.

Parameters:

list – Pointer to the list.

hv_band_list_item_t hv_band_list_get(hv_band_list_t const *list, size_t index)

Get a band selection item by index.

Parameters:
  • list – Band list to read from.

  • index – Zero-based index.

Return values:
  • hv_band_list_item – The band item if index is valid.

  • {-1, -1, -1} – Error (index out of bounds).

void hv_band_list_new(hv_band_list_t **list)

Create a new empty band selection list.

Parameters:

list – Output pointer to receive a newly allocated hv_band_list. The caller takes ownership of the returned object.

struct hv_band_list_item
#include <hv-sdk.h>

A single band selection item.

If only start is non-negative, the selection is a single index. If end is non-negative, the selection is a range. If step is non-negative, the selection is a range with a step.

Public Members

int16_t start

The starting index of the selection.

int16_t end

If nonzero, this is the end (exclusive) of the selection.

int16_t step

If nonzero, this is the step between indices.