remove impl ResultPoint for FinderPattern & AlignmentPattern

This commit is contained in:
Vukašin Stepanović
2023-02-16 16:32:01 +00:00
parent 072d3d0ec7
commit 1322f7defa
6 changed files with 47 additions and 65 deletions

View File

@@ -14,10 +14,12 @@
* limitations under the License.
*/
use std::ops::Div;
use crate::{
common::{BitMatrix, Result},
result_point_utils, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
PointCallback, ResultPoint,
result_point_utils, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Point,
PointCallback,
};
use super::{FinderPattern, FinderPatternInfo};
@@ -633,9 +635,11 @@ impl<'a> FinderPatternFinder<'_> {
// difference in the x / y coordinates of the two centers.
// This is the case where you find top left last.
self.hasSkipped = true;
return (((fnp.getX() - center.getX()).abs()
- (fnp.getY() - center.getY()).abs())
/ 2.0)
return (Point::from(fnp) - Point::from(center))
.abs()
.fold(|x, y| x - y)
.div(2.0)
.floor() as u32;
} else {
firstConfirmedCenter.replace(center);
@@ -679,10 +683,7 @@ impl<'a> FinderPatternFinder<'_> {
* Get square of distance between a and b.
*/
fn squaredDistance(a: &FinderPattern, b: &FinderPattern) -> f64 {
let x = a.getX() as f64 - b.getX() as f64;
let y = a.getY() as f64 - b.getY() as f64;
x * x + y * y
Point::from(a).squaredDistance(Point::from(b)) as f64
}
/**