wip: Search & replace RXingResultPoint with Point

Build fails because the OneDReader proc macro expects
that a RXingResultPoint type exists.
This commit is contained in:
Vukašin Stepanović
2023-02-16 08:25:32 +00:00
parent 15280d5f98
commit dbc6ca4e55
57 changed files with 476 additions and 476 deletions

View File

@@ -17,7 +17,7 @@
use std::collections::HashMap;
use crate::common::Result;
use crate::{Exceptions, RXingResult, RXingResultPoint, Reader, ResultPoint};
use crate::{Exceptions, RXingResult, Point, Reader, ResultPoint};
/**
* This class attempts to decode a barcode from an image, not by scanning the whole image,
@@ -61,7 +61,7 @@ impl<T: Reader> Reader for ByQuadrantReader<T> {
// This is a match because only NotFoundExceptions should be ignored
match result {
Ok(res) => {
let points = Self::makeAbsolute(res.getRXingResultPoints(), halfWidth as f32, 0.0);
let points = Self::makeAbsolute(res.getPoints(), halfWidth as f32, 0.0);
return Ok(RXingResult::new_from_existing_result(res, points));
}
Err(Exceptions::NotFoundException(_)) => {}
@@ -74,7 +74,7 @@ impl<T: Reader> Reader for ByQuadrantReader<T> {
// This is a match because only NotFoundExceptions should be ignored
match result {
Ok(res) => {
let points = Self::makeAbsolute(res.getRXingResultPoints(), 0.0, halfHeight as f32);
let points = Self::makeAbsolute(res.getPoints(), 0.0, halfHeight as f32);
return Ok(RXingResult::new_from_existing_result(res, points));
}
Err(Exceptions::NotFoundException(_)) => {}
@@ -89,7 +89,7 @@ impl<T: Reader> Reader for ByQuadrantReader<T> {
match result {
Ok(res) => {
let points = Self::makeAbsolute(
res.getRXingResultPoints(),
res.getPoints(),
halfWidth as f32,
halfHeight as f32,
);
@@ -105,7 +105,7 @@ impl<T: Reader> Reader for ByQuadrantReader<T> {
let result = self.0.decode_with_hints(&mut center, hints)?;
let points = Self::makeAbsolute(
result.getRXingResultPoints(),
result.getPoints(),
quarterWidth as f32,
quarterHeight as f32,
);
@@ -123,15 +123,15 @@ impl<T: Reader> ByQuadrantReader<T> {
}
fn makeAbsolute(
points: &[RXingResultPoint],
points: &[Point],
leftOffset: f32,
topOffset: f32,
) -> Vec<RXingResultPoint> {
) -> Vec<Point> {
// let mut result = Vec::new();
// if !points.is_empty() {
// // for relative in points {
// // result.push(RXingResultPoint::new(
// // result.push(Point::new(
// // relative.getX() + leftOffset,
// // relative.getY() + topOffset,
// // ));
@@ -141,7 +141,7 @@ impl<T: Reader> ByQuadrantReader<T> {
points
.iter()
.map(|relative| {
RXingResultPoint::new(relative.getX() + leftOffset, relative.getY() + topOffset)
Point::new(relative.getX() + leftOffset, relative.getY() + topOffset)
})
.collect()
}

View File

@@ -18,7 +18,7 @@ use std::collections::HashMap;
use crate::{
common::Result, BinaryBitmap, DecodingHintDictionary, Exceptions, RXingResult,
RXingResultPoint, Reader, ResultPoint,
Point, Reader, ResultPoint,
};
use super::MultipleBarcodeReader;
@@ -26,7 +26,7 @@ use super::MultipleBarcodeReader;
/**
* <p>Attempts to locate multiple barcodes in an image by repeatedly decoding portion of the image.
* After one barcode is found, the areas left, above, right and below the barcode's
* {@link RXingResultPoint}s are scanned, recursively.</p>
* {@link Point}s are scanned, recursively.</p>
*
* <p>A caller may want to also employ {@link ByQuadrantReader} when attempting to find multiple
* 2D barcodes, like QR Codes, in an image, where the presence of multiple barcodes might prevent
@@ -95,10 +95,10 @@ impl<T: Reader> GenericMultipleBarcodeReader<T> {
}
}
let resultPoints = result.getRXingResultPoints().clone();
let resultPoints = result.getPoints().clone();
if !alreadyFound {
results.push(Self::translateRXingResultPoints(result, xOffset, yOffset));
results.push(Self::translatePoints(result, xOffset, yOffset));
}
if resultPoints.is_empty() {
@@ -177,25 +177,25 @@ impl<T: Reader> GenericMultipleBarcodeReader<T> {
}
}
fn translateRXingResultPoints(result: RXingResult, xOffset: u32, yOffset: u32) -> RXingResult {
let oldRXingResultPoints = result.getRXingResultPoints();
if oldRXingResultPoints.is_empty() {
fn translatePoints(result: RXingResult, xOffset: u32, yOffset: u32) -> RXingResult {
let oldPoints = result.getPoints();
if oldPoints.is_empty() {
return result;
}
let newRXingResultPoints: Vec<RXingResultPoint> = oldRXingResultPoints
let newPoints: Vec<Point> = oldPoints
.iter()
.map(|oldPoint| {
RXingResultPoint::new(
Point::new(
oldPoint.getX() + xOffset as f32,
oldPoint.getY() + yOffset as f32,
)
})
.collect();
// let mut newRXingResultPoints = Vec::with_capacity(oldRXingResultPoints.len());
// for oldPoint in oldRXingResultPoints {
// newRXingResultPoints.push(RXingResultPoint::new(
// let mut newPoints = Vec::with_capacity(oldPoints.len());
// for oldPoint in oldPoints {
// newPoints.push(Point::new(
// oldPoint.getX() + xOffset as f32,
// oldPoint.getY() + yOffset as f32,
// ));
@@ -204,7 +204,7 @@ impl<T: Reader> GenericMultipleBarcodeReader<T> {
result.getText(),
result.getRawBytes().clone(),
result.getNumBits(),
newRXingResultPoints,
newPoints,
*result.getBarcodeFormat(),
result.getTimestamp(),
);

View File

@@ -20,7 +20,7 @@ use crate::{
common::{BitMatrix, Result},
qrcode::detector::{FinderPattern, FinderPatternFinder, FinderPatternInfo},
result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions,
RXingResultPointCallback,
PointCallback,
};
// max. legal count of modules per QR code edge (177)
@@ -68,7 +68,7 @@ impl<'a> MultiFinderPatternFinder<'_> {
pub fn new(
image: &'a BitMatrix,
resultPointCallback: Option<RXingResultPointCallback>,
resultPointCallback: Option<PointCallback>,
) -> MultiFinderPatternFinder<'a> {
MultiFinderPatternFinder(FinderPatternFinder::with_callback(
image,