mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
slight performance improvement, detector
This commit is contained in:
@@ -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,
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
@@ -15,4 +15,4 @@ pub use finder_pattern_info::*;
|
||||
pub use qrcode_detector_result::*;
|
||||
|
||||
#[cfg(test)]
|
||||
mod cetector_test;
|
||||
mod detector_test;
|
||||
|
||||
@@ -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();
|
||||
|
||||
Reference in New Issue
Block a user