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:
- Access a connected ZWO ASI camera,
- Acquire images from the in supported pixel formats (using the
imagecrate as a backend), - Save these images to
FITSfiles (requires thecfitsioC library, and uses thefitsiocrate) with extensive metadata, - Alternatively, use the internal
image::DynamicImageobject to obtainJPEG,PNG,BMPetc.
- Install
libusb-1.0-devon your system. - Obtain the ZWO ASI Camera SDK.
- Extract the
ASI_linux_mac_SDK_VX.XX.tar.bz2from the ZIP, and extract its contents (tar -xf ASI_linux_mac_SDK_VX.XX.tar.bz2), which will extract the contents toASI_linux_mac_SDK_VX.XXin the current directory. - Copy
ASI_linux_mac_SDK_VX.XX/include/ASICamera2.hto/usr/local/include, or any other directory in your include path. - Open
README.txtinASI_linux_mac_SDK_VX.XX/libto determine the applicable system platform. Follow the additional commands to install theudevrules so that the cameras can be accessed withoutsudo. - Copy
ASI_linux_mac_SDK_VX.XX/lib/your_target_platform/libASICamera*to a directory in your library path (probably/usr/local/lib), and ensureLD_LIBRARY_PATH(Linux) orDYLD_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.