mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
wip: Search & replace RXingResultPoint with Point
Build fails because the OneDReader proc macro expects that a RXingResultPoint type exists.
This commit is contained in:
@@ -18,7 +18,7 @@ use std::rc::Rc;
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
Exceptions, RXingResultPoint, ResultPoint,
|
||||
Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -27,10 +27,10 @@ use crate::{
|
||||
#[derive(Clone)]
|
||||
pub struct BoundingBox {
|
||||
image: Rc<BitMatrix>,
|
||||
topLeft: RXingResultPoint,
|
||||
bottomLeft: RXingResultPoint,
|
||||
topRight: RXingResultPoint,
|
||||
bottomRight: RXingResultPoint,
|
||||
topLeft: Point,
|
||||
bottomLeft: Point,
|
||||
topRight: Point,
|
||||
bottomRight: Point,
|
||||
minX: u32,
|
||||
maxX: u32,
|
||||
minY: u32,
|
||||
@@ -39,10 +39,10 @@ pub struct BoundingBox {
|
||||
impl BoundingBox {
|
||||
pub fn new(
|
||||
image: Rc<BitMatrix>,
|
||||
topLeft: Option<RXingResultPoint>,
|
||||
bottomLeft: Option<RXingResultPoint>,
|
||||
topRight: Option<RXingResultPoint>,
|
||||
bottomRight: Option<RXingResultPoint>,
|
||||
topLeft: Option<Point>,
|
||||
bottomLeft: Option<Point>,
|
||||
topRight: Option<Point>,
|
||||
bottomRight: Option<Point>,
|
||||
) -> Result<BoundingBox> {
|
||||
let leftUnspecified = topLeft.is_none() || bottomLeft.is_none();
|
||||
let rightUnspecified = topRight.is_none() || bottomRight.is_none();
|
||||
@@ -58,14 +58,14 @@ impl BoundingBox {
|
||||
if leftUnspecified {
|
||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomRight = bottomRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopLeft = RXingResultPoint::new(0.0, newTopRight.getY());
|
||||
newBottomLeft = RXingResultPoint::new(0.0, newBottomRight.getY());
|
||||
newTopLeft = Point::new(0.0, newTopRight.getY());
|
||||
newBottomLeft = Point::new(0.0, newBottomRight.getY());
|
||||
} else if rightUnspecified {
|
||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopRight = RXingResultPoint::new(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
||||
newTopRight = Point::new(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
||||
newBottomRight =
|
||||
RXingResultPoint::new(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
||||
Point::new(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
||||
} else {
|
||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
@@ -145,7 +145,7 @@ impl BoundingBox {
|
||||
if newMinY < 0.0 {
|
||||
newMinY = 0.0;
|
||||
}
|
||||
let newTop = RXingResultPoint::new(top.getX(), newMinY);
|
||||
let newTop = Point::new(top.getX(), newMinY);
|
||||
if isLeft {
|
||||
newTopLeft = newTop;
|
||||
} else {
|
||||
@@ -163,7 +163,7 @@ impl BoundingBox {
|
||||
if newMaxY >= self.image.getHeight() {
|
||||
newMaxY = self.image.getHeight() - 1;
|
||||
}
|
||||
let newBottom = RXingResultPoint::new(bottom.getX(), newMaxY as f32);
|
||||
let newBottom = Point::new(bottom.getX(), newMaxY as f32);
|
||||
if isLeft {
|
||||
newBottomLeft = newBottom;
|
||||
} else {
|
||||
@@ -196,19 +196,19 @@ impl BoundingBox {
|
||||
self.maxY
|
||||
}
|
||||
|
||||
pub fn getTopLeft(&self) -> &RXingResultPoint {
|
||||
pub fn getTopLeft(&self) -> &Point {
|
||||
&self.topLeft
|
||||
}
|
||||
|
||||
pub fn getTopRight(&self) -> &RXingResultPoint {
|
||||
pub fn getTopRight(&self) -> &Point {
|
||||
&self.topRight
|
||||
}
|
||||
|
||||
pub fn getBottomLeft(&self) -> &RXingResultPoint {
|
||||
pub fn getBottomLeft(&self) -> &Point {
|
||||
&self.bottomLeft
|
||||
}
|
||||
|
||||
pub fn getBottomRight(&self) -> &RXingResultPoint {
|
||||
pub fn getBottomRight(&self) -> &Point {
|
||||
&self.bottomRight
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::rc::Rc;
|
||||
use crate::{
|
||||
common::{BitMatrix, DecoderRXingResult, Result},
|
||||
pdf417::pdf_417_common,
|
||||
Exceptions, RXingResultPoint, ResultPoint,
|
||||
Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
use super::{
|
||||
@@ -44,10 +44,10 @@ const MAX_EC_CODEWORDS: u32 = 512;
|
||||
// than it should be. This can happen if the scanner used a bad blackpoint.
|
||||
pub fn decode(
|
||||
image: &BitMatrix,
|
||||
imageTopLeft: Option<RXingResultPoint>,
|
||||
imageBottomLeft: Option<RXingResultPoint>,
|
||||
imageTopRight: Option<RXingResultPoint>,
|
||||
imageBottomRight: Option<RXingResultPoint>,
|
||||
imageTopLeft: Option<Point>,
|
||||
imageBottomLeft: Option<Point>,
|
||||
imageTopRight: Option<Point>,
|
||||
imageBottomRight: Option<Point>,
|
||||
minCodewordWidth: u32,
|
||||
maxCodewordWidth: u32,
|
||||
) -> Result<DecoderRXingResult> {
|
||||
@@ -358,7 +358,7 @@ fn getBarcodeMetadata<T: DetectionRXingResultRowIndicatorColumn>(
|
||||
fn getRowIndicatorColumn<'a>(
|
||||
image: &BitMatrix,
|
||||
boundingBox: Rc<BoundingBox>,
|
||||
startPoint: RXingResultPoint,
|
||||
startPoint: Point,
|
||||
leftToRight: bool,
|
||||
minCodewordWidth: u32,
|
||||
maxCodewordWidth: u32,
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
BinaryBitmap, DecodingHintDictionary, Exceptions, RXingResultPoint, ResultPoint,
|
||||
BinaryBitmap, DecodingHintDictionary, Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
use std::borrow::Cow;
|
||||
@@ -116,10 +116,10 @@ fn applyRotation(matrix: &BitMatrix, rotation: u32) -> Result<Cow<BitMatrix>> {
|
||||
* @param multiple if true, then the image is searched for multiple codes. If false, then at most one code will
|
||||
* be found and returned
|
||||
* @param bitMatrix bit matrix to detect barcodes in
|
||||
* @return List of RXingResultPoint arrays containing the coordinates of found barcodes
|
||||
* @return List of Point arrays containing the coordinates of found barcodes
|
||||
*/
|
||||
pub fn detect(multiple: bool, bitMatrix: &BitMatrix) -> Option<Vec<[Option<RXingResultPoint>; 8]>> {
|
||||
let mut barcodeCoordinates: Vec<[Option<RXingResultPoint>; 8]> = Vec::new();
|
||||
pub fn detect(multiple: bool, bitMatrix: &BitMatrix) -> Option<Vec<[Option<Point>; 8]>> {
|
||||
let mut barcodeCoordinates: Vec<[Option<Point>; 8]> = Vec::new();
|
||||
let mut row = 0;
|
||||
let mut column = 0;
|
||||
let mut foundBarcodeInRow = false;
|
||||
@@ -183,13 +183,13 @@ fn findVertices(
|
||||
matrix: &BitMatrix,
|
||||
startRow: u32,
|
||||
startColumn: u32,
|
||||
) -> Option<[Option<RXingResultPoint>; 8]> {
|
||||
) -> Option<[Option<Point>; 8]> {
|
||||
let height = matrix.getHeight();
|
||||
let width = matrix.getWidth();
|
||||
let mut startRow = startRow;
|
||||
let mut startColumn = startColumn;
|
||||
|
||||
let mut result = [None::<RXingResultPoint>; 8]; //RXingResultPoint[8];
|
||||
let mut result = [None::<Point>; 8]; //Point[8];
|
||||
copyToRXingResult(
|
||||
&mut result,
|
||||
&findRowsWithPattern(matrix, height, width, startRow, startColumn, &START_PATTERN)?,
|
||||
@@ -210,8 +210,8 @@ fn findVertices(
|
||||
}
|
||||
|
||||
fn copyToRXingResult(
|
||||
result: &mut [Option<RXingResultPoint>],
|
||||
tmpRXingResult: &[Option<RXingResultPoint>],
|
||||
result: &mut [Option<Point>],
|
||||
tmpRXingResult: &[Option<Point>],
|
||||
destinationIndexes: &[u32],
|
||||
) {
|
||||
for i in 0..destinationIndexes.len() {
|
||||
@@ -226,7 +226,7 @@ fn findRowsWithPattern(
|
||||
startRow: u32,
|
||||
startColumn: u32,
|
||||
pattern: &[u32],
|
||||
) -> Option<[Option<RXingResultPoint>; 4]> {
|
||||
) -> Option<[Option<Point>; 4]> {
|
||||
let mut startRow = startRow;
|
||||
let mut result = [None; 4];
|
||||
let mut found = false;
|
||||
@@ -249,11 +249,11 @@ fn findRowsWithPattern(
|
||||
break;
|
||||
}
|
||||
}
|
||||
result[0] = Some(RXingResultPoint::new(
|
||||
result[0] = Some(Point::new(
|
||||
loc_store.as_ref()?[0] as f32,
|
||||
startRow as f32,
|
||||
));
|
||||
result[1] = Some(RXingResultPoint::new(
|
||||
result[1] = Some(Point::new(
|
||||
loc_store.as_ref()?[1] as f32,
|
||||
startRow as f32,
|
||||
));
|
||||
@@ -304,11 +304,11 @@ fn findRowsWithPattern(
|
||||
stopRow += 1;
|
||||
}
|
||||
stopRow -= skippedRowCount + 1;
|
||||
result[2] = Some(RXingResultPoint::new(
|
||||
result[2] = Some(Point::new(
|
||||
previousRowLoc[0] as f32,
|
||||
stopRow as f32,
|
||||
));
|
||||
result[3] = Some(RXingResultPoint::new(
|
||||
result[3] = Some(Point::new(
|
||||
previousRowLoc[1] as f32,
|
||||
stopRow as f32,
|
||||
));
|
||||
|
||||
@@ -14,21 +14,21 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use crate::{common::BitMatrix, RXingResultPoint};
|
||||
use crate::{common::BitMatrix, Point};
|
||||
|
||||
/**
|
||||
* @author Guenther Grau
|
||||
*/
|
||||
pub struct PDF417DetectorRXingResult {
|
||||
bits: BitMatrix,
|
||||
points: Vec<[Option<RXingResultPoint>; 8]>,
|
||||
points: Vec<[Option<Point>; 8]>,
|
||||
rotation: u32,
|
||||
}
|
||||
|
||||
impl PDF417DetectorRXingResult {
|
||||
pub fn with_rotation(
|
||||
bits: BitMatrix,
|
||||
points: Vec<[Option<RXingResultPoint>; 8]>,
|
||||
points: Vec<[Option<Point>; 8]>,
|
||||
rotation: u32,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -38,7 +38,7 @@ impl PDF417DetectorRXingResult {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(bits: BitMatrix, points: Vec<[Option<RXingResultPoint>; 8]>) -> Self {
|
||||
pub fn new(bits: BitMatrix, points: Vec<[Option<Point>; 8]>) -> Self {
|
||||
Self::with_rotation(bits, points, 0)
|
||||
}
|
||||
|
||||
@@ -46,7 +46,7 @@ impl PDF417DetectorRXingResult {
|
||||
&self.bits
|
||||
}
|
||||
|
||||
pub fn getPoints(&self) -> &Vec<[Option<RXingResultPoint>; 8]> {
|
||||
pub fn getPoints(&self) -> &Vec<[Option<Point>; 8]> {
|
||||
&self.points
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::collections::HashMap;
|
||||
use crate::{
|
||||
common::Result, multi::MultipleBarcodeReader, BarcodeFormat, BinaryBitmap,
|
||||
DecodingHintDictionary, Exceptions, RXingResult, RXingResultMetadataType,
|
||||
RXingResultMetadataValue, RXingResultPoint, Reader, ResultPoint,
|
||||
RXingResultMetadataValue, Point, Reader, ResultPoint,
|
||||
};
|
||||
|
||||
use super::{
|
||||
@@ -151,7 +151,7 @@ impl PDF417Reader {
|
||||
Ok(results)
|
||||
}
|
||||
|
||||
fn getMaxWidth(p1: &Option<RXingResultPoint>, p2: &Option<RXingResultPoint>) -> u64 {
|
||||
fn getMaxWidth(p1: &Option<Point>, p2: &Option<Point>) -> u64 {
|
||||
if let (Some(p1), Some(p2)) = (p1, p2) {
|
||||
(p1.getX() - p2.getX()).abs() as u64
|
||||
} else {
|
||||
@@ -159,7 +159,7 @@ impl PDF417Reader {
|
||||
}
|
||||
}
|
||||
|
||||
fn getMinWidth(p1: &Option<RXingResultPoint>, p2: &Option<RXingResultPoint>) -> u64 {
|
||||
fn getMinWidth(p1: &Option<Point>, p2: &Option<Point>) -> u64 {
|
||||
if let (Some(p1), Some(p2)) = (p1, p2) {
|
||||
(p1.getX() - p2.getX()).abs() as u64
|
||||
} else {
|
||||
@@ -167,7 +167,7 @@ impl PDF417Reader {
|
||||
}
|
||||
}
|
||||
|
||||
fn getMaxCodewordWidth(p: &[Option<RXingResultPoint>]) -> u32 {
|
||||
fn getMaxCodewordWidth(p: &[Option<Point>]) -> u32 {
|
||||
Self::getMaxWidth(&p[0], &p[4])
|
||||
.max(
|
||||
Self::getMaxWidth(&p[6], &p[2]) * pdf_417_common::MODULES_IN_CODEWORD as u64
|
||||
@@ -179,7 +179,7 @@ impl PDF417Reader {
|
||||
)) as u32
|
||||
}
|
||||
|
||||
fn getMinCodewordWidth(p: &[Option<RXingResultPoint>]) -> u32 {
|
||||
fn getMinCodewordWidth(p: &[Option<Point>]) -> u32 {
|
||||
Self::getMinWidth(&p[0], &p[4])
|
||||
.min(
|
||||
Self::getMinWidth(&p[6], &p[2]) * pdf_417_common::MODULES_IN_CODEWORD as u64
|
||||
|
||||
Reference in New Issue
Block a user