14 stable releases
4.1.0 | May 14, 2024 |
---|---|
4.0.2 | Apr 4, 2024 |
3.0.1 | Apr 4, 2024 |
2.4.1 | Oct 3, 2023 |
2.1.2 | Sep 30, 2023 |
#235 in Hardware support
115KB
2K
SLoC
cameraunit_asi
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:
- 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]
cameraunit_asi = "4.1"
and this to your source code:
use cameraunit::{CameraUnit, CameraInfo, ImageData};
use cameraunit_asi::{num_cameras, open_first_camera, ASIImageFormat};
Example
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.
Installation
The example program can be installed using
$ cargo install cameraunit_asi
and executed using
$ asicamera_capture
Dependencies
~17–27MB
~350K SLoC