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

@@ -20,7 +20,6 @@ use crate::{
DatamatrixDetectorResult,
},
qrcode::encoder::ByteMatrix,
result_point_utils::distance,
Exceptions, Point, ResultPoint,
};
@@ -101,8 +100,8 @@ fn Scan(
let right = *t.front();
CHECK!(t.traceCorner(&mut t.left(), &mut br)?);
let lenL = distance(&tl, &bl) - 1.0;
let lenB = distance(&bl, &br) - 1.0;
let lenL = Point::distance(tl, bl) - 1.0;
let lenB = Point::distance(bl, br) - 1.0;
CHECK!(lenL >= 8.0 && lenB >= 10.0 && lenB >= lenL / 4.0 && lenB <= lenL * 18.0);
let mut maxStepSize: i32 = (lenB / 5.0 + 1.0) as i32; // datamatrix bottom dim is at least 10
@@ -129,8 +128,8 @@ fn Scan(
CHECK!(t.traceGaps(t.left(), lineR, maxStepSize, lineT)?);
CHECK!(t.traceCorner(&mut t.left(), &mut tr)?);
let lenT = distance(&tl, &tr) - 1.0;
let lenR = distance(&tr, &br) - 1.0;
let lenT = Point::distance(tl, tr) - 1.0;
let lenR = Point::distance(tr, br) - 1.0;
CHECK!(
(lenT - lenB).abs() / lenB < 0.5

View File

@@ -252,7 +252,7 @@ impl DMRegressionLine {
// calculate the distance between the points projected onto the regression line
for i in 1..self.points.len() {
// for (size_t i = 1; i < _points.size(); ++i)
gapSizes.push(self.distance(
gapSizes.push(Point::distance(
self.project(self.points[i]),
self.project(self.points[i - 1]),
) as f64);
@@ -273,7 +273,7 @@ impl DMRegressionLine {
// calculate the width of 2 modules (first black pixel to first black pixel)
let mut sumFront: f64 =
self.distance(beg, self.project(self.points[0])) as f64 - unitPixelDist;
Point::distance(beg, self.project(self.points[0])) as f64 - unitPixelDist;
let mut sumBack: f64 = 0.0; // (last black pixel to last black pixel)
for dist in gapSizes {
// for (auto dist : gapSizes) {
@@ -289,7 +289,7 @@ impl DMRegressionLine {
modSizes.push(
sumFront
+ self.distance(
+ Point::distance(
end,
self.project(
self.points
@@ -300,7 +300,7 @@ impl DMRegressionLine {
) as f64,
);
modSizes[0] = 0.0; // the first element is an invalid sumBack value, would be pop_front() if vector supported this
let lineLength = self.distance(beg, end) as f64 - unitPixelDist;
let lineLength = Point::distance(beg, end) as f64 - unitPixelDist;
let mut meanModSize = Self::average(&modSizes, |_: f64| true);
// let meanModSize = average(modSizes, [](double){ return true; });
// #ifdef PRINT_DEBUG

View File

@@ -44,10 +44,6 @@ pub trait RegressionLine {
fn evaluate(&mut self, points: &[Point]) -> bool; // { return self.evaluate_begin_end(&points.front(), &points.back() + 1); }
fn evaluateSelf(&mut self) -> bool;
fn distance(&self, a: Point, b: Point) -> f32 {
crate::result_point_utils::distance(&a, &b)
}
// RegressionLine() { _points.reserve(16); } // arbitrary but plausible start size (tiny performance improvement)
// template<typename T> RegressionLine(PointT<T> a, PointT<T> b)