Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

use the frame size for the gray image buf #829

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 2 additions & 5 deletions cli/src/common/camera.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ use opencv::{
};
use qr_reader_phone::process_payload::{process_decoded_payload, InProgress, Ready};

// Default camera settings
const DEFAULT_WIDTH: u32 = 640;
const DEFAULT_HEIGHT: u32 = 480;

pub(crate) fn read_qr_file(source_file: &Path) -> anyhow::Result<String> {
let mut camera = create_camera(source_file)?;

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

let mut image: GrayImage = ImageBuffer::new(DEFAULT_WIDTH, DEFAULT_HEIGHT);
let mut image: GrayImage =
ImageBuffer::new(frame.size()?.width as u32, frame.size()?.height as u32);
let mut ocv_gray_image = Mat::default();

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