mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
clippy --fix && fmt
This commit is contained in:
@@ -102,30 +102,14 @@ fn test_error_in_parameter_locator(data: &str) {
|
|||||||
clone(&matrix)
|
clone(&matrix)
|
||||||
};
|
};
|
||||||
copy.flip_coords(
|
copy.flip_coords(
|
||||||
(orientation_points
|
(orientation_points.get(error1).unwrap().x as i32).unsigned_abs(),
|
||||||
.get(error1)
|
(orientation_points.get(error1).unwrap().y as i32).unsigned_abs(),
|
||||||
.unwrap()
|
|
||||||
.x as i32)
|
|
||||||
.unsigned_abs(),
|
|
||||||
(orientation_points
|
|
||||||
.get(error1)
|
|
||||||
.unwrap()
|
|
||||||
.y as i32)
|
|
||||||
.unsigned_abs(),
|
|
||||||
);
|
);
|
||||||
if error2 > error1 {
|
if error2 > error1 {
|
||||||
// if error2 == error1, we only test a single error
|
// if error2 == error1, we only test a single error
|
||||||
copy.flip_coords(
|
copy.flip_coords(
|
||||||
(orientation_points
|
(orientation_points.get(error2).unwrap().x as i32).unsigned_abs(),
|
||||||
.get(error2)
|
(orientation_points.get(error2).unwrap().y as i32).unsigned_abs(),
|
||||||
.unwrap()
|
|
||||||
.x as i32)
|
|
||||||
.unsigned_abs(),
|
|
||||||
(orientation_points
|
|
||||||
.get(error2)
|
|
||||||
.unwrap()
|
|
||||||
.y as i32)
|
|
||||||
.unsigned_abs(),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
// dbg!(copy.to_string());
|
// dbg!(copy.to_string());
|
||||||
|
|||||||
@@ -319,10 +319,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 = point(pina.x as f32 + 0.5, pina.y as f32 - 0.5);
|
let pinax = point(pina.x + 0.5, pina.y - 0.5);
|
||||||
let pinbx = point(pinb.x as f32 + 0.5, pinb.y as f32 + 0.5);
|
let pinbx = point(pinb.x + 0.5, pinb.y + 0.5);
|
||||||
let pincx = point(pinc.x as f32 - 0.5, pinc.y as f32 + 0.5);
|
let pincx = point(pinc.x - 0.5, pinc.y + 0.5);
|
||||||
let pindx = point(pind.x as f32 - 0.5, pind.y as f32 - 0.5);
|
let pindx = point(pind.x - 0.5, pind.y - 0.5);
|
||||||
|
|
||||||
// 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.
|
||||||
@@ -362,18 +362,10 @@ impl<'a> Detector<'_> {
|
|||||||
if !fnd {
|
if !fnd {
|
||||||
let cx: i32 = (self.image.getWidth() / 2) as i32;
|
let cx: i32 = (self.image.getWidth() / 2) as i32;
|
||||||
let cy: i32 = (self.image.getHeight() / 2) as i32;
|
let cy: i32 = (self.image.getHeight() / 2) as i32;
|
||||||
point_a = self
|
point_a = self.get_first_different(Point::from((cx + 7, cy - 7)), false, 1, -1);
|
||||||
.get_first_different(Point::from((cx + 7, cy - 7)), false, 1, -1)
|
point_b = self.get_first_different(Point::from((cx + 7, cy + 7)), false, 1, 1);
|
||||||
.into();
|
point_c = self.get_first_different(Point::from((cx - 7, cy + 7)), false, -1, 1);
|
||||||
point_b = self
|
point_d = self.get_first_different(Point::from((cx - 7, cy - 7)), false, -1, -1);
|
||||||
.get_first_different(Point::from((cx + 7, cy + 7)), false, 1, 1)
|
|
||||||
.into();
|
|
||||||
point_c = self
|
|
||||||
.get_first_different(Point::from((cx - 7, cy + 7)), false, -1, 1)
|
|
||||||
.into();
|
|
||||||
point_d = self
|
|
||||||
.get_first_different(Point::from((cx - 7, cy - 7)), false, -1, -1)
|
|
||||||
.into();
|
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
|
|
||||||
@@ -416,18 +408,10 @@ impl<'a> Detector<'_> {
|
|||||||
// This exception can be in case the initial rectangle is white
|
// This exception can be in case the initial rectangle is white
|
||||||
// In that case we try to expand the rectangle.
|
// In that case we try to expand the rectangle.
|
||||||
if !fnd {
|
if !fnd {
|
||||||
point_a = self
|
point_a = self.get_first_different(Point::from((cx + 7, cy - 7)), false, 1, -1);
|
||||||
.get_first_different(Point::from((cx + 7, cy - 7)), false, 1, -1)
|
point_b = self.get_first_different(Point::from((cx + 7, cy + 7)), false, 1, 1);
|
||||||
.into();
|
point_c = self.get_first_different(Point::from((cx - 7, cy + 7)), false, -1, 1);
|
||||||
point_b = self
|
point_d = self.get_first_different(Point::from((cx - 7, cy - 7)), false, -1, -1);
|
||||||
.get_first_different(Point::from((cx + 7, cy + 7)), false, 1, 1)
|
|
||||||
.into();
|
|
||||||
point_c = self
|
|
||||||
.get_first_different(Point::from((cx - 7, cy + 7)), false, -1, 1)
|
|
||||||
.into();
|
|
||||||
point_d = self
|
|
||||||
.get_first_different(Point::from((cx - 7, cy - 7)), false, -1, -1)
|
|
||||||
.into();
|
|
||||||
}
|
}
|
||||||
// try {
|
// try {
|
||||||
// Point[] cornerPoints = new WhiteRectangleDetector(image, 15, cx, cy).detect();
|
// Point[] cornerPoints = new WhiteRectangleDetector(image, 15, cx, cy).detect();
|
||||||
@@ -540,13 +524,7 @@ 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(
|
fn is_white_or_black_rectangle(&self, p1: &Point, p2: &Point, p3: &Point, p4: &Point) -> bool {
|
||||||
&self,
|
|
||||||
p1: &Point,
|
|
||||||
p2: &Point,
|
|
||||||
p3: &Point,
|
|
||||||
p4: &Point,
|
|
||||||
) -> bool {
|
|
||||||
let corr = 3.0;
|
let corr = 3.0;
|
||||||
|
|
||||||
let p1 = Point::new(
|
let p1 = Point::new(
|
||||||
@@ -602,12 +580,12 @@ impl<'a> Detector<'_> {
|
|||||||
if d == 0.0 {
|
if d == 0.0 {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
let dx = (p2.x - p1.x) as f32 / d;
|
let dx = (p2.x - p1.x) / d;
|
||||||
let dy = (p2.y - p1.y) as f32 / d;
|
let dy = (p2.y - p1.y) / d;
|
||||||
let mut error = 0;
|
let mut error = 0;
|
||||||
|
|
||||||
let mut px = p1.x as f32;
|
let mut px = p1.x;
|
||||||
let mut py = p1.y as f32;
|
let mut py = p1.y;
|
||||||
|
|
||||||
let color_model = self.image.get(p1.x as u32, p1.y as u32);
|
let color_model = self.image.get(p1.x as u32, p1.y as u32);
|
||||||
|
|
||||||
@@ -641,18 +619,21 @@ impl<'a> Detector<'_> {
|
|||||||
fn get_first_different(&self, init: Point, color: bool, dx: i32, dy: i32) -> Point {
|
fn get_first_different(&self, init: Point, color: bool, dx: i32, dy: i32) -> Point {
|
||||||
let mut point = init + Point::from((dx, dy));
|
let mut point = init + Point::from((dx, dy));
|
||||||
|
|
||||||
while self.is_valid_points(point) && self.image.get(point.x as u32, point.y as u32) == color {
|
while self.is_valid_points(point) && self.image.get(point.x as u32, point.y as u32) == color
|
||||||
|
{
|
||||||
point += Point::from((dx, dy));
|
point += Point::from((dx, dy));
|
||||||
}
|
}
|
||||||
|
|
||||||
point -= Point::from((dx, dy));
|
point -= Point::from((dx, dy));
|
||||||
|
|
||||||
while self.is_valid_points(point) && self.image.get(point.x as u32, point.y as u32) == color {
|
while self.is_valid_points(point) && self.image.get(point.x as u32, point.y as u32) == color
|
||||||
|
{
|
||||||
point.x += dx as f32;
|
point.x += dx as f32;
|
||||||
}
|
}
|
||||||
point.x -= dx as f32;
|
point.x -= dx as f32;
|
||||||
|
|
||||||
while self.is_valid_points(point) && self.image.get(point.x as u32, point.y as u32) == color {
|
while self.is_valid_points(point) && self.image.get(point.x as u32, point.y as u32) == color
|
||||||
|
{
|
||||||
point.y += dy as f32;
|
point.y += dy as f32;
|
||||||
}
|
}
|
||||||
point.y -= dy as f32;
|
point.y -= dy as f32;
|
||||||
@@ -685,7 +666,10 @@ impl<'a> Detector<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn is_valid_points(&self, p: Point) -> bool {
|
fn is_valid_points(&self, p: Point) -> bool {
|
||||||
p.x >= 0.0 && p.x < self.image.getWidth() as f32 && p.y >= 0.0 && p.y < self.image.getHeight() as f32
|
p.x >= 0.0
|
||||||
|
&& p.x < self.image.getWidth() as f32
|
||||||
|
&& p.y >= 0.0
|
||||||
|
&& p.y < self.image.getHeight() as f32
|
||||||
}
|
}
|
||||||
|
|
||||||
fn is_valid(&self, point: Point) -> bool {
|
fn is_valid(&self, point: Point) -> bool {
|
||||||
@@ -693,7 +677,7 @@ impl<'a> Detector<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn distance_points(a: Point, b: Point) -> f32 {
|
fn distance_points(a: Point, b: Point) -> f32 {
|
||||||
Point::from(a).distance(b.into())
|
a.distance(b)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn distance(a: Point, b: Point) -> f32 {
|
fn distance(a: Point, b: Point) -> f32 {
|
||||||
|
|||||||
@@ -225,9 +225,9 @@ impl<'a> EdgeTracer<'_> {
|
|||||||
|
|
||||||
return Ok(StepResult::Found);
|
return Ok(StepResult::Found);
|
||||||
}
|
}
|
||||||
pEdge = pEdge - dEdge;
|
pEdge -= dEdge;
|
||||||
if self.blackAt(pEdge - self.d) {
|
if self.blackAt(pEdge - self.d) {
|
||||||
pEdge = pEdge - self.d;
|
pEdge -= self.d;
|
||||||
}
|
}
|
||||||
// dbg!(pEdge);
|
// dbg!(pEdge);
|
||||||
|
|
||||||
|
|||||||
@@ -43,7 +43,6 @@
|
|||||||
aztec_reader: AztecReader,
|
aztec_reader: AztecReader,
|
||||||
pdf417_reader: PDF417Reader,
|
pdf417_reader: PDF417Reader,
|
||||||
maxicode_reader: MaxiCodeReader,
|
maxicode_reader: MaxiCodeReader,
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reader for MultiUseMultiFormatReader {
|
impl Reader for MultiUseMultiFormatReader {
|
||||||
@@ -177,12 +176,10 @@
|
|||||||
BarcodeFormat::QR_CODE => {
|
BarcodeFormat::QR_CODE => {
|
||||||
self.qr_code_reader.decode_with_hints(image, &self.hints)
|
self.qr_code_reader.decode_with_hints(image, &self.hints)
|
||||||
}
|
}
|
||||||
BarcodeFormat::DATA_MATRIX => {
|
BarcodeFormat::DATA_MATRIX => self
|
||||||
self.data_matrix_reader.decode_with_hints(image, &self.hints)
|
.data_matrix_reader
|
||||||
}
|
.decode_with_hints(image, &self.hints),
|
||||||
BarcodeFormat::AZTEC => {
|
BarcodeFormat::AZTEC => self.aztec_reader.decode_with_hints(image, &self.hints),
|
||||||
self.aztec_reader.decode_with_hints(image, &self.hints)
|
|
||||||
}
|
|
||||||
BarcodeFormat::PDF_417 => {
|
BarcodeFormat::PDF_417 => {
|
||||||
self.pdf417_reader.decode_with_hints(image, &self.hints)
|
self.pdf417_reader.decode_with_hints(image, &self.hints)
|
||||||
}
|
}
|
||||||
@@ -210,7 +207,10 @@
|
|||||||
if let Ok(res) = self.qr_code_reader.decode_with_hints(image, &self.hints) {
|
if let Ok(res) = self.qr_code_reader.decode_with_hints(image, &self.hints) {
|
||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
if let Ok(res) = self.data_matrix_reader.decode_with_hints(image, &self.hints) {
|
if let Ok(res) = self
|
||||||
|
.data_matrix_reader
|
||||||
|
.decode_with_hints(image, &self.hints)
|
||||||
|
{
|
||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
if let Ok(res) = self.aztec_reader.decode_with_hints(image, &self.hints) {
|
if let Ok(res) = self.aztec_reader.decode_with_hints(image, &self.hints) {
|
||||||
@@ -233,4 +233,3 @@
|
|||||||
Err(Exceptions::UNSUPPORTED_OPERATION)
|
Err(Exceptions::UNSUPPORTED_OPERATION)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -235,7 +235,10 @@ impl Point {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn round(self) -> Self {
|
pub fn round(self) -> Self {
|
||||||
Self { x: self.x.round(), y: self.y.round() }
|
Self {
|
||||||
|
x: self.x.round(),
|
||||||
|
y: self.y.round(),
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user