pub struct Camera { /* private fields */ }Implementations§
Source§impl Camera
impl Camera
Sourcepub fn all_cameras() -> Vec<CameraDescription>
pub fn all_cameras() -> Vec<CameraDescription>
Returns the list of all available cameras Call open() on the CameraDescription to get a Camera instance
Sourcepub fn capture(
&mut self,
buffer: &mut [u8],
timeout: Option<i32>,
) -> Result<(), Error>
pub fn capture( &mut self, buffer: &mut [u8], timeout: Option<i32>, ) -> Result<(), Error>
get a single frame, this function will block or wait for the timeout (in ms)
To get continuous frames, prefer to use the stream() method
the buffer size must be bigger than this: POA_RAW8: width * height, POA_RAW16: width * height * 2, POA_RGB24: width * height * 3
Sourcepub fn stream(
&mut self,
timeout: Option<u32>,
callback: impl FnMut(&mut Camera, &[u8]) -> bool,
) -> Result<(), Error>
pub fn stream( &mut self, timeout: Option<u32>, callback: impl FnMut(&mut Camera, &[u8]) -> bool, ) -> Result<(), Error>
Calls the callback continuously with the newest image data. Stops the stream if the callback returns false.
Sourcepub fn create_image_buffer(&self) -> Vec<u8> ⓘ
pub fn create_image_buffer(&self) -> Vec<u8> ⓘ
Creates a buffer of the proper size to hold the image data
Sourcepub fn start_exposure(&mut self) -> Result<(), Error>
pub fn start_exposure(&mut self) -> Result<(), Error>
start camera exposure for manual control over frame fetching Prefer to use stream() or single_frame() method for easier use.
Sourcepub fn is_image_ready(&self) -> Result<bool, Error>
pub fn is_image_ready(&self) -> Result<bool, Error>
the image data is available? if true, you can call get_image_data to get image data
Sourcepub fn get_image_data(
&self,
buffer: &mut [u8],
timeout_ms: Option<i32>,
) -> Result<(), Error>
pub fn get_image_data( &self, buffer: &mut [u8], timeout_ms: Option<i32>, ) -> Result<(), Error>
get image data after exposure, this function will block or wait for the timeout (in ms) None timeout means infinite blocking
the buffer size must be bigger than this: POA_RAW8: width * height, POA_RAW16: width * height * 2, POA_RGB24: width * height * 3
Sourcepub fn stop_exposure(&mut self) -> Result<(), Error>
pub fn stop_exposure(&mut self) -> Result<(), Error>
Stops the exposure. Must be called before any other camera operations if start_exposure was called.
Sourcepub fn close(self) -> Result<(), Error>
pub fn close(self) -> Result<(), Error>
Close the camera. This is done automatically on Camera drop but can be called manually if you wish to handle any errors that may occur.
Sourcepub fn config_bounds(&self) -> AllConfigBounds
pub fn config_bounds(&self) -> AllConfigBounds
Returns the bounds of all the configurations available for this camera This is an expensive operation and should not be called frequently
pub fn set_dps(&mut self, dps: bool) -> Result<(), Error>
Sourcepub fn set_image_size(&mut self, width: u32, height: u32) -> Result<(), Error>
pub fn set_image_size(&mut self, width: u32, height: u32) -> Result<(), Error>
Must be within max_width and max_height as specified in the camera properties
Sourcepub fn image_size(&self) -> (u32, u32)
pub fn image_size(&self) -> (u32, u32)
Returns the current image size This may change if the binning factor is changed
Sourcepub fn set_image_start_pos(
&mut self,
start_x: u32,
start_y: u32,
) -> Result<(), Error>
pub fn set_image_start_pos( &mut self, start_x: u32, start_y: u32, ) -> Result<(), Error>
Sets the offset/anchor/start position in the image
Sourcepub fn image_start_pos(&self) -> Result<(u32, u32), Error>
pub fn image_start_pos(&self) -> Result<(u32, u32), Error>
Returns the current image start position This may change if the binning factor is changed
pub fn set_image_format( &mut self, image_format: ImageFormat, ) -> Result<(), Error>
pub fn image_format(&self) -> Result<ImageFormat, Error>
Sourcepub fn set_bin(&mut self, bin: u32) -> Result<(), Error>
pub fn set_bin(&mut self, bin: u32) -> Result<(), Error>
Sets the binning factor e.g 1, 2, 4
Must be a bin within the available bins in properties
The binning function can be average or sum depending on the pixel_bin_sum property (true is sum, false is average). default is average
Note: If successful, the image size (width & height) and start position will be changed (divided by the binning factor)
Call image_size() and image_start_pos() to get the updated values
Sourcepub fn sensor_modes(&self) -> Result<Vec<SensorMode>, Error>
pub fn sensor_modes(&self) -> Result<Vec<SensorMode>, Error>
Enumerate sensor modes advertised by this camera.
Returns an empty vec when the camera does not support mode selection (e.g. most entry-level models). Each call queries the hardware.
Sourcepub fn sensor_mode(&self) -> Result<u32, Error>
pub fn sensor_mode(&self) -> Result<u32, Error>
Current sensor-mode index.
Returns Error::AccessDenied on cameras that do not support mode
selection.
Sourcepub fn set_sensor_mode(&mut self, index: u32) -> Result<(), Error>
pub fn set_sensor_mode(&mut self, index: u32) -> Result<(), Error>
Set the active sensor mode by index.
The caller must stop any running exposure before calling this (matches the underlying SDK requirement).
pub fn properties(&self) -> &CameraProperties
pub fn id(&self) -> i32
Sourcepub fn set_exposure(
&mut self,
exposure_micros: i64,
is_auto: bool,
) -> Result<(), Error>
pub fn set_exposure( &mut self, exposure_micros: i64, is_auto: bool, ) -> Result<(), Error>
Sets the exposure time in microseconds
pub fn set_gain(&mut self, gain: i64, is_auto: bool) -> Result<(), Error>
Sourcepub fn exposure(&self) -> Result<(i64, bool), Error>
pub fn exposure(&self) -> Result<(i64, bool), Error>
Exposure in microseconds and whether it is auto
pub fn hardware_bin(&self) -> Result<bool, Error>
Sourcepub fn temperature(&self) -> Result<f64, Error>
pub fn temperature(&self) -> Result<f64, Error>
Current temperature in Celsius
pub fn offset(&self) -> Result<i64, Error>
Sourcepub fn auto_max_gain(&self) -> Result<i64, Error>
pub fn auto_max_gain(&self) -> Result<i64, Error>
maximum gain when auto-adjust
Sourcepub fn auto_max_exposure_ms(&self) -> Result<i64, Error>
pub fn auto_max_exposure_ms(&self) -> Result<i64, Error>
maximum exposure when auto-adjust (in ms)
Sourcepub fn auto_target_brightness(&self) -> Result<i64, Error>
pub fn auto_target_brightness(&self) -> Result<i64, Error>
target brightness when auto-adjust
Sourcepub fn guide_north(&self) -> Result<bool, Error>
pub fn guide_north(&self) -> Result<bool, Error>
ST4 guide north, generally, it’s DEC+ on the mount
Sourcepub fn guide_south(&self) -> Result<bool, Error>
pub fn guide_south(&self) -> Result<bool, Error>
ST4 guide south, generally, it’s DEC- on the mount
Sourcepub fn guide_east(&self) -> Result<bool, Error>
pub fn guide_east(&self) -> Result<bool, Error>
ST4 guide east, generally, it’s RA+ on the mount
Sourcepub fn guide_west(&self) -> Result<bool, Error>
pub fn guide_west(&self) -> Result<bool, Error>
ST4 guide west, generally, it’s RA- on the mount
Sourcepub fn cooler_power(&self) -> Result<i64, Error>
pub fn cooler_power(&self) -> Result<i64, Error>
cooler power percentage[0-100%](only cool camera)
Sourcepub fn target_temp(&self) -> Result<i64, Error>
pub fn target_temp(&self) -> Result<i64, Error>
camera target temperature (in Celsius)
Sourcepub fn heater_power(&self) -> Result<i64, Error>
pub fn heater_power(&self) -> Result<i64, Error>
lens heater power percentage[0-100%]
Sourcepub fn frame_limit(&self) -> Result<i64, Error>
pub fn frame_limit(&self) -> Result<i64, Error>
Range is [0, 2000] 0 means no limit
Sourcepub fn hqi(&self) -> Result<bool, Error>
pub fn hqi(&self) -> Result<bool, Error>
High Quality Image, for those without DDR camera(guide camera) if true, this will reduce the waviness and stripe of the image
Sourcepub fn usb_bandwidth_limit(&self) -> Result<i64, Error>
pub fn usb_bandwidth_limit(&self) -> Result<i64, Error>
0-100% usage of USB bandwidth
Sourcepub fn pixel_bin_sum(&self) -> Result<bool, Error>
pub fn pixel_bin_sum(&self) -> Result<bool, Error>
take the sum or average of pixels after binning, true is sum and false is average, default is false
Sourcepub fn mono_bin(&self) -> Result<bool, Error>
pub fn mono_bin(&self) -> Result<bool, Error>
only for color camera, when set to true, pixel binning will use neighbour pixels and image after binning will lose the bayer pattern
pub fn set_hardware_bin(&mut self, value: bool) -> Result<(), Error>
Sourcepub fn set_wb_r(&mut self, value: i64) -> Result<(), Error>
pub fn set_wb_r(&mut self, value: i64) -> Result<(), Error>
set the red pixels coefficient of white balance
Sourcepub fn set_wb_g(&mut self, value: i64) -> Result<(), Error>
pub fn set_wb_g(&mut self, value: i64) -> Result<(), Error>
set the green pixels coefficient of white balance
Sourcepub fn set_wb_b(&mut self, value: i64) -> Result<(), Error>
pub fn set_wb_b(&mut self, value: i64) -> Result<(), Error>
set the blue pixels coefficient of white balance
pub fn set_offset(&mut self, value: i64) -> Result<(), Error>
Sourcepub fn set_auto_max_gain(&mut self, value: i64) -> Result<(), Error>
pub fn set_auto_max_gain(&mut self, value: i64) -> Result<(), Error>
set the max gain when auto-adjust
Sourcepub fn set_auto_max_exposure_ms(&mut self, value: i64) -> Result<(), Error>
pub fn set_auto_max_exposure_ms(&mut self, value: i64) -> Result<(), Error>
set the max exposure when auto-adjust (in ms)
Sourcepub fn set_auto_target_brightness(&mut self, value: i64) -> Result<(), Error>
pub fn set_auto_target_brightness(&mut self, value: i64) -> Result<(), Error>
set the target brightness when auto-adjust
Sourcepub fn set_guide_north(&mut self, value: bool) -> Result<(), Error>
pub fn set_guide_north(&mut self, value: bool) -> Result<(), Error>
set ST4 guide north, generally, it’s DEC+ on the mount
Sourcepub fn set_guide_south(&mut self, value: bool) -> Result<(), Error>
pub fn set_guide_south(&mut self, value: bool) -> Result<(), Error>
set ST4 guide south, generally, it’s DEC- on the mount
Sourcepub fn set_guide_east(&mut self, value: bool) -> Result<(), Error>
pub fn set_guide_east(&mut self, value: bool) -> Result<(), Error>
set ST4 guide east, generally, it’s RA+ on the mount
Sourcepub fn set_guide_west(&mut self, value: bool) -> Result<(), Error>
pub fn set_guide_west(&mut self, value: bool) -> Result<(), Error>
set ST4 guide west, generally, it’s RA- on the mount
Sourcepub fn set_target_temperature(&mut self, value: i64) -> Result<(), Error>
pub fn set_target_temperature(&mut self, value: i64) -> Result<(), Error>
set the camera target temperature (in Celsius)
Sourcepub fn set_cooler(&mut self, value: bool) -> Result<(), Error>
pub fn set_cooler(&mut self, value: bool) -> Result<(), Error>
set the cooler(and fan) on or off
Sourcepub fn set_heater(&mut self, value: bool) -> Result<(), Error>
👎Deprecated
pub fn set_heater(&mut self, value: bool) -> Result<(), Error>
set the state of lens heater(on or off)
Sourcepub fn set_heater_power(&mut self, value: i64) -> Result<(), Error>
pub fn set_heater_power(&mut self, value: i64) -> Result<(), Error>
set the lens heater power percentage[0-100%]
Sourcepub fn set_fan_power(&mut self, value: i64) -> Result<(), Error>
pub fn set_fan_power(&mut self, value: i64) -> Result<(), Error>
set the radiator fan power percentage[0-100%]
Sourcepub fn set_frame_limit(&mut self, value: i64) -> Result<(), Error>
pub fn set_frame_limit(&mut self, value: i64) -> Result<(), Error>
set the frame limit Range is [0, 2000]. 0 means no limit
Sourcepub fn set_hqi(&mut self, value: bool) -> Result<(), Error>
pub fn set_hqi(&mut self, value: bool) -> Result<(), Error>
set High Quality Image, for those without DDR camera(guide camera) if true, this will reduce the waviness and stripe of the image but frame rate may go down note: this config has no effect on cameras with DDR
Sourcepub fn set_usb_bandwidth_limit(&mut self, value: i64) -> Result<(), Error>
pub fn set_usb_bandwidth_limit(&mut self, value: i64) -> Result<(), Error>
set the maximum usage of USB bandwidth [0-100%]