mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
cargo fmt
This commit is contained in:
@@ -39,7 +39,7 @@ use rand::Rng;
|
|||||||
use crate::{aztec::decoder, common::BitMatrix, exceptions::Exceptions};
|
use crate::{aztec::decoder, common::BitMatrix, exceptions::Exceptions};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
detector::{self, Detector, AztecPoint},
|
detector::{self, AztecPoint, Detector},
|
||||||
encoder::{self, AztecCode},
|
encoder::{self, AztecCode},
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -271,7 +271,10 @@ fn get_orientation_points(code: &AztecCode) -> Vec<AztecPoint> {
|
|||||||
let mut ySign: i32 = -1;
|
let mut ySign: i32 = -1;
|
||||||
while ySign <= 1 {
|
while ySign <= 1 {
|
||||||
// for (int ySign = -1; ySign <= 1; ySign += 2) {
|
// for (int ySign = -1; ySign <= 1; ySign += 2) {
|
||||||
result.push(AztecPoint::new(center + xSign * offset, center + ySign * offset));
|
result.push(AztecPoint::new(
|
||||||
|
center + xSign * offset,
|
||||||
|
center + ySign * offset,
|
||||||
|
));
|
||||||
result.push(AztecPoint::new(
|
result.push(AztecPoint::new(
|
||||||
center + xSign * (offset - 1),
|
center + xSign * (offset - 1),
|
||||||
center + ySign * offset,
|
center + ySign * offset,
|
||||||
|
|||||||
@@ -325,14 +325,10 @@ impl<'a> Detector<'_> {
|
|||||||
|
|
||||||
// Expand the square by .5 pixel in each direction so that we're on the border
|
// Expand the square by .5 pixel in each direction so that we're on the border
|
||||||
// between the white square and the black square
|
// between the white square and the black square
|
||||||
let pinax =
|
let pinax = Point::new(pina.get_x() as f32 + 0.5f32, pina.get_y() as f32 - 0.5f32);
|
||||||
Point::new(pina.get_x() as f32 + 0.5f32, pina.get_y() as f32 - 0.5f32);
|
let pinbx = Point::new(pinb.get_x() as f32 + 0.5f32, pinb.get_y() as f32 + 0.5f32);
|
||||||
let pinbx =
|
let pincx = Point::new(pinc.get_x() as f32 - 0.5f32, pinc.get_y() as f32 + 0.5f32);
|
||||||
Point::new(pinb.get_x() as f32 + 0.5f32, pinb.get_y() as f32 + 0.5f32);
|
let pindx = Point::new(pind.get_x() as f32 - 0.5f32, pind.get_y() as f32 - 0.5f32);
|
||||||
let pincx =
|
|
||||||
Point::new(pinc.get_x() as f32 - 0.5f32, pinc.get_y() as f32 + 0.5f32);
|
|
||||||
let pindx =
|
|
||||||
Point::new(pind.get_x() as f32 - 0.5f32, pind.get_y() as f32 - 0.5f32);
|
|
||||||
|
|
||||||
// Expand the square so that its corners are the centers of the points
|
// Expand the square so that its corners are the centers of the points
|
||||||
// just outside the bull's eye.
|
// just outside the bull's eye.
|
||||||
@@ -475,10 +471,7 @@ impl<'a> Detector<'_> {
|
|||||||
* @param bullsEyeCorners the array of bull's eye corners
|
* @param bullsEyeCorners the array of bull's eye corners
|
||||||
* @return the array of aztec code corners
|
* @return the array of aztec code corners
|
||||||
*/
|
*/
|
||||||
fn get_matrix_corner_points(
|
fn get_matrix_corner_points(&self, bulls_eye_corners: &[Point]) -> [Point; 4] {
|
||||||
&self,
|
|
||||||
bulls_eye_corners: &[Point],
|
|
||||||
) -> [Point; 4] {
|
|
||||||
Self::expand_square(
|
Self::expand_square(
|
||||||
bulls_eye_corners,
|
bulls_eye_corners,
|
||||||
2 * self.nb_center_layers,
|
2 * self.nb_center_layers,
|
||||||
@@ -561,7 +554,13 @@ impl<'a> Detector<'_> {
|
|||||||
* @return true if the border of the rectangle passed in parameter is compound of white points only
|
* @return true if the border of the rectangle passed in parameter is compound of white points only
|
||||||
* or black points only
|
* or black points only
|
||||||
*/
|
*/
|
||||||
fn is_white_or_black_rectangle(&self, p1: &AztecPoint, p2: &AztecPoint, p3: &AztecPoint, p4: &AztecPoint) -> bool {
|
fn is_white_or_black_rectangle(
|
||||||
|
&self,
|
||||||
|
p1: &AztecPoint,
|
||||||
|
p2: &AztecPoint,
|
||||||
|
p3: &AztecPoint,
|
||||||
|
p4: &AztecPoint,
|
||||||
|
) -> bool {
|
||||||
let corr = 3;
|
let corr = 3;
|
||||||
|
|
||||||
let p1 = AztecPoint::new(
|
let p1 = AztecPoint::new(
|
||||||
@@ -690,11 +689,7 @@ impl<'a> Detector<'_> {
|
|||||||
* @param newSide the new length of the size of the square in the target bit matrix
|
* @param newSide the new length of the size of the square in the target bit matrix
|
||||||
* @return the corners of the expanded square
|
* @return the corners of the expanded square
|
||||||
*/
|
*/
|
||||||
fn expand_square(
|
fn expand_square(corner_points: &[Point], old_side: u32, new_side: u32) -> [Point; 4] {
|
||||||
corner_points: &[Point],
|
|
||||||
old_side: u32,
|
|
||||||
new_side: u32,
|
|
||||||
) -> [Point; 4] {
|
|
||||||
let ratio = new_side as f32 / (2.0f32 * old_side as f32);
|
let ratio = new_side as f32 / (2.0f32 * old_side as f32);
|
||||||
|
|
||||||
let d = corner_points[0] - corner_points[2];
|
let d = corner_points[0] - corner_points[2];
|
||||||
|
|||||||
@@ -289,13 +289,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_black_point_on_segment(
|
fn get_black_point_on_segment(&self, a_x: f32, a_y: f32, b_x: f32, b_y: f32) -> Option<Point> {
|
||||||
&self,
|
|
||||||
a_x: f32,
|
|
||||||
a_y: f32,
|
|
||||||
b_x: f32,
|
|
||||||
b_y: f32,
|
|
||||||
) -> Option<Point> {
|
|
||||||
let dist = MathUtils::round(MathUtils::distance(a_x, a_y, b_x, b_y));
|
let dist = MathUtils::round(MathUtils::distance(a_x, a_y, b_x, b_y));
|
||||||
let x_step: f32 = (b_x - a_x) / dist as f32;
|
let x_step: f32 = (b_x - a_x) / dist as f32;
|
||||||
let y_step: f32 = (b_y - a_y) / dist as f32;
|
let y_step: f32 = (b_y - a_y) / dist as f32;
|
||||||
@@ -323,13 +317,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
|||||||
* point and the last, the bottommost. The second point will be
|
* point and the last, the bottommost. The second point will be
|
||||||
* leftmost and the third, the rightmost
|
* leftmost and the third, the rightmost
|
||||||
*/
|
*/
|
||||||
fn center_edges(
|
fn center_edges(&self, y: Point, z: Point, x: Point, t: Point) -> [Point; 4] {
|
||||||
&self,
|
|
||||||
y: Point,
|
|
||||||
z: Point,
|
|
||||||
x: Point,
|
|
||||||
t: Point,
|
|
||||||
) -> [Point; 4] {
|
|
||||||
//
|
//
|
||||||
// t t
|
// t t
|
||||||
// z x
|
// z x
|
||||||
|
|||||||
@@ -197,14 +197,8 @@ fn Scan(
|
|||||||
|
|
||||||
CHECK!((10..=144).contains(&dimT) && (8..=144).contains(&dimR));
|
CHECK!((10..=144).contains(&dimT) && (8..=144).contains(&dimR));
|
||||||
|
|
||||||
let movedTowardsBy = |a: Point,
|
let movedTowardsBy = |a: Point, b1: Point, b2: Point, d: f32| -> Point {
|
||||||
b1: Point,
|
a + d * Point::normalized(Point::normalized(b1 - a) + Point::normalized(b2 - a))
|
||||||
b2: Point,
|
|
||||||
d: f32|
|
|
||||||
-> Point {
|
|
||||||
a + d * Point::normalized(
|
|
||||||
Point::normalized(b1 - a) + Point::normalized(b2 - a),
|
|
||||||
)
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// shrink shape by half a pixel to go from center of white pixel outside of code to the edge between white and black
|
// shrink shape by half a pixel to go from center of white pixel outside of code to the edge between white and black
|
||||||
@@ -302,8 +296,7 @@ pub fn detect(
|
|||||||
x: (image.getWidth() / 2) as f32,
|
x: (image.getWidth() / 2) as f32,
|
||||||
y: (image.getHeight() / 2) as f32,
|
y: (image.getHeight() / 2) as f32,
|
||||||
}; //PointF(image.width() / 2, image.height() / 2);
|
}; //PointF(image.width() / 2, image.height() / 2);
|
||||||
let startPos =
|
let startPos = Point::centered(center - center * dir + MIN_SYMBOL_SIZE as i32 / 2 * dir);
|
||||||
Point::centered(center - center * dir + MIN_SYMBOL_SIZE as i32 / 2 * dir);
|
|
||||||
|
|
||||||
if let Some(history) = &mut history {
|
if let Some(history) = &mut history {
|
||||||
history.borrow_mut().clear(0);
|
history.borrow_mut().clear(0);
|
||||||
|
|||||||
@@ -37,8 +37,7 @@ impl RegressionLine for DMRegressionLine {
|
|||||||
|
|
||||||
fn length(&self) -> u32 {
|
fn length(&self) -> u32 {
|
||||||
if self.points.len() >= 2 {
|
if self.points.len() >= 2 {
|
||||||
Point::distance(*self.points.first().unwrap(), *self.points.last().unwrap())
|
Point::distance(*self.points.first().unwrap(), *self.points.last().unwrap()) as u32
|
||||||
as u32
|
|
||||||
} else {
|
} else {
|
||||||
0
|
0
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -252,21 +252,14 @@ impl<'a> EdgeTracer<'_> {
|
|||||||
}
|
}
|
||||||
// make sure d stays in the same quadrant to prevent an infinite loop
|
// make sure d stays in the same quadrant to prevent an infinite loop
|
||||||
if (self.d.x).abs() == (self.d.y).abs() {
|
if (self.d.x).abs() == (self.d.y).abs() {
|
||||||
self.d = Point::mainDirection(old_d)
|
self.d = Point::mainDirection(old_d) + 0.99 * (self.d - Point::mainDirection(old_d));
|
||||||
+ 0.99 * (self.d - Point::mainDirection(old_d));
|
} else if Point::mainDirection(self.d) != Point::mainDirection(old_d) {
|
||||||
} else if Point::mainDirection(self.d) != Point::mainDirection(old_d)
|
self.d = Point::mainDirection(old_d) + 0.99 * Point::mainDirection(self.d);
|
||||||
{
|
|
||||||
self.d = Point::mainDirection(old_d)
|
|
||||||
+ 0.99 * Point::mainDirection(self.d);
|
|
||||||
}
|
}
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn traceLine<T: RegressionLine>(
|
pub fn traceLine<T: RegressionLine>(&mut self, dEdge: Point, line: &mut T) -> Result<bool> {
|
||||||
&mut self,
|
|
||||||
dEdge: Point,
|
|
||||||
line: &mut T,
|
|
||||||
) -> Result<bool> {
|
|
||||||
line.setDirectionInward(dEdge);
|
line.setDirectionInward(dEdge);
|
||||||
loop {
|
loop {
|
||||||
// log(self.p);
|
// log(self.p);
|
||||||
@@ -341,9 +334,7 @@ impl<'a> EdgeTracer<'_> {
|
|||||||
// In case the 'go outward' step in traceStep lead us astray, we might end up with a line
|
// In case the 'go outward' step in traceStep lead us astray, we might end up with a line
|
||||||
// that is almost perpendicular to d. Then the back-projection below can result in an
|
// that is almost perpendicular to d. Then the back-projection below can result in an
|
||||||
// endless loop. Break if the angle between d and line is greater than 45 deg.
|
// endless loop. Break if the angle between d and line is greater than 45 deg.
|
||||||
if (Point::dot(Point::normalized(self.d), line.normal()))
|
if (Point::dot(Point::normalized(self.d), line.normal())).abs() > 0.7
|
||||||
.abs()
|
|
||||||
> 0.7
|
|
||||||
// thresh is approx. sin(45 deg)
|
// thresh is approx. sin(45 deg)
|
||||||
{
|
{
|
||||||
return Ok(false);
|
return Ok(false);
|
||||||
@@ -439,11 +430,7 @@ impl<'a> EdgeTracer<'_> {
|
|||||||
} //while (true);
|
} //while (true);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn traceCorner(
|
pub fn traceCorner(&mut self, dir: &mut Point, corner: &mut Point) -> Result<bool> {
|
||||||
&mut self,
|
|
||||||
dir: &mut Point,
|
|
||||||
corner: &mut Point,
|
|
||||||
) -> Result<bool> {
|
|
||||||
self.step(None);
|
self.step(None);
|
||||||
// log(p);
|
// log(p);
|
||||||
*corner = self.p;
|
*corner = self.p;
|
||||||
|
|||||||
@@ -17,12 +17,7 @@ impl Quadrilateral {
|
|||||||
// Self([tl, tr,br, bl ])
|
// Self([tl, tr,br, bl ])
|
||||||
// }
|
// }
|
||||||
|
|
||||||
pub fn with_points(
|
pub fn with_points(tl: Point, tr: Point, br: Point, bl: Point) -> Self {
|
||||||
tl: Point,
|
|
||||||
tr: Point,
|
|
||||||
br: Point,
|
|
||||||
bl: Point,
|
|
||||||
) -> Self {
|
|
||||||
Self([tl, tr, br, bl])
|
Self([tl, tr, br, bl])
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::common::Result;
|
use crate::common::Result;
|
||||||
use crate::{Exceptions, RXingResult, Point, Reader, ResultPoint};
|
use crate::{Exceptions, Point, RXingResult, Reader, ResultPoint};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class attempts to decode a barcode from an image, not by scanning the whole image,
|
* This class attempts to decode a barcode from an image, not by scanning the whole image,
|
||||||
@@ -88,11 +88,8 @@ impl<T: Reader> Reader for ByQuadrantReader<T> {
|
|||||||
// This is a match because only NotFoundExceptions should be ignored
|
// This is a match because only NotFoundExceptions should be ignored
|
||||||
match result {
|
match result {
|
||||||
Ok(res) => {
|
Ok(res) => {
|
||||||
let points = Self::makeAbsolute(
|
let points =
|
||||||
res.getPoints(),
|
Self::makeAbsolute(res.getPoints(), halfWidth as f32, halfHeight as f32);
|
||||||
halfWidth as f32,
|
|
||||||
halfHeight as f32,
|
|
||||||
);
|
|
||||||
return Ok(RXingResult::new_from_existing_result(res, points));
|
return Ok(RXingResult::new_from_existing_result(res, points));
|
||||||
}
|
}
|
||||||
Err(Exceptions::NotFoundException(_)) => {}
|
Err(Exceptions::NotFoundException(_)) => {}
|
||||||
@@ -122,11 +119,7 @@ impl<T: Reader> ByQuadrantReader<T> {
|
|||||||
Self(delegate)
|
Self(delegate)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn makeAbsolute(
|
fn makeAbsolute(points: &[Point], leftOffset: f32, topOffset: f32) -> Vec<Point> {
|
||||||
points: &[Point],
|
|
||||||
leftOffset: f32,
|
|
||||||
topOffset: f32,
|
|
||||||
) -> Vec<Point> {
|
|
||||||
// let mut result = Vec::new();
|
// let mut result = Vec::new();
|
||||||
// if !points.is_empty() {
|
// if !points.is_empty() {
|
||||||
|
|
||||||
@@ -140,9 +133,7 @@ impl<T: Reader> ByQuadrantReader<T> {
|
|||||||
// result
|
// result
|
||||||
points
|
points
|
||||||
.iter()
|
.iter()
|
||||||
.map(|relative| {
|
.map(|relative| Point::new(relative.getX() + leftOffset, relative.getY() + topOffset))
|
||||||
Point::new(relative.getX() + leftOffset, relative.getY() + topOffset)
|
|
||||||
})
|
|
||||||
.collect()
|
.collect()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,8 +17,8 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::Result, BinaryBitmap, DecodingHintDictionary, Exceptions, RXingResult,
|
common::Result, BinaryBitmap, DecodingHintDictionary, Exceptions, Point, RXingResult, Reader,
|
||||||
Point, Reader, ResultPoint,
|
ResultPoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::MultipleBarcodeReader;
|
use super::MultipleBarcodeReader;
|
||||||
|
|||||||
@@ -19,8 +19,7 @@ use std::cmp::Ordering;
|
|||||||
use crate::{
|
use crate::{
|
||||||
common::{BitMatrix, Result},
|
common::{BitMatrix, Result},
|
||||||
qrcode::detector::{FinderPattern, FinderPatternFinder, FinderPatternInfo},
|
qrcode::detector::{FinderPattern, FinderPatternFinder, FinderPatternInfo},
|
||||||
result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions,
|
result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions, PointCallback,
|
||||||
PointCallback,
|
|
||||||
};
|
};
|
||||||
|
|
||||||
// max. legal count of modules per QR code edge (177)
|
// max. legal count of modules per QR code edge (177)
|
||||||
|
|||||||
@@ -17,10 +17,10 @@
|
|||||||
use rxing_one_d_proc_derive::OneDReader;
|
use rxing_one_d_proc_derive::OneDReader;
|
||||||
|
|
||||||
use crate::common::{BitArray, Result};
|
use crate::common::{BitArray, Result};
|
||||||
use crate::{BarcodeFormat, Point};
|
|
||||||
use crate::DecodeHintValue;
|
use crate::DecodeHintValue;
|
||||||
use crate::Exceptions;
|
use crate::Exceptions;
|
||||||
use crate::RXingResult;
|
use crate::RXingResult;
|
||||||
|
use crate::{BarcodeFormat, Point};
|
||||||
|
|
||||||
use super::OneDReader;
|
use super::OneDReader;
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use rxing_one_d_proc_derive::OneDReader;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitArray, Result},
|
common::{BitArray, Result},
|
||||||
BarcodeFormat, Exceptions, RXingResult, Point,
|
BarcodeFormat, Exceptions, Point, RXingResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{one_d_reader, OneDReader};
|
use super::{one_d_reader, OneDReader};
|
||||||
|
|||||||
@@ -17,7 +17,7 @@
|
|||||||
use rxing_one_d_proc_derive::OneDReader;
|
use rxing_one_d_proc_derive::OneDReader;
|
||||||
|
|
||||||
use crate::common::{BitArray, Result};
|
use crate::common::{BitArray, Result};
|
||||||
use crate::{BarcodeFormat, Exceptions, RXingResult, Point};
|
use crate::{BarcodeFormat, Exceptions, Point, RXingResult};
|
||||||
|
|
||||||
use super::{one_d_reader, OneDReader};
|
use super::{one_d_reader, OneDReader};
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use rxing_one_d_proc_derive::OneDReader;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitArray, Result},
|
common::{BitArray, Result},
|
||||||
BarcodeFormat, Exceptions, RXingResult, Point,
|
BarcodeFormat, Exceptions, Point, RXingResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{one_d_reader, OneDReader};
|
use super::{one_d_reader, OneDReader};
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ use rxing_one_d_proc_derive::OneDReader;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitArray, Result},
|
common::{BitArray, Result},
|
||||||
BarcodeFormat, DecodeHintValue, Exceptions, RXingResult, Point,
|
BarcodeFormat, DecodeHintValue, Exceptions, Point, RXingResult,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{one_d_reader, OneDReader};
|
use super::{one_d_reader, OneDReader};
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitArray, Result},
|
common::{BitArray, Result},
|
||||||
BinaryBitmap, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, RXingResult,
|
BinaryBitmap, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Point,
|
||||||
RXingResultMetadataType, RXingResultMetadataValue, Point, Reader, ResultPoint,
|
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader, ResultPoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,14 +117,10 @@ pub trait OneDReader: Reader {
|
|||||||
// And remember to flip the result points horizontally.
|
// And remember to flip the result points horizontally.
|
||||||
let points = result.getPointsMut();
|
let points = result.getPointsMut();
|
||||||
if !points.is_empty() && points.len() >= 2 {
|
if !points.is_empty() && points.len() >= 2 {
|
||||||
points[0] = Point::new(
|
points[0] =
|
||||||
width as f32 - points[0].getX() - 1.0,
|
Point::new(width as f32 - points[0].getX() - 1.0, points[0].getY());
|
||||||
points[0].getY(),
|
points[1] =
|
||||||
);
|
Point::new(width as f32 - points[1].getX() - 1.0, points[1].getY());
|
||||||
points[1] = Point::new(
|
|
||||||
width as f32 - points[1].getX() - 1.0,
|
|
||||||
points[1].getY(),
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return Ok(result);
|
return Ok(result);
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ use std::collections::HashMap;
|
|||||||
use crate::{
|
use crate::{
|
||||||
common::{BitArray, Result},
|
common::{BitArray, Result},
|
||||||
oned::{one_d_reader, OneDReader},
|
oned::{one_d_reader, OneDReader},
|
||||||
BarcodeFormat, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
|
BarcodeFormat, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Point,
|
||||||
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Point, Reader,
|
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitArray, Result},
|
common::{BitArray, Result},
|
||||||
BarcodeFormat, Exceptions, RXingResult, RXingResultMetadataType, RXingResultMetadataValue,
|
BarcodeFormat, Exceptions, Point, RXingResult, RXingResultMetadataType,
|
||||||
Point,
|
RXingResultMetadataValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{upc_ean_reader, UPCEANReader, STAND_IN};
|
use super::{upc_ean_reader, UPCEANReader, STAND_IN};
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitArray, Result},
|
common::{BitArray, Result},
|
||||||
BarcodeFormat, Exceptions, RXingResult, RXingResultMetadataType, RXingResultMetadataValue,
|
BarcodeFormat, Exceptions, Point, RXingResult, RXingResultMetadataType,
|
||||||
Point,
|
RXingResultMetadataValue,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{upc_ean_reader, UPCEANReader, STAND_IN};
|
use super::{upc_ean_reader, UPCEANReader, STAND_IN};
|
||||||
|
|||||||
@@ -16,8 +16,8 @@
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitArray, Result},
|
common::{BitArray, Result},
|
||||||
BarcodeFormat, DecodeHintType, DecodeHintValue, Exceptions, RXingResult,
|
BarcodeFormat, DecodeHintType, DecodeHintValue, Exceptions, Point, RXingResult,
|
||||||
RXingResultMetadataType, RXingResultMetadataValue, Point, Reader,
|
RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{one_d_reader, EANManufacturerOrgSupport, OneDReader, UPCEANExtensionSupport};
|
use super::{one_d_reader, EANManufacturerOrgSupport, OneDReader, UPCEANExtensionSupport};
|
||||||
@@ -223,8 +223,7 @@ pub trait UPCEANReader: OneDReader {
|
|||||||
),
|
),
|
||||||
);
|
);
|
||||||
decodeRXingResult.putAllMetadata(extensionRXingResult.getRXingResultMetadata().clone());
|
decodeRXingResult.putAllMetadata(extensionRXingResult.getRXingResultMetadata().clone());
|
||||||
decodeRXingResult
|
decodeRXingResult.addPoints(&mut extensionRXingResult.getPoints().clone());
|
||||||
.addPoints(&mut extensionRXingResult.getPoints().clone());
|
|
||||||
extensionLength = extensionRXingResult.getText().chars().count();
|
extensionLength = extensionRXingResult.getText().chars().count();
|
||||||
Ok(())
|
Ok(())
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ impl BoundingBox {
|
|||||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||||
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||||
newTopRight = Point::new(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
newTopRight = Point::new(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
||||||
newBottomRight =
|
newBottomRight = Point::new(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
||||||
Point::new(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
|
||||||
} else {
|
} else {
|
||||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||||
|
|||||||
@@ -179,11 +179,7 @@ pub fn detect(multiple: bool, bitMatrix: &BitMatrix) -> Option<Vec<[Option<Point
|
|||||||
* vertices[6] x, y top right codeword area
|
* vertices[6] x, y top right codeword area
|
||||||
* vertices[7] x, y bottom right codeword area
|
* vertices[7] x, y bottom right codeword area
|
||||||
*/
|
*/
|
||||||
fn findVertices(
|
fn findVertices(matrix: &BitMatrix, startRow: u32, startColumn: u32) -> Option<[Option<Point>; 8]> {
|
||||||
matrix: &BitMatrix,
|
|
||||||
startRow: u32,
|
|
||||||
startColumn: u32,
|
|
||||||
) -> Option<[Option<Point>; 8]> {
|
|
||||||
let height = matrix.getHeight();
|
let height = matrix.getHeight();
|
||||||
let width = matrix.getWidth();
|
let width = matrix.getWidth();
|
||||||
let mut startRow = startRow;
|
let mut startRow = startRow;
|
||||||
@@ -249,14 +245,8 @@ fn findRowsWithPattern(
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
result[0] = Some(Point::new(
|
result[0] = Some(Point::new(loc_store.as_ref()?[0] as f32, startRow as f32));
|
||||||
loc_store.as_ref()?[0] as f32,
|
result[1] = Some(Point::new(loc_store.as_ref()?[1] as f32, startRow as f32));
|
||||||
startRow as f32,
|
|
||||||
));
|
|
||||||
result[1] = Some(Point::new(
|
|
||||||
loc_store.as_ref()?[1] as f32,
|
|
||||||
startRow as f32,
|
|
||||||
));
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -304,14 +294,8 @@ fn findRowsWithPattern(
|
|||||||
stopRow += 1;
|
stopRow += 1;
|
||||||
}
|
}
|
||||||
stopRow -= skippedRowCount + 1;
|
stopRow -= skippedRowCount + 1;
|
||||||
result[2] = Some(Point::new(
|
result[2] = Some(Point::new(previousRowLoc[0] as f32, stopRow as f32));
|
||||||
previousRowLoc[0] as f32,
|
result[3] = Some(Point::new(previousRowLoc[1] as f32, stopRow as f32));
|
||||||
stopRow as f32,
|
|
||||||
));
|
|
||||||
result[3] = Some(Point::new(
|
|
||||||
previousRowLoc[1] as f32,
|
|
||||||
stopRow as f32,
|
|
||||||
));
|
|
||||||
}
|
}
|
||||||
if stopRow - startRow < BARCODE_MIN_HEIGHT {
|
if stopRow - startRow < BARCODE_MIN_HEIGHT {
|
||||||
result.fill(None);
|
result.fill(None);
|
||||||
|
|||||||
@@ -26,11 +26,7 @@ pub struct PDF417DetectorRXingResult {
|
|||||||
}
|
}
|
||||||
|
|
||||||
impl PDF417DetectorRXingResult {
|
impl PDF417DetectorRXingResult {
|
||||||
pub fn with_rotation(
|
pub fn with_rotation(bits: BitMatrix, points: Vec<[Option<Point>; 8]>, rotation: u32) -> Self {
|
||||||
bits: BitMatrix,
|
|
||||||
points: Vec<[Option<Point>; 8]>,
|
|
||||||
rotation: u32,
|
|
||||||
) -> Self {
|
|
||||||
Self {
|
Self {
|
||||||
bits,
|
bits,
|
||||||
points,
|
points,
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::Result, multi::MultipleBarcodeReader, BarcodeFormat, BinaryBitmap,
|
common::Result, multi::MultipleBarcodeReader, BarcodeFormat, BinaryBitmap,
|
||||||
DecodingHintDictionary, Exceptions, RXingResult, RXingResultMetadataType,
|
DecodingHintDictionary, Exceptions, Point, RXingResult, RXingResultMetadataType,
|
||||||
RXingResultMetadataValue, Point, Reader, ResultPoint,
|
RXingResultMetadataValue, Reader, ResultPoint,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|||||||
@@ -18,8 +18,8 @@ use std::collections::HashMap;
|
|||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{BitMatrix, DecoderRXingResult, DetectorRXingResult, Result},
|
common::{BitMatrix, DecoderRXingResult, DetectorRXingResult, Result},
|
||||||
BarcodeFormat, DecodeHintType, DecodeHintValue, Exceptions, RXingResult,
|
BarcodeFormat, DecodeHintType, DecodeHintValue, Exceptions, Point, RXingResult,
|
||||||
RXingResultMetadataType, RXingResultMetadataValue, Point, Reader,
|
RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||||
};
|
};
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
use std::{collections::HashMap, fmt};
|
use std::{collections::HashMap, fmt};
|
||||||
|
|
||||||
use crate::{BarcodeFormat, RXingResultMetadataType, RXingResultMetadataValue, Point};
|
use crate::{BarcodeFormat, Point, RXingResultMetadataType, RXingResultMetadataValue};
|
||||||
|
|
||||||
#[cfg(feature = "serde")]
|
#[cfg(feature = "serde")]
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|||||||
Reference in New Issue
Block a user