mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
Add error reporting to tests
This commit is contained in:
@@ -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)
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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(
|
||||
|
||||
Reference in New Issue
Block a user