Add workaround for the non-detectable missing QUIRC support in OpenCV from the Ubuntu 20.04 repo
MODIFY
tests/objdetect.rs
tests/objdetect.rs
use std::path::Path;
use opencv::{
+ core,
imgcodecs,
objdetect,
prelude::*,
@@ -14,16 +15,24 @@ use opencv::{
fn qr_code() -> Result<()> {
let qr_path = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/qr.png");
+ // workaround for the missing (and not runtime detectable) QUIRC support in repository OpenCV in Ubuntu 20.04
+ let objdetect_missing_quirc = cfg!(target_os = "linux") && core::get_build_information()?.contains("/opencv-4.2.0+dfsg/");
+
{
let mut detector = objdetect::QRCodeDetector::default()?;
let src = imgcodecs::imread(qr_path.to_str().unwrap(), imgcodecs::IMREAD_COLOR)?;
let mut pts = VectorOfPoint::new();
let mut straight = Mat::default();
let res = detector.detect_and_decode(&src, &mut pts, &mut straight)?;
- assert_eq!(res, "https://crates.io/crates/opencv");
assert_eq!(4, pts.len());
+ if objdetect_missing_quirc {
+ assert_eq!(res, "");
+ assert!(straight.empty());
+ } else {
+ assert_eq!(res, "https://crates.io/crates/opencv");
assert!(!straight.empty());
}
+ }
{
let mut detector = objdetect::QRCodeDetector::default()?;
@@ -34,9 +43,14 @@ fn qr_code() -> Result<()> {
assert_eq!(4, pts.len());
let mut straight = Mat::default();
let res = detector.decode(&src, &pts, &mut straight)?;
+ if objdetect_missing_quirc {
+ assert_eq!(res, "");
+ assert!(straight.empty());
+ } else {
assert_eq!(res, "https://crates.io/crates/opencv");
assert!(!straight.empty());
}
+ }
#[cfg(ocvrs_opencv_branch_34)] {
let src = imgcodecs::imread(qr_path.to_str().unwrap(), imgcodecs::IMREAD_COLOR)?;

Add workaround for the non-detectable missing QUIRC support in OpenCV from the Ubuntu 20.04 repo