diff options
author | iximeow <me@iximeow.net> | 2019-07-23 23:21:14 -0700 |
---|---|---|
committer | iximeow <me@iximeow.net> | 2019-07-23 23:21:14 -0700 |
commit | 30c518c400fda401134a92eedbbd99004b387ab7 (patch) | |
tree | 474a56d1b46c6660c21b369602a6288527ff603e /src/asicam | |
parent | 3a91cc308139a4ec5e8aff09f6f5eb2f81969249 (diff) |
asi camera adjustments
record images in 16 bit mode, is the biggest change
Diffstat (limited to 'src/asicam')
-rw-r--r-- | src/asicam/mod.rs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/src/asicam/mod.rs b/src/asicam/mod.rs index 4d006ae..93ed683 100644 --- a/src/asicam/mod.rs +++ b/src/asicam/mod.rs @@ -117,25 +117,29 @@ impl Camera { ASICamera2::ASIGetDataAfterExp( self.id, self.image_buffer, - self.curr_width as i64 * self.curr_height as i64 * 3 + self.curr_width as i64 * self.curr_height as i64 * 2 ) }; build_result((), res)?; + let mut real_image = vec![0; self.curr_width as usize * self.curr_height as usize * 2 * 3]; + for i in 0..(self.curr_width * self.curr_height) { + unsafe { + real_image[i as usize * 6 + 0] = *self.image_buffer.offset(i as isize * 2 + 1); + real_image[i as usize * 6 + 2] = *self.image_buffer.offset(i as isize * 2 + 1); + real_image[i as usize * 6 + 4] = *self.image_buffer.offset(i as isize * 2 + 1); + real_image[i as usize * 6 + 1] = *self.image_buffer.offset(i as isize * 2); + real_image[i as usize * 6 + 3] = *self.image_buffer.offset(i as isize * 2); + real_image[i as usize * 6 + 5] = *self.image_buffer.offset(i as isize * 2); + } + } let dest = Path::new(path); let file = File::create(dest).unwrap(); let ref mut w = BufWriter::new(file); let mut encoder = png::Encoder::new(w, self.curr_width, self.curr_height); - encoder.set(png::ColorType::RGB).set(png::BitDepth::Eight); + encoder.set(png::ColorType::RGB).set(png::BitDepth::Sixteen); let mut writer = encoder.write_header().unwrap(); - writer.write_image_data( - unsafe { - std::slice::from_raw_parts( - self.image_buffer, - self.curr_width as usize * self.curr_height as usize* 3 - ) - } - ).unwrap(); + writer.write_image_data(&real_image).unwrap(); Ok(()) } @@ -248,10 +252,10 @@ pub fn acquire(camera_id: i32) -> Result<Camera> { camera.curr_height = camera_props.max_height as u32; camera.color_format = ImageType::RGB24; camera.image_buffer = alloc( - Layout::from_size_align(camera.curr_width as usize * camera.curr_height as usize * 3, 8).unwrap() + Layout::from_size_align(camera.curr_width as usize * camera.curr_height as usize * 2, 8).unwrap() ); - let res = ASICamera2::ASISetROIFormat(camera_id, camera.width as i32, camera.height as i32, 1, ImageType::RGB24 as i32); + let res = ASICamera2::ASISetROIFormat(camera_id, camera.width as i32, camera.height as i32, 1, ImageType::RAW16 as i32); build_result((), res)?; println!("Set ROI/Format"); |