7 releases
0.0.10 | Oct 26, 2024 |
---|---|
0.0.9 | Oct 16, 2024 |
0.0.5 | Sep 26, 2024 |
#227 in Hardware support
324 downloads per month
89KB
2K
SLoC
generic-camera-asi
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
image
crate as a backend), - Save these images to
FITS
files (requires thecfitsio
C library, and uses thefitsio
crate) with extensive metadata, - Alternatively, use the internal
image::DynamicImage
object to obtainJPEG
,PNG
,BMP
etc.
Pre-requisite
- Install
libusb-1.0-dev
on your system. - Obtain the ZWO ASI Camera SDK.
- Extract the
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 toASI_linux_mac_SDK_VX.XX
in the current directory. - Copy
ASI_linux_mac_SDK_VX.XX/include/ASICamera2.h
to/usr/local/include
, or any other directory in your include path. - Open
README.txt
inASI_linux_mac_SDK_VX.XX/lib
to determine the applicable system platform. Follow the additional commands to install theudev
rules 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.
Usage
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};
Example
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.
Features
Activate the bayerswap
feature to swap the Bayer mosaic conversion.
Dependencies
~3–6MB
~113K SLoC