| Crates.io | generic-camera-asi |
| lib.rs | generic-camera-asi |
| version | 0.0.11 |
| created_at | 2024-09-20 21:16:32.989789+00 |
| updated_at | 2025-01-23 23:03:12.509313+00 |
| description | An efficient and ergonomic interface to capture images using cameras. |
| homepage | https://crates.io/crates/generic-camera-asi |
| repository | https://github.com/sunipkm/generic-camera-asi |
| max_upload_size | |
| id | 1381799 |
| size | 93,570 |
generic-camera-asi implements the API traits provided by generic-camera
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
refimage::GenericImageRef with extensive metadata.
As is, this Rust driver is intended for use on Linux and macOS platforms.
You can use generic-camera-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]
generic-camera-asi = "<1.0"
and this to your source code:
use generic_camera::{GenCam, GenCamDriver};
use generic_camera_asi::{GenCamAsi, GenCamDriverAsi};
use std::{thread::sleep, time::Duration};
Minimally, the following can open the first available camera and capture a single image:
let mut drv = GenCamDriverAsi;
if drv.available_devices() == 0 {
return;
}
let mut cam = drv.connect_first_device().expect("Could not connect to camera");
cam.start_exposure().expect("Could not start exposure");
while !cam.image_ready().expect("Could not check if image is ready") {
sleep(Duration::from_secs(1));
}
let img = cam
.download_image()
.expect("Could not download image");
For a more complete example, refer to the bundled program.