mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
fix pattern test
This commit is contained in:
@@ -412,7 +412,12 @@ pub fn FitQadrilateralToPoints(center: Point, points: &mut [Point]) -> Option<Qu
|
|||||||
.max_by(diagonal_max_by_pred)?;
|
.max_by(diagonal_max_by_pred)?;
|
||||||
// corners[3] = std::max_element(&points[Size(points) * 5 / 8], &points[Size(points) * 7 / 8], dist2Diagonal);
|
// 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 = [
|
// let lines = [
|
||||||
// RegressionLine::with_two_points(corners[0] + 1.0, corners[1]),
|
// RegressionLine::with_two_points(corners[0] + 1.0, corners[1]),
|
||||||
@@ -421,10 +426,10 @@ let corner_positions = [0, points.iter().position(|p| *p == corners[1])?, points
|
|||||||
// RegressionLine::with_two_points(corners[3] + 1.0, *points.last()? + 1.0),
|
// RegressionLine::with_two_points(corners[3] + 1.0, *points.last()? + 1.0),
|
||||||
// ];
|
// ];
|
||||||
let lines = [
|
let lines = [
|
||||||
RegressionLine::with_point_slice(&points[corner_positions[0] + 1.. corner_positions[1]]),
|
RegressionLine::with_point_slice(&points[corner_positions[0] + 1..corner_positions[1]]),
|
||||||
RegressionLine::with_point_slice(&points[corner_positions[1] + 1.. corner_positions[2]]),
|
RegressionLine::with_point_slice(&points[corner_positions[1] + 1..corner_positions[2]]),
|
||||||
RegressionLine::with_point_slice(&points[corner_positions[2] + 1.. corner_positions[3]]),
|
RegressionLine::with_point_slice(&points[corner_positions[2] + 1..corner_positions[3]]),
|
||||||
RegressionLine::with_point_slice(&points[corner_positions[3] + 1.. points.len()]),
|
RegressionLine::with_point_slice(&points[corner_positions[3] + 1..points.len()]),
|
||||||
];
|
];
|
||||||
// std::array lines{RegressionLine{corners[0] + 1, corners[1]}, RegressionLine{corners[1] + 1, corners[2]},
|
// std::array lines{RegressionLine{corners[0] + 1, corners[1]}, RegressionLine{corners[1] + 1, corners[2]},
|
||||||
// RegressionLine{corners[2] + 1, corners[3]}, RegressionLine{corners[3] + 1, &points.back() + 1}};
|
// RegressionLine{corners[2] + 1, corners[3]}, RegressionLine{corners[3] + 1, &points.back() + 1}};
|
||||||
|
|||||||
@@ -66,9 +66,9 @@ impl<T: Default + Clone + Copy> Matrix<T> {
|
|||||||
pub fn get(&self, x: usize, y: usize) -> Option<T> {
|
pub fn get(&self, x: usize, y: usize) -> Option<T> {
|
||||||
if x >= self.width || y >= self.height {
|
if x >= self.width || y >= self.height {
|
||||||
None
|
None
|
||||||
} else if let Some(Some(d)) = self.data.get(Self::get_offset(x, y, self.width)){
|
} else if let Some(Some(d)) = self.data.get(Self::get_offset(x, y, self.width)) {
|
||||||
Some(*d)
|
Some(*d)
|
||||||
}else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -163,7 +163,7 @@ impl<'a> PatternView<'a> {
|
|||||||
|
|
||||||
// index is the number of bars and spaces from the first bar to the current position
|
// index is the number of bars and spaces from the first bar to the current position
|
||||||
pub fn index(&self) -> usize {
|
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 {
|
pub fn pixelsInFront(&self) -> PatternType {
|
||||||
self.data
|
self.data
|
||||||
|
|||||||
@@ -715,7 +715,10 @@ pub fn SampleQR(image: &BitMatrix, fp: &FinderPatternSet) -> Result<QRCodeDetect
|
|||||||
let y1 = apM[y + 1];
|
let y1 = apM[y + 1];
|
||||||
rois.push(SamplerControl {
|
rois.push(SamplerControl {
|
||||||
p0: point_i(x0 - u32::from(x == 0) * 6, y0 - u32::from(y == 0) * 6),
|
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(
|
transform: PerspectiveTransform::quadrilateralToQuadrilateral(
|
||||||
Quadrilateral::rectangle_from_xy(
|
Quadrilateral::rectangle_from_xy(
|
||||||
x0 as f32, x1 as f32, y0 as f32, y1 as f32, None,
|
x0 as f32, x1 as f32, y0 as f32, y1 as f32, None,
|
||||||
|
|||||||
@@ -284,7 +284,7 @@ impl Point {
|
|||||||
pub fn floor(self) -> Self {
|
pub fn floor(self) -> Self {
|
||||||
Self {
|
Self {
|
||||||
x: self.x.floor(),
|
x: self.x.floor(),
|
||||||
y: self.y.floor()
|
y: self.y.floor(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user