remove ResultPoint trait uses of Point

Point already has `x` and `y` properties, so accessing
them with `getX()` and `getY()` is needlessly verbose.
These calls have been removed, though the trait impl is
still presen for the time being, since the OneDReader
proc macro requires it.
This commit is contained in:
Vukašin Stepanović
2023-02-16 15:54:07 +00:00
parent 9889555b02
commit 0992e85e6c
16 changed files with 137 additions and 147 deletions

View File

@@ -23,7 +23,7 @@ use crate::{
BitMatrix, DefaultGridSampler, GridSampler, Result,
},
exceptions::Exceptions,
point, Point, ResultPoint,
point, Point,
};
use super::aztec_detector_result::AztecDetectorRXingResult;
@@ -403,10 +403,8 @@ impl<'a> Detector<'_> {
// }
//Compute the center of the rectangle
let mut cx = ((point_a.getX() + point_d.getX() + point_b.getX() + point_c.getX()) / 4.0)
.round() as i32;
let mut cy = ((point_a.getY() + point_d.getY() + point_b.getY() + point_c.getY()) / 4.0)
.round() as i32;
let mut cx = ((point_a.x + point_d.x + point_b.x + point_c.x) / 4.0).round() as i32;
let mut cy = ((point_a.y + point_d.y + point_b.y + point_c.y) / 4.0).round() as i32;
// Redetermine the white rectangle starting from previously computed center.
// This will ensure that we end up with a white rectangle in center bull's eye
@@ -453,10 +451,8 @@ impl<'a> Detector<'_> {
// }
// Recompute the center of the rectangle
cx = ((point_a.getX() + point_d.getX() + point_b.getX() + point_c.getX()) / 4.0).round()
as i32;
cy = ((point_a.getY() + point_d.getY() + point_b.getY() + point_c.getY()) / 4.0).round()
as i32;
cx = ((point_a.x + point_d.x + point_b.x + point_c.x) / 4.0).round() as i32;
cy = ((point_a.y + point_d.y + point_b.y + point_c.y) / 4.0).round() as i32;
AztecPoint::new(cx, cy)
}
@@ -506,14 +502,14 @@ impl<'a> Detector<'_> {
high, // bottomright
low,
high, // bottomleft
top_left.getX(),
top_left.getY(),
top_right.getX(),
top_right.getY(),
bottom_right.getX(),
bottom_right.getY(),
bottom_left.getX(),
bottom_left.getY(),
top_left.x,
top_left.y,
top_right.x,
top_right.y,
bottom_right.x,
bottom_right.y,
bottom_left.x,
bottom_left.y,
)
}
@@ -530,10 +526,10 @@ impl<'a> Detector<'_> {
let d = Self::distance(p1, p2);
let module_size = d / size as f32;
let px = p1.getX();
let py = p1.getY();
let dx = module_size * (p2.getX() - p1.getX()) / d;
let dy = module_size * (p2.getY() - p1.getY()) / d;
let px = p1.x;
let py = p1.y;
let dx = module_size * (p2.x - p1.x) / d;
let dy = module_size * (p2.y - p1.y) / d;
for i in 0..size {
// for (int i = 0; i < size; i++) {
if self.image.get(
@@ -702,8 +698,8 @@ impl<'a> Detector<'_> {
}
fn is_valid(&self, point: Point) -> bool {
let x = point.getX().round() as i32;
let y = point.getY().round() as i32;
let x = point.x.round() as i32;
let y = point.y.round() as i32;
self.is_valid_points(x, y)
}

View File

@@ -19,7 +19,7 @@
use crate::{
common::{BitMatrix, Result},
point, Exceptions, Point, ResultPoint,
point, Exceptions, Point,
};
/**
@@ -74,7 +74,7 @@ impl<'a> MonochromeRectangleDetector<'_> {
bottom,
halfWidth / 2,
)?;
top = (pointA.getY() - 1f32) as i32;
top = (pointA.y - 1f32) as i32;
let pointB = self.findCornerFromCenter(
halfWidth,
-deltaX,
@@ -86,7 +86,7 @@ impl<'a> MonochromeRectangleDetector<'_> {
bottom,
halfHeight / 2,
)?;
left = (pointB.getX() - 1f32) as i32;
left = (pointB.x - 1f32) as i32;
let pointC = self.findCornerFromCenter(
halfWidth,
deltaX,
@@ -98,7 +98,7 @@ impl<'a> MonochromeRectangleDetector<'_> {
bottom,
halfHeight / 2,
)?;
right = (pointC.getX() + 1f32) as i32;
right = (pointC.x + 1f32) as i32;
let pointD = self.findCornerFromCenter(
halfWidth,
0,
@@ -110,7 +110,7 @@ impl<'a> MonochromeRectangleDetector<'_> {
bottom,
halfWidth / 2,
)?;
bottom = (pointD.getY() + 1f32) as i32;
bottom = (pointD.y + 1f32) as i32;
// Go try to find point A again with better information -- might have been off at first.
pointA = self.findCornerFromCenter(

View File

@@ -18,7 +18,7 @@
use crate::{
common::{BitMatrix, Result},
point, Exceptions, Point, ResultPoint,
point, Exceptions, Point,
};
/**
@@ -326,14 +326,14 @@ impl<'a> WhiteRectangleDetector<'_> {
// y y
//
let yi = y.getX();
let yj = y.getY();
let zi = z.getX();
let zj = z.getY();
let xi = x.getX();
let xj = x.getY();
let ti = t.getX();
let tj = t.getY();
let yi = y.x;
let yj = y.y;
let zi = z.x;
let zj = z.y;
let xi = x.x;
let xj = x.y;
let ti = t.x;
let tj = t.y;
if yi < self.width as f32 / 2.0f32 {
[

View File

@@ -18,7 +18,7 @@ use crate::{
common::{
detector::WhiteRectangleDetector, BitMatrix, DefaultGridSampler, GridSampler, Result,
},
point, Exceptions, Point, ResultPoint,
point, Exceptions, Point,
};
use super::DatamatrixDetectorResult;
@@ -102,14 +102,14 @@ impl<'a> Detector<'_> {
}
fn shiftPoint(p: Point, to: Point, div: u32) -> Point {
let x = (to.getX() - p.getX()) / (div as f32 + 1.0);
let y = (to.getY() - p.getY()) / (div as f32 + 1.0);
point(p.getX() + x, p.getY() + y)
let x = (to.x - p.x) / (div as f32 + 1.0);
let y = (to.y - p.y) / (div as f32 + 1.0);
point(p.x + x, p.y + y)
}
fn moveAway(p: Point, fromX: f32, fromY: f32) -> Point {
let mut x = p.getX();
let mut y = p.getY();
let mut x = p.x;
let mut y = p.y;
if x < fromX {
x -= 1.0;
@@ -233,12 +233,12 @@ impl<'a> Detector<'_> {
trRight = self.transitionsBetween(pointCs, pointD);
let candidate1 = point(
pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop as f32 + 1.0),
pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop as f32 + 1.0),
pointD.x + (pointC.x - pointB.x) / (trTop as f32 + 1.0),
pointD.y + (pointC.y - pointB.y) / (trTop as f32 + 1.0),
);
let candidate2 = point(
pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight as f32 + 1.0),
pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight as f32 + 1.0),
pointD.x + (pointA.x - pointB.x) / (trRight as f32 + 1.0),
pointD.y + (pointA.y - pointB.y) / (trRight as f32 + 1.0),
);
if !self.isValid(candidate1) {
@@ -295,8 +295,8 @@ impl<'a> Detector<'_> {
// WhiteRectangleDetector returns points inside of the rectangle.
// I want points on the edges.
let centerX = (pointA.getX() + pointB.getX() + pointC.getX() + pointD.getX()) / 4.0;
let centerY = (pointA.getY() + pointB.getY() + pointC.getY() + pointD.getY()) / 4.0;
let centerX = (pointA.x + pointB.x + pointC.x + pointD.x) / 4.0;
let centerY = (pointA.y + pointB.y + pointC.y + pointD.y) / 4.0;
pointA = Self::moveAway(pointA, centerX, centerY);
pointB = Self::moveAway(pointB, centerX, centerY);
pointC = Self::moveAway(pointC, centerX, centerY);
@@ -319,10 +319,10 @@ impl<'a> Detector<'_> {
}
fn isValid(&self, p: Point) -> bool {
p.getX() >= 0.0
&& p.getX() <= self.image.getWidth() as f32 - 1.0
&& p.getY() > 0.0
&& p.getY() <= self.image.getHeight() as f32 - 1.0
p.x >= 0.0
&& p.x <= self.image.getWidth() as f32 - 1.0
&& p.y > 0.0
&& p.y <= self.image.getHeight() as f32 - 1.0
}
fn sampleGrid(
@@ -348,14 +348,14 @@ impl<'a> Detector<'_> {
dimensionY as f32 - 0.5,
0.5,
dimensionY as f32 - 0.5,
topLeft.getX(),
topLeft.getY(),
topRight.getX(),
topRight.getY(),
bottomRight.getX(),
bottomRight.getY(),
bottomLeft.getX(),
bottomLeft.getY(),
topLeft.x,
topLeft.y,
topRight.x,
topRight.y,
bottomRight.x,
bottomRight.y,
bottomLeft.x,
bottomLeft.y,
)
}
@@ -364,10 +364,10 @@ impl<'a> Detector<'_> {
*/
fn transitionsBetween(&self, from: Point, to: Point) -> u32 {
// See QR Code Detector, sizeOfBlackWhiteBlackRun()
let mut fromX = from.getX().floor() as i32;
let mut fromY = from.getY().floor() as i32;
let mut toX = to.getX().floor() as i32;
let mut toY = (self.image.getHeight() - 1).min(to.getY().floor() as u32) as i32;
let mut fromX = from.x.floor() as i32;
let mut fromY = from.y.floor() as i32;
let mut toX = to.x.floor() as i32;
let mut toY = (self.image.getHeight() - 1).min(to.y.floor() as u32) as i32;
let steep = (toY - fromY).abs() > (toX - fromX).abs();
if steep {

View File

@@ -20,7 +20,7 @@ use crate::{
DatamatrixDetectorResult,
},
qrcode::encoder::ByteMatrix,
Exceptions, Point, ResultPoint,
Exceptions, Point,
};
use super::{DMRegressionLine, EdgeTracer};
@@ -225,14 +225,14 @@ fn Scan(
dimR as f32,
0.0,
dimR as f32,
sourcePoints.topLeft().getX(),
sourcePoints.topLeft().getY(),
sourcePoints.topRight().getX(),
sourcePoints.topRight().getY(),
sourcePoints.bottomRight().getX(),
sourcePoints.bottomRight().getY(),
sourcePoints.bottomLeft().getX(),
sourcePoints.bottomLeft().getY(),
sourcePoints.topLeft().x,
sourcePoints.topLeft().y,
sourcePoints.topRight().x,
sourcePoints.topRight().y,
sourcePoints.bottomRight().x,
sourcePoints.bottomRight().y,
sourcePoints.bottomLeft().x,
sourcePoints.bottomLeft().y,
);
// let res = grid_sampler.sample_grid(startTracer.img, dimT as u32, dimR as u32, &transform);

View File

@@ -17,7 +17,7 @@
use std::collections::HashMap;
use crate::common::Result;
use crate::{point, Exceptions, Point, RXingResult, Reader, ResultPoint};
use crate::{point, Exceptions, Point, RXingResult, Reader};
/**
* This class attempts to decode a barcode from an image, not by scanning the whole image,
@@ -133,7 +133,7 @@ impl<T: Reader> ByQuadrantReader<T> {
// result
points
.iter()
.map(|relative| point(relative.getX() + leftOffset, relative.getY() + topOffset))
.map(|relative| point(relative.x + leftOffset, relative.y + topOffset))
.collect()
}
}

View File

@@ -18,7 +18,7 @@ use std::collections::HashMap;
use crate::{
common::Result, point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point, RXingResult,
Reader, ResultPoint,
Reader,
};
use super::MultipleBarcodeReader;
@@ -115,8 +115,8 @@ impl<T: Reader> GenericMultipleBarcodeReader<T> {
// if (point == null) {
// continue;
// }
let x = point.getX();
let y = point.getY();
let x = point.x;
let y = point.y;
if x < minX {
minX = x;
}
@@ -185,12 +185,7 @@ impl<T: Reader> GenericMultipleBarcodeReader<T> {
let newPoints: Vec<Point> = oldPoints
.iter()
.map(|oldPoint| {
point(
oldPoint.getX() + xOffset as f32,
oldPoint.getY() + yOffset as f32,
)
})
.map(|oldPoint| point(oldPoint.x + xOffset as f32, oldPoint.y + yOffset as f32))
.collect();
// let mut newPoints = Vec::with_capacity(oldPoints.len());

View File

@@ -17,7 +17,7 @@
use crate::{
common::{BitArray, Result},
point, BinaryBitmap, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader, ResultPoint,
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader,
};
/**
@@ -117,8 +117,8 @@ pub trait OneDReader: Reader {
// And remember to flip the result points horizontally.
let points = result.getPointsMut();
if !points.is_empty() && points.len() >= 2 {
points[0] = point(width as f32 - points[0].getX() - 1.0, points[0].getY());
points[1] = point(width as f32 - points[1].getX() - 1.0, points[1].getY());
points[0] = point(width as f32 - points[0].x - 1.0, points[0].y);
points[1] = point(width as f32 - points[1].x - 1.0, points[1].y);
}
}
return Ok(result);

View File

@@ -18,7 +18,7 @@ use std::rc::Rc;
use crate::{
common::{BitMatrix, Result},
point, Exceptions, Point, ResultPoint,
point, Exceptions, Point,
};
/**
@@ -58,13 +58,13 @@ impl BoundingBox {
if leftUnspecified {
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
newBottomRight = bottomRight.ok_or(Exceptions::IllegalStateException(None))?;
newTopLeft = point(0.0, newTopRight.getY());
newBottomLeft = point(0.0, newBottomRight.getY());
newTopLeft = point(0.0, newTopRight.y);
newBottomLeft = point(0.0, newBottomRight.y);
} else if rightUnspecified {
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
newTopRight = point(image.getWidth() as f32 - 1.0, newTopLeft.getY());
newBottomRight = point(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
newTopRight = point(image.getWidth() as f32 - 1.0, newTopLeft.y);
newBottomRight = point(image.getWidth() as f32 - 1.0, newBottomLeft.y);
} else {
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
@@ -74,10 +74,10 @@ impl BoundingBox {
Ok(BoundingBox {
image,
minX: newTopLeft.getX().min(newBottomLeft.getX()) as u32,
maxX: newTopRight.getX().max(newBottomRight.getX()) as u32,
minY: newTopLeft.getY().min(newTopRight.getY()) as u32,
maxY: newBottomLeft.getY().max(newBottomRight.getY()) as u32,
minX: newTopLeft.x.min(newBottomLeft.x) as u32,
maxX: newTopRight.x.max(newBottomRight.x) as u32,
minY: newTopLeft.y.min(newTopRight.y) as u32,
maxY: newBottomLeft.y.max(newBottomRight.y) as u32,
topLeft: newTopLeft,
bottomLeft: newBottomLeft,
topRight: newTopRight,
@@ -140,11 +140,11 @@ impl BoundingBox {
if missingStartRows > 0 {
let top = if isLeft { self.topLeft } else { self.topRight };
let mut newMinY = top.getY() - missingStartRows as f32;
let mut newMinY = top.y - missingStartRows as f32;
if newMinY < 0.0 {
newMinY = 0.0;
}
let newTop = point(top.getX(), newMinY);
let newTop = point(top.x, newMinY);
if isLeft {
newTopLeft = newTop;
} else {
@@ -158,11 +158,11 @@ impl BoundingBox {
} else {
self.bottomRight
};
let mut newMaxY = bottom.getY() as u32 + missingEndRows;
let mut newMaxY = bottom.y as u32 + missingEndRows;
if newMaxY >= self.image.getHeight() {
newMaxY = self.image.getHeight() - 1;
}
let newBottom = point(bottom.getX(), newMaxY as f32);
let newBottom = point(bottom.x, newMaxY as f32);
if isLeft {
newBottomLeft = newBottom;
} else {

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
use crate::{pdf417::pdf_417_common, ResultPoint};
use crate::pdf417::pdf_417_common;
use super::{
BarcodeMetadata, BarcodeValue, Codeword, DetectionRXingResultColumn,
@@ -63,8 +63,8 @@ impl DetectionRXingResultRowIndicatorColumn for DetectionRXingResultColumn {
boundingBox.getBottomRight()
};
let firstRow = self.imageRowToCodewordIndex(top.getY() as u32);
let lastRow = self.imageRowToCodewordIndex(bottom.getY() as u32);
let firstRow = self.imageRowToCodewordIndex(top.y as u32);
let lastRow = self.imageRowToCodewordIndex(bottom.y as u32);
// We need to be careful using the average row height. Barcode could be skewed so that we have smaller and
// taller rows
let averageRowHeight: f64 =
@@ -263,8 +263,8 @@ fn adjustIncompleteIndicatorColumnRowNumbers(
} else {
boundingBox.getBottomRight()
};
let firstRow = col.imageRowToCodewordIndex(top.getY() as u32);
let lastRow = col.imageRowToCodewordIndex(bottom.getY() as u32);
let firstRow = col.imageRowToCodewordIndex(top.y as u32);
let lastRow = col.imageRowToCodewordIndex(bottom.y as u32);
let averageRowHeight: f64 =
(lastRow as f64 - firstRow as f64) / barcodeMetadata.getRowCount() as f64;
let codewords = col.getCodewordsMut();

View File

@@ -19,7 +19,7 @@ use std::rc::Rc;
use crate::{
common::{BitMatrix, DecoderRXingResult, Result},
pdf417::pdf_417_common,
Exceptions, Point, ResultPoint,
Exceptions, Point,
};
use super::{
@@ -368,8 +368,8 @@ fn getRowIndicatorColumn<'a>(
for i in 0..2 {
// for (int i = 0; i < 2; i++) {
let increment: i32 = if i == 0 { 1 } else { -1 };
let mut startColumn: u32 = startPoint.getX() as u32;
let mut imageRow: i32 = startPoint.getY() as i32;
let mut startColumn: u32 = startPoint.x as u32;
let mut imageRow: i32 = startPoint.y as i32;
while imageRow <= boundingBox.getMaxY() as i32 && imageRow >= boundingBox.getMinY() as i32 {
// for (int imageRow = (int) startPoint.getY(); imageRow <= boundingBox.getMaxY() &&
// imageRow >= boundingBox.getMinY(); imageRow += increment) {

View File

@@ -16,7 +16,7 @@
use crate::{
common::{BitMatrix, Result},
point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point, ResultPoint,
point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point,
};
use std::borrow::Cow;
@@ -137,10 +137,10 @@ pub fn detect(multiple: bool, bitMatrix: &BitMatrix) -> Option<Vec<[Option<Point
column = 0;
for barcodeCoordinate in &barcodeCoordinates {
if let Some(coord_1) = barcodeCoordinate[1] {
row = row.max(coord_1.getY() as u32);
row = row.max(coord_1.y as u32);
}
if let Some(coord_3) = barcodeCoordinate[3] {
row = row.max(coord_3.getY() as u32);
row = row.max(coord_3.y as u32);
}
}
row += ROW_STEP;
@@ -154,11 +154,11 @@ pub fn detect(multiple: bool, bitMatrix: &BitMatrix) -> Option<Vec<[Option<Point
// if we didn't find a right row indicator column, then continue the search for the next barcode after the
// start pattern of the barcode just found.
if let Some(vert_2) = vertices[2] {
column = vert_2.getX() as u32;
row = vert_2.getY() as u32;
column = vert_2.x as u32;
row = vert_2.y as u32;
} else {
column = vertices[4].as_ref().unwrap().getX() as u32;
row = vertices[4].as_ref().unwrap().getY() as u32;
column = vertices[4].as_ref().unwrap().x as u32;
row = vertices[4].as_ref().unwrap().y as u32;
}
}
Some(barcodeCoordinates)
@@ -193,8 +193,8 @@ fn findVertices(matrix: &BitMatrix, startRow: u32, startColumn: u32) -> Option<[
);
if let Some(result_4) = result[4] {
startColumn = result_4.getX() as u32;
startRow = result_4.getY() as u32;
startColumn = result_4.x as u32;
startRow = result_4.y as u32;
}
copyToRXingResult(
&mut result,
@@ -258,10 +258,7 @@ fn findRowsWithPattern(
// Last row of the current symbol that contains pattern
if found {
let mut skippedRowCount = 0;
let mut previousRowLoc = [
result[0].as_ref()?.getX() as u32,
result[1].as_ref()?.getX() as u32,
];
let mut previousRowLoc = [result[0].as_ref()?.x as u32, result[1].as_ref()?.x as u32];
while stopRow < height {
if let Some(loc) = findGuardPattern(
matrix,

View File

@@ -19,7 +19,7 @@ use std::collections::HashMap;
use crate::{
common::Result, multi::MultipleBarcodeReader, BarcodeFormat, BinaryBitmap,
DecodingHintDictionary, Exceptions, Point, RXingResult, RXingResultMetadataType,
RXingResultMetadataValue, Reader, ResultPoint,
RXingResultMetadataValue, Reader,
};
use super::{
@@ -153,7 +153,7 @@ impl PDF417Reader {
fn getMaxWidth(p1: &Option<Point>, p2: &Option<Point>) -> u64 {
if let (Some(p1), Some(p2)) = (p1, p2) {
(p1.getX() - p2.getX()).abs() as u64
(p1.x - p2.x).abs() as u64
} else {
0
}
@@ -161,7 +161,7 @@ impl PDF417Reader {
fn getMinWidth(p1: &Option<Point>, p2: &Option<Point>) -> u64 {
if let (Some(p1), Some(p2)) = (p1, p2) {
(p1.getX() - p2.getX()).abs() as u64
(p1.x - p2.x).abs() as u64
} else {
u32::MAX as u64
}

View File

@@ -186,14 +186,14 @@ impl<'a> Detector<'_> {
let sourceBottomRightY: f32;
if alignmentPattern.is_some() {
let alignmentPattern = alignmentPattern?;
bottomRightX = alignmentPattern.getX();
bottomRightY = alignmentPattern.getY();
bottomRightX = alignmentPattern.x;
bottomRightY = alignmentPattern.y;
sourceBottomRightX = dimMinusThree - 3.0;
sourceBottomRightY = sourceBottomRightX;
} else {
// Don't have an alignment pattern, just make up the bottom-right point
bottomRightX = (topRight.getX() - topLeft.getX()) + bottomLeft.getX();
bottomRightY = (topRight.getY() - topLeft.getY()) + bottomLeft.getY();
bottomRightX = (topRight.x - topLeft.x) + bottomLeft.x;
bottomRightY = (topRight.y - topLeft.y) + bottomLeft.y;
sourceBottomRightX = dimMinusThree;
sourceBottomRightY = dimMinusThree;
}
@@ -207,14 +207,14 @@ impl<'a> Detector<'_> {
sourceBottomRightY,
3.5,
dimMinusThree,
topLeft.getX(),
topLeft.getY(),
topRight.getX(),
topRight.getY(),
topLeft.x,
topLeft.y,
topRight.x,
topRight.y,
bottomRightX,
bottomRightY,
bottomLeft.getX(),
bottomLeft.getY(),
bottomLeft.x,
bottomLeft.y,
))
}
@@ -231,7 +231,7 @@ impl<'a> Detector<'_> {
* <p>Computes the dimension (number of modules on a size) of the QR Code based on the position
* of the finder patterns and estimated module size.</p>
*/
fn computeDimension<T: Into<Point>>(
fn computeDimension<T: Into<Point> + Copy>(
topLeft: T,
topRight: T,
bottomLeft: T,
@@ -260,7 +260,7 @@ impl<'a> Detector<'_> {
* @param bottomLeft detected bottom-left finder pattern center
* @return estimated module size
*/
pub fn calculateModuleSize<T: Into<Point>>(
pub fn calculateModuleSize<T: Into<Point> + Copy>(
&self,
topLeft: T,
topRight: T,
@@ -282,16 +282,16 @@ impl<'a> Detector<'_> {
let otherPattern: Point = otherPattern.into();
let moduleSizeEst1 = self.sizeOfBlackWhiteBlackRunBothWays(
pattern.getX().floor() as u32,
pattern.getY().floor() as u32,
otherPattern.getX().floor() as u32,
otherPattern.getY().floor() as u32,
pattern.x.floor() as u32,
pattern.y.floor() as u32,
otherPattern.x.floor() as u32,
otherPattern.y.floor() as u32,
);
let moduleSizeEst2 = self.sizeOfBlackWhiteBlackRunBothWays(
otherPattern.getX().floor() as u32,
otherPattern.getY().floor() as u32,
pattern.getX().floor() as u32,
pattern.getY().floor() as u32,
otherPattern.x.floor() as u32,
otherPattern.y.floor() as u32,
pattern.x.floor() as u32,
pattern.y.floor() as u32,
);
if moduleSizeEst1.is_nan() {
return moduleSizeEst2 / 7.0;

View File

@@ -6,7 +6,7 @@ use crate::Point;
*
* @param patterns array of three {@code Point} to order
*/
pub fn orderBestPatterns<T: Into<Point>>(patterns: &mut [T; 3]) {
pub fn orderBestPatterns<T: Into<Point> + Copy>(patterns: &mut [T; 3]) {
// Find distances between pattern centers
let zeroOneDistance = Point::distance(patterns[0].into(), patterns[1].into());
let oneTwoDistance = Point::distance(patterns[1].into(), patterns[2].into());

View File

@@ -1,11 +1,12 @@
use std::{fmt, iter::Sum};
use crate::ResultPoint;
use std::hash::Hash;
#[cfg(feature = "serde")]
use serde::{Deserialize, Serialize};
use crate::ResultPoint;
/**
* <p>Encapsulates a point of interest in an image containing a barcode. Typically, this
* would be the location of a finder pattern or the corner of the barcode, for example.</p>
@@ -64,6 +65,7 @@ impl<'a> Sum<&'a Point> for Point {
}
}
/** This impl is temporary and is there to ease refactoring. */
impl ResultPoint for Point {
fn getX(&self) -> f32 {
self.x