Remove result_point_utils::distance()

This commit is contained in:
Vukašin Stepanović
2023-02-16 12:50:24 +00:00
parent 39b4866e47
commit 3881df6672
7 changed files with 40 additions and 44 deletions

View File

@@ -14,7 +14,7 @@
* limitations under the License.
*/
use crate::{Point, ResultPoint};
use crate::{point, Point, ResultPoint};
/**
* <p>Encapsulates a finder pattern, which are the three square patterns found in
@@ -27,23 +27,20 @@ use crate::{Point, ResultPoint};
pub struct FinderPattern {
estimatedModuleSize: f32,
count: usize,
point: (f32, f32),
point: Point,
}
impl ResultPoint for FinderPattern {
fn getX(&self) -> f32 {
self.point.0
self.point.x
}
fn getY(&self) -> f32 {
self.point.1
self.point.y
}
fn to_rxing_result_point(&self) -> Point {
Point {
x: self.point.0,
y: self.point.1,
}
self.point
}
}
@@ -56,7 +53,7 @@ impl FinderPattern {
Self {
estimatedModuleSize,
count,
point: (posX, posY),
point: point(posX, posY),
}
}

View File

@@ -20,8 +20,8 @@ use crate::{
common::{BitMatrix, DefaultGridSampler, GridSampler, PerspectiveTransform, Result},
point,
qrcode::decoder::Version,
result_point_utils, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Point,
PointCallback, ResultPoint,
DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Point, PointCallback,
ResultPoint,
};
use super::{
@@ -232,10 +232,16 @@ impl<'a> Detector<'_> {
bottomLeft: &T,
moduleSize: f32,
) -> Result<u32> {
let tltrCentersDimension =
(result_point_utils::distance(topLeft, topRight) / moduleSize).round() as i32;
let tlblCentersDimension =
(result_point_utils::distance(topLeft, bottomLeft) / moduleSize).round() as i32;
let tltrCentersDimension = (Point::distance(
topLeft.to_rxing_result_point(),
topRight.to_rxing_result_point(),
) / moduleSize)
.round() as i32;
let tlblCentersDimension = (Point::distance(
topLeft.to_rxing_result_point(),
bottomLeft.to_rxing_result_point(),
) / moduleSize)
.round() as i32;
let mut dimension = ((tltrCentersDimension + tlblCentersDimension) / 2) + 7;
match dimension & 0x03 {
0 => dimension += 1,