slight performance improvement, detector

This commit is contained in:
Henry Schimke
2022-12-31 17:01:10 -06:00
parent a111776032
commit a6727220fa
11 changed files with 31 additions and 30 deletions

View File

@@ -36,14 +36,14 @@ use super::{
*
* @author Sean Owen
*/
pub struct Detector {
image: BitMatrix,
pub struct Detector<'a> {
image: &'a BitMatrix,
resultPointCallback: Option<RXingResultPointCallback>,
}
impl Detector {
pub fn new(image: BitMatrix) -> Self {
Self {
impl<'a> Detector<'_> {
pub fn new(image: &'a BitMatrix) -> Detector<'a> {
Detector {
image,
resultPointCallback: None,
}

View File

@@ -32,7 +32,8 @@ fn test_encode_decode(value: &str) {
let byt_matrix = qr_code.getMatrix().as_ref().unwrap().clone();
// dbg!(BitMatrix::from(byt_matrix.clone()).to_string());
// let mut detector = Detector::new(make_larger(&byt_matrix.into(),5));
let mut detector = Detector::new(byt_matrix.into());
let new_matrix : &BitMatrix = &byt_matrix.into();
let mut detector = Detector::new(new_matrix);
let detected_points = detector.detect().expect("must detect");
let decoded = decoder::decode_bitmatrix(detected_points.getBits()).expect("must decode");
assert_eq!(decoded.getText(), value);

View File

@@ -15,4 +15,4 @@ pub use finder_pattern_info::*;
pub use qrcode_detector_result::*;
#[cfg(test)]
mod cetector_test;
mod detector_test;

View File

@@ -67,7 +67,7 @@ impl Reader for QRCodeReader {
points = Vec::new();
} else {
let detectorRXingResult =
Detector::new(image.getBlackMatrix().clone()).detect_with_hints(&hints)?;
Detector::new(image.getBlackMatrix()).detect_with_hints(&hints)?;
decoderRXingResult =
decoder::decode_bitmatrix_with_hints(detectorRXingResult.getBits(), &hints)?;
points = detectorRXingResult.getPoints().clone();