keyfork-qrcode: enforce use of MPG1 video streams

This commit is contained in:
Ryan Heywood 2024-02-01 22:29:09 -05:00
parent 60261aa3e9
commit f47d7c92b8
Signed by: ryan
GPG Key ID: 8E401478A3FBEF72
1 changed files with 8 additions and 0 deletions

View File

@ -9,6 +9,8 @@ use std::{
use v4l::{
buffer::Type,
io::{userptr::Stream, traits::CaptureStream},
video::Capture,
FourCC,
Device,
};
@ -100,6 +102,9 @@ pub fn qrencode(
#[cfg(feature = "decode-backend-rqrr")]
pub fn scan_camera(timeout: Duration, index: usize) -> Result<Option<String>, QRCodeScanError> {
let device = Device::new(index)?;
let mut fmt = device.format().expect("Failed to read format");
fmt.fourcc = FourCC::new(b"MPG1");
device.set_format(&fmt)?;
let mut stream = Stream::with_buffers(&device, Type::VideoCapture, 4)?;
let start = SystemTime::now();
@ -128,6 +133,9 @@ pub fn scan_camera(timeout: Duration, index: usize) -> Result<Option<String>, QR
#[cfg(feature = "decode-backend-zbar")]
pub fn scan_camera(timeout: Duration, index: usize) -> Result<Option<String>, QRCodeScanError> {
let device = Device::new(index)?;
let mut fmt = device.format().expect("Failed to read format");
fmt.fourcc = FourCC::new(b"MPG1");
device.set_format(&fmt)?;
let mut stream = Stream::with_buffers(&device, Type::VideoCapture, 4)?;
let start = SystemTime::now();
let mut scanner = keyfork_zbar::image_scanner::ImageScanner::new();