Skip to content

Commit cf1d072

Browse files
committed
use the frame size for the gray image buf
1 parent 77e7533 commit cf1d072

File tree

1 file changed

+2
-5
lines changed

1 file changed

+2
-5
lines changed

cli/src/common/camera.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@ use opencv::{
1010
};
1111
use qr_reader_phone::process_payload::{process_decoded_payload, InProgress, Ready};
1212

13-
// Default camera settings
14-
const DEFAULT_WIDTH: u32 = 640;
15-
const DEFAULT_HEIGHT: u32 = 480;
16-
1713
pub(crate) fn read_qr_file(source_file: &Path) -> anyhow::Result<String> {
1814
let mut camera = create_camera(source_file)?;
1915

@@ -67,7 +63,8 @@ fn camera_capture(camera: &mut videoio::VideoCapture) -> anyhow::Result<GrayImag
6763
Err(e) => bail!("Can`t read camera. {}", e),
6864
};
6965

70-
let mut image: GrayImage = ImageBuffer::new(DEFAULT_WIDTH, DEFAULT_HEIGHT);
66+
let mut image: GrayImage =
67+
ImageBuffer::new(frame.size()?.width as u32, frame.size()?.height as u32);
7168
let mut ocv_gray_image = Mat::default();
7269

7370
cvt_color(&frame, &mut ocv_gray_image, COLOR_BGR2GRAY, 0)?;

0 commit comments

Comments
 (0)