From 9b47d53f4b1bd07c9fff194d68868e7d3061bd85 Mon Sep 17 00:00:00 2001 From: Henry Schimke Date: Mon, 10 Oct 2022 16:28:37 -0500 Subject: [PATCH] checkin --- .../detector/alignment_pattern_finder.rs | 18 +++++++++--------- tests/common/abstract_black_box_test_case.rs | 16 ++++++++-------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/qrcode/detector/alignment_pattern_finder.rs b/src/qrcode/detector/alignment_pattern_finder.rs index 1f26b3f..45e9985 100644 --- a/src/qrcode/detector/alignment_pattern_finder.rs +++ b/src/qrcode/detector/alignment_pattern_finder.rs @@ -172,7 +172,7 @@ impl AlignmentPatternFinder { * figures the location of the center of this black/white/black run. */ fn centerFromEnd(stateCount: &[u32], end: u32) -> f32 { - (end - stateCount[2]) as f32 - stateCount[1] as f32 / 2.0 + (end as f32 - stateCount[2] as f32) - stateCount[1] as f32 / 2.0 } /** @@ -219,8 +219,8 @@ impl AlignmentPatternFinder { self.crossCheckStateCount[2] = 0; // Start counting up from center - let mut i = startI; - while i >= 0 && image.get(centerJ, i) && self.crossCheckStateCount[1] <= maxCount { + let mut i = startI as i32; + while i >= 0 && image.get(centerJ, i as u32) && self.crossCheckStateCount[1] <= maxCount { self.crossCheckStateCount[1] += 1; i -= 1; } @@ -228,7 +228,7 @@ impl AlignmentPatternFinder { if i < 0 || self.crossCheckStateCount[1] > maxCount { return f32::NAN; } - while i >= 0 && !image.get(centerJ, i) && self.crossCheckStateCount[0] <= maxCount { + while i >= 0 && !image.get(centerJ, i as u32) && self.crossCheckStateCount[0] <= maxCount { self.crossCheckStateCount[0] += 1; i -= 1; } @@ -237,15 +237,15 @@ impl AlignmentPatternFinder { } // Now also count down from center - i = startI + 1; - while i < maxI && image.get(centerJ, i) && self.crossCheckStateCount[1] <= maxCount { + i = startI as i32+ 1; + while i < maxI as i32 && image.get(centerJ, i as u32) && self.crossCheckStateCount[1] <= maxCount { self.crossCheckStateCount[1] += 1; i += 1; } - if i == maxI || self.crossCheckStateCount[1] > maxCount { + if i == maxI as i32 || self.crossCheckStateCount[1] > maxCount { return f32::NAN; } - while i < maxI && !image.get(centerJ, i) && self.crossCheckStateCount[2] <= maxCount { + while i < maxI as i32 && !image.get(centerJ, i as u32) && self.crossCheckStateCount[2] <= maxCount { self.crossCheckStateCount[2] += 1; i += 1; } @@ -263,7 +263,7 @@ impl AlignmentPatternFinder { } if self.foundPatternCross(&self.crossCheckStateCount) { - Self::centerFromEnd(&self.crossCheckStateCount, i) + Self::centerFromEnd(&self.crossCheckStateCount, i as u32) } else { f32::NAN } diff --git a/tests/common/abstract_black_box_test_case.rs b/tests/common/abstract_black_box_test_case.rs index b232f68..bb1d1a9 100644 --- a/tests/common/abstract_black_box_test_case.rs +++ b/tests/common/abstract_black_box_test_case.rs @@ -235,14 +235,14 @@ impl AbstractBlackBoxTestCase { let source = BufferedImageLuminanceSource::new(rotated_image); let bitmap = BinaryBitmap::new(Box::new(HybridBinarizer::new(Box::new(source)))); - #[cfg(test)] - if file_base_name == "13" { - let mut f = File::create("test_file_output.txt").unwrap(); - dbg!("dumb"); - write!(f,"{}", bitmap.getBlackMatrix().unwrap()); - drop(f); - Self::rotate_image(&image, rotation).save("test_image.png").unwrap(); - } + // #[cfg(test)] + // if file_base_name == "13" { + // let mut f = File::create("test_file_output.txt").unwrap(); + // dbg!("dumb"); + // write!(f,"{}", bitmap.getBlackMatrix().unwrap()); + // drop(f); + // Self::rotate_image(&image, rotation).save("test_image.png").unwrap(); + // } if let Ok(decoded) = self.decode(&bitmap, rotation, &expected_text, &expected_metadata, false)