Add error reporting to tests

This commit is contained in:
Steve Cook
2023-03-02 00:06:30 -05:00
parent 70b1ef270f
commit d2ab7de5dd
5 changed files with 52 additions and 35 deletions

View File

@@ -119,22 +119,20 @@ impl MultiFormatReader {
&mut self,
image: &mut BinaryBitmap<B>,
) -> Result<RXingResult> {
if !self.possible_formats.is_empty() {
let res = self.decode_formats(image);
if res.is_ok() {
return res;
}
if matches!(
self.hints.get(&DecodeHintType::ALSO_INVERTED),
Some(DecodeHintValue::AlsoInverted(true))
) {
// Calling all readers again with inverted image
image.get_black_matrix_mut().flip_self();
let res = self.decode_formats(image);
if res.is_ok() {
return res;
}
if matches!(
self.hints.get(&DecodeHintType::ALSO_INVERTED),
Some(DecodeHintValue::AlsoInverted(true))
) {
// Calling all readers again with inverted image
image.get_black_matrix_mut().flip_self();
let res = self.decode_formats(image);
if res.is_ok() {
return res;
}
}
}
Err(Exceptions::NOT_FOUND)
}

View File

@@ -105,8 +105,8 @@ pub trait OneDReader: Reader {
}
}
let Ok(mut result) = self.decode_row(row_number as u32, &row, &hints) else {
continue
};
continue
};
// We found our barcode
if attempt == 1 {
// But it was upside down, so note that

View File

@@ -28,7 +28,9 @@ use std::rc::Rc;
use image::DynamicImage;
use crate::{common::GlobalHistogramBinarizer, BinaryBitmap, BufferedImageLuminanceSource, Binarizer};
use crate::{
common::GlobalHistogramBinarizer, Binarizer, BinaryBitmap, BufferedImageLuminanceSource,
};
fn getBufferedImage(fileName: &str) -> DynamicImage {
let path = format!("test_resources/blackbox/rssexpandedstacked-2/{fileName}");
@@ -36,7 +38,9 @@ fn getBufferedImage(fileName: &str) -> DynamicImage {
image::open(path).expect("load image")
}
pub(crate) fn getBinaryBitmap(fileName: &str) -> BinaryBitmap<GlobalHistogramBinarizer<BufferedImageLuminanceSource>> {
pub(crate) fn getBinaryBitmap(
fileName: &str,
) -> BinaryBitmap<GlobalHistogramBinarizer<BufferedImageLuminanceSource>> {
let bufferedImage = getBufferedImage(fileName);
BinaryBitmap::new(GlobalHistogramBinarizer::new(