Crates.io | cameraunit_asi |
lib.rs | cameraunit_asi |
version | 4.1.0 |
source | src |
created_at | 2023-09-30 19:03:36.139118 |
updated_at | 2024-05-14 23:44:17.830591 |
description | An efficient and ergonomic interface to capture images using cameras. |
homepage | https://crates.io/crates/cameraunit_asi |
repository | https://github.com/sunipkm/cameraunit |
max_upload_size | |
id | 988801 |
size | 132,215 |
cameraunit_asi
implements the API traits provided by cameraunit
to capture frames from CCD/CMOS based detectors from ZWO. This crate provides
wrappers for the ASI Camera SDK C library to access the
cameras for image capture and other housekeeping functions in a safe way. Images are obtained as
cameraunit::ImageData
with extensive metadata.
As is, this Rust driver is intended for use on Linux and macOS platforms.
You can use cameraunit_asi
to:
image
crate as a backend),FITS
files (requires the cfitsio
C library, and uses the fitsio
crate) with extensive metadata,image::DynamicImage
object to obtain JPEG
, PNG
, BMP
etc.libusb-1.0-dev
on your system.ASI_linux_mac_SDK_VX.XX.tar.bz2
from the ZIP, and extract its contents (tar -xf ASI_linux_mac_SDK_VX.XX.tar.bz2
), which will extract the contents to ASI_linux_mac_SDK_VX.XX
in the current directory.ASI_linux_mac_SDK_VX.XX/include/ASICamera2.h
to /usr/local/include
, or any other directory in your include path.README.txt
in ASI_linux_mac_SDK_VX.XX/lib
to determine the applicable system platform. Follow the additional commands to install the udev
rules so that the cameras can be accessed without sudo
.ASI_linux_mac_SDK_VX.XX/lib/your_target_platform/libASICamera*
to a directory in your library path (probably /usr/local/lib
), and ensure LD_LIBRARY_PATH
(Linux) or DYLD_LIBRARY_PATH
(macOS) contains the library path.Add this to your Cargo.toml
:
[dependencies]
cameraunit_asi = "4.1"
and this to your source code:
use cameraunit::{CameraUnit, CameraInfo, ImageData};
use cameraunit_asi::{num_cameras, open_first_camera, ASIImageFormat};
Minimally, the following can open the first available camera, capture a single image, and save it to a FITS
file:
let nc = num_cameras();
if nc <= 0 {
return;
}
let (mut cam, _caminfo) = open_first_camera()
.map_err(|x| println!("Opening camera: {}", x.to_string()))
.unwrap();
cam.set_exposure(Duration::from_millis(700))
.map_err(|x| println!("Setting exposure: {}", x.to_string()))
.unwrap();
cam.start_exposure()
.map_err(|x| println!("Start exposure: {}", x.to_string()))
.unwrap();
while !cam
.image_ready()
.map_err(|x| println!("Check exposure: {}", x.to_string()))
.unwrap()
{
sleep(Duration::from_secs(1));
}
let img = cam
.download_image()
.map_err(|x| println!("Downloading image: {}", x.to_string()))
.unwrap();
img.save_fits(Path::new("./"), "test", "asicam_test", true, true)
.unwrap();
Note, that the unused _caminfo
object implements the cameraunit::CameraInfo
trait and can be cloned and passed around
to multiple threads.
For a more complete example, refer to the bundled program.
The example program can be installed using
$ cargo install cameraunit_asi
and executed using
$ asicamera_capture