Skip to main content

Camera

Struct Camera 

Source
pub struct Camera { /* private fields */ }

Implementations§

Source§

impl Camera

Source

pub fn all_cameras() -> Vec<CameraDescription>

Returns the list of all available cameras Call open() on the CameraDescription to get a Camera instance

Source

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

Source

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.

Source

pub fn create_image_buffer(&self) -> Vec<u8>

Creates a buffer of the proper size to hold the image data

Source

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.

Source

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

Source

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

Source

pub fn stop_exposure(&mut self) -> Result<(), Error>

Stops the exposure. Must be called before any other camera operations if start_exposure was called.

Source

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.

Source

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

Source

pub fn set_dps(&mut self, dps: bool) -> Result<(), Error>

Source

pub fn set_roi(&mut self, roi_area: &ROI) -> Result<(), Error>

Sets the Region Of Interest

Source

pub fn roi(&self) -> ROI

Gets the Region Of Interest

Source

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

Source

pub fn image_size(&self) -> (u32, u32)

Returns the current image size This may change if the binning factor is changed

Source

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

Source

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

Source

pub fn set_image_format( &mut self, image_format: ImageFormat, ) -> Result<(), Error>

Source

pub fn image_format(&self) -> Result<ImageFormat, Error>

Source

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

Source

pub fn bin(&self) -> u32

Returns the current binning factor

Source

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.

Source

pub fn sensor_mode(&self) -> Result<u32, Error>

Current sensor-mode index.

Returns Error::AccessDenied on cameras that do not support mode selection.

Source

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).

Source

pub fn properties(&self) -> &CameraProperties

Source

pub fn id(&self) -> i32

Source

pub fn set_exposure( &mut self, exposure_micros: i64, is_auto: bool, ) -> Result<(), Error>

Sets the exposure time in microseconds

Source

pub fn set_gain(&mut self, gain: i64, is_auto: bool) -> Result<(), Error>

Source

pub fn exposure(&self) -> Result<(i64, bool), Error>

Exposure in microseconds and whether it is auto

Source

pub fn gain(&self) -> Result<(i64, bool), Error>

Gain and whether it is auto

Source

pub fn hardware_bin(&self) -> Result<bool, Error>

Source

pub fn temperature(&self) -> Result<f64, Error>

Current temperature in Celsius

Source

pub fn wb_r(&self) -> Result<i64, Error>

red pixels coefficient of white balance

Source

pub fn wb_g(&self) -> Result<i64, Error>

green pixels coefficient of white balance

Source

pub fn wb_b(&self) -> Result<i64, Error>

blue pixels coefficient of white balance

Source

pub fn offset(&self) -> Result<i64, Error>

Source

pub fn auto_max_gain(&self) -> Result<i64, Error>

maximum gain when auto-adjust

Source

pub fn auto_max_exposure_ms(&self) -> Result<i64, Error>

maximum exposure when auto-adjust (in ms)

Source

pub fn auto_target_brightness(&self) -> Result<i64, Error>

target brightness when auto-adjust

Source

pub fn guide_north(&self) -> Result<bool, Error>

ST4 guide north, generally, it’s DEC+ on the mount

Source

pub fn guide_south(&self) -> Result<bool, Error>

ST4 guide south, generally, it’s DEC- on the mount

Source

pub fn guide_east(&self) -> Result<bool, Error>

ST4 guide east, generally, it’s RA+ on the mount

Source

pub fn guide_west(&self) -> Result<bool, Error>

ST4 guide west, generally, it’s RA- on the mount

Source

pub fn egain(&self) -> Result<f64, Error>

e/ADU, This value will change with gain

Source

pub fn cooler_power(&self) -> Result<i64, Error>

cooler power percentage[0-100%](only cool camera)

Source

pub fn target_temp(&self) -> Result<i64, Error>

camera target temperature (in Celsius)

Source

pub fn cooler(&self) -> Result<bool, Error>

is cooler(and fan) on or off

Source

pub fn heater(&self) -> Result<bool, Error>

👎Deprecated

get state of lens heater(on or off)

Source

pub fn heater_power(&self) -> Result<i64, Error>

lens heater power percentage[0-100%]

Source

pub fn fan_power(&self) -> Result<i64, Error>

radiator fan power percentage[0-100%]

Source

pub fn frame_limit(&self) -> Result<i64, Error>

Range is [0, 2000] 0 means no limit

Source

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

Source

pub fn usb_bandwidth_limit(&self) -> Result<i64, Error>

0-100% usage of USB bandwidth

Source

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

Source

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

Source

pub fn set_hardware_bin(&mut self, value: bool) -> Result<(), Error>

Source

pub fn set_wb_r(&mut self, value: i64) -> Result<(), Error>

set the red pixels coefficient of white balance

Source

pub fn set_wb_g(&mut self, value: i64) -> Result<(), Error>

set the green pixels coefficient of white balance

Source

pub fn set_wb_b(&mut self, value: i64) -> Result<(), Error>

set the blue pixels coefficient of white balance

Source

pub fn set_offset(&mut self, value: i64) -> Result<(), Error>

Source

pub fn set_auto_max_gain(&mut self, value: i64) -> Result<(), Error>

set the max gain when auto-adjust

Source

pub fn set_auto_max_exposure_ms(&mut self, value: i64) -> Result<(), Error>

set the max exposure when auto-adjust (in ms)

Source

pub fn set_auto_target_brightness(&mut self, value: i64) -> Result<(), Error>

set the target brightness when auto-adjust

Source

pub fn set_guide_north(&mut self, value: bool) -> Result<(), Error>

set ST4 guide north, generally, it’s DEC+ on the mount

Source

pub fn set_guide_south(&mut self, value: bool) -> Result<(), Error>

set ST4 guide south, generally, it’s DEC- on the mount

Source

pub fn set_guide_east(&mut self, value: bool) -> Result<(), Error>

set ST4 guide east, generally, it’s RA+ on the mount

Source

pub fn set_guide_west(&mut self, value: bool) -> Result<(), Error>

set ST4 guide west, generally, it’s RA- on the mount

Source

pub fn set_target_temperature(&mut self, value: i64) -> Result<(), Error>

set the camera target temperature (in Celsius)

Source

pub fn set_cooler(&mut self, value: bool) -> Result<(), Error>

set the cooler(and fan) on or off

Source

pub fn set_heater(&mut self, value: bool) -> Result<(), Error>

👎Deprecated

set the state of lens heater(on or off)

Source

pub fn set_heater_power(&mut self, value: i64) -> Result<(), Error>

set the lens heater power percentage[0-100%]

Source

pub fn set_fan_power(&mut self, value: i64) -> Result<(), Error>

set the radiator fan power percentage[0-100%]

Source

pub fn set_frame_limit(&mut self, value: i64) -> Result<(), Error>

set the frame limit Range is [0, 2000]. 0 means no limit

Source

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

Source

pub fn set_usb_bandwidth_limit(&mut self, value: i64) -> Result<(), Error>

set the maximum usage of USB bandwidth [0-100%]

Source

pub fn set_pixel_bin_sum(&mut self, value: bool) -> Result<(), Error>

set whether to take the sum or average of pixels after binning, true is sum and false is average, default is false

Source

pub fn set_mono_bin(&mut self, value: bool) -> Result<(), Error>

only for color camera: if true, pixel binning will use neighbour pixels and image after binning will lose the bayer pattern

Trait Implementations§

Source§

impl Debug for Camera

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Drop for Camera

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.