Promote Quadrilateral to default

The library now uses the `Quadrilateral` struct when handling sets of four points in `GridSampler` and `PerspectiveTransform`
This commit is contained in:
Henry Schimke
2023-03-08 11:17:43 -06:00
parent d5e6a5d0a7
commit 2b7d053646
13 changed files with 348 additions and 422 deletions

View File

@@ -2,7 +2,7 @@
use num::integer::Roots;
use crate::{
common::{BitMatrix, DefaultGridSampler, DetectorRXingResult, GridSampler, Result},
common::{BitMatrix, DefaultGridSampler, DetectorRXingResult, GridSampler, Result, Quadrilateral},
point, Exceptions, Point,
};
@@ -346,26 +346,16 @@ pub fn detect(image: &BitMatrix, try_harder: bool) -> Result<MaxicodeDetectionRe
// let target_width = (tr.0 - tl.0).round().abs() as u32;
// let target_height = (br.1 - tr.1).round().abs() as u32;
let dst = Quadrilateral::new(point(0.0,0.0), point(target_width,0.0), point(target_width,
target_height), point(0.0,
target_height));
let src = Quadrilateral::new(tl, tr, br, bl);
let Ok(bits) = grid_sampler.sample_grid_detailed(
image,
target_width.round() as u32,
target_height.round() as u32,
0.0,
0.0,
target_width ,
0.0,
target_width,
target_height,
0.0,
target_height,
tl.x,
tl.y,
tr.x,
tr.y,
br.x,
br.y,
bl.x,
bl.y,
dst, src
) else {
if try_harder {
continue;