fix pattern test

This commit is contained in:
Henry Schimke
2023-04-24 17:49:04 -05:00
parent d08f67feed
commit 483539a194
5 changed files with 18 additions and 10 deletions

View File

@@ -412,7 +412,12 @@ pub fn FitQadrilateralToPoints(center: Point, points: &mut [Point]) -> Option<Qu
.max_by(diagonal_max_by_pred)?;
// corners[3] = std::max_element(&points[Size(points) * 5 / 8], &points[Size(points) * 7 / 8], dist2Diagonal);
let corner_positions = [0, points.iter().position(|p| *p == corners[1])?, points.iter().position(|p| *p == corners[2])?, points.iter().position(|p| *p == corners[3])?];
let corner_positions = [
0,
points.iter().position(|p| *p == corners[1])?,
points.iter().position(|p| *p == corners[2])?,
points.iter().position(|p| *p == corners[3])?,
];
// let lines = [
// RegressionLine::with_two_points(corners[0] + 1.0, corners[1]),

View File

@@ -163,7 +163,7 @@ impl<'a> PatternView<'a> {
// index is the number of bars and spaces from the first bar to the current position
pub fn index(&self) -> usize {
self.current - self.start /*return narrow_cast<int>(_data - _base) - 1;*/
self.current /*return narrow_cast<int>(_data - _base) - 1;*/
}
pub fn pixelsInFront(&self) -> PatternType {
self.data

View File

@@ -715,7 +715,10 @@ pub fn SampleQR(image: &BitMatrix, fp: &FinderPatternSet) -> Result<QRCodeDetect
let y1 = apM[y + 1];
rois.push(SamplerControl {
p0: point_i(x0 - u32::from(x == 0) * 6, y0 - u32::from(y == 0) * 6),
p1: point_i(x1 + u32::from(x == N - 1) * 7, y1 + u32::from(y == N - 1) * 7),
p1: point_i(
x1 + u32::from(x == N - 1) * 7,
y1 + u32::from(y == N - 1) * 7,
),
transform: PerspectiveTransform::quadrilateralToQuadrilateral(
Quadrilateral::rectangle_from_xy(
x0 as f32, x1 as f32, y0 as f32, y1 as f32, None,

View File

@@ -284,7 +284,7 @@ impl Point {
pub fn floor(self) -> Self {
Self {
x: self.x.floor(),
y: self.y.floor()
y: self.y.floor(),
}
}
}