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

@@ -77,7 +77,7 @@ impl Reader for DataMatrixReader {
decoderRXingResult = DECODER.decode(&bits)?;
points.clear();
} else {
let detectorRXingResult = Detector::new(image.getBlackMatrix().clone())?.detect()?;
let detectorRXingResult = Detector::new(image.getBlackMatrix())?.detect()?;
decoderRXingResult = DECODER.decode(detectorRXingResult.getBits())?;
points = detectorRXingResult.getPoints().clone();
}

View File

@@ -27,14 +27,14 @@ use super::DatamatrixDetectorResult;
*
* @author Sean Owen
*/
pub struct Detector {
image: BitMatrix,
pub struct Detector<'a> {
image: &'a BitMatrix,
rectangleDetector: WhiteRectangleDetector,
}
impl Detector {
pub fn new(image: BitMatrix) -> Result<Self, Exceptions> {
Ok(Self {
rectangleDetector: WhiteRectangleDetector::new_from_image(&image)?,
impl<'a> Detector<'_> {
pub fn new(image: &'a BitMatrix) -> Result<Detector<'a>, Exceptions> {
Ok(Detector {
rectangleDetector: WhiteRectangleDetector::new_from_image(image)?,
image,
})
}