clippy --fix && fmt

This commit is contained in:
Henry Schimke
2023-03-06 11:37:37 -06:00
parent fe8f89cd29
commit bef21af81e
6 changed files with 269 additions and 299 deletions

View File

@@ -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());

View File

@@ -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);
@@ -639,20 +617,23 @@ impl<'a> Detector<'_> {
* Gets the coordinate of the first point with a different color in the given direction * Gets the coordinate of the first point with a different color in the given direction
*/ */
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 {
@@ -707,4 +691,4 @@ impl<'a> Detector<'_> {
4 * self.nb_layers + 2 * ((2 * self.nb_layers + 6) / 15) + 15 4 * self.nb_layers + 2 * ((2 * self.nb_layers + 6) / 15) + 15
} }
} }
} }

View File

@@ -28,16 +28,16 @@ use crate::Exceptions;
#[derive(Debug, PartialEq, Eq, Clone, Copy)] #[derive(Debug, PartialEq, Eq, Clone, Copy)]
pub enum CharacterSet { pub enum CharacterSet {
// Enum name is a Java encoding valid for java.lang and java.io // Enum name is a Java encoding valid for java.lang and java.io
Cp437, //(new int[]{0,2}), Cp437, //(new int[]{0,2}),
ISO8859_1, //(new int[]{1,3}, "ISO-8859-1"), ISO8859_1, //(new int[]{1,3}, "ISO-8859-1"),
ISO8859_2, //(4, "ISO-8859-2"), ISO8859_2, //(4, "ISO-8859-2"),
ISO8859_3, //(5, "ISO-8859-3"), ISO8859_3, //(5, "ISO-8859-3"),
ISO8859_4, //(6, "ISO-8859-4"), ISO8859_4, //(6, "ISO-8859-4"),
ISO8859_5, //(7, "ISO-8859-5"), ISO8859_5, //(7, "ISO-8859-5"),
// ISO8859_6, //(8, "ISO-8859-6"), // ISO8859_6, //(8, "ISO-8859-6"),
ISO8859_7, //(9, "ISO-8859-7"), ISO8859_7, //(9, "ISO-8859-7"),
// ISO8859_8, //(10, "ISO-8859-8"), // ISO8859_8, //(10, "ISO-8859-8"),
ISO8859_9, //(11, "ISO-8859-9"), ISO8859_9, //(11, "ISO-8859-9"),
// ISO8859_10, //(12, "ISO-8859-10"), // ISO8859_10, //(12, "ISO-8859-10"),
// ISO8859_11, //(13, "ISO-8859-11"), // ISO8859_11, //(13, "ISO-8859-11"),
ISO8859_13, //(15, "ISO-8859-13"), ISO8859_13, //(15, "ISO-8859-13"),

View File

@@ -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);

View File

@@ -14,223 +14,222 @@
* limitations under the License. * limitations under the License.
*/ */
use std::collections::{HashMap, HashSet}; use std::collections::{HashMap, HashSet};
use crate::common::Result; use crate::common::Result;
use crate::{ use crate::{
aztec::AztecReader, datamatrix::DataMatrixReader, maxicode::MaxiCodeReader, aztec::AztecReader, datamatrix::DataMatrixReader, maxicode::MaxiCodeReader,
oned::MultiFormatOneDReader, pdf417::PDF417Reader, qrcode::QRCodeReader, BarcodeFormat, oned::MultiFormatOneDReader, pdf417::PDF417Reader, qrcode::QRCodeReader, BarcodeFormat,
Binarizer, BinaryBitmap, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Binarizer, BinaryBitmap, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
RXingResult, Reader, RXingResult, Reader,
}; };
/**
* MultiFormatReader is a convenience class and the main entry point into the library for most uses.
* By default it attempts to decode all barcode formats that the library supports. Optionally, you
* can provide a hints object to request different behavior, for example only decoding QR codes.
*
* @author Sean Owen
* @author dswitkin@google.com (Daniel Switkin)
*/
#[derive(Default)]
pub struct MultiUseMultiFormatReader {
hints: DecodingHintDictionary,
possible_formats: HashSet<BarcodeFormat>,
try_harder: bool,
one_d_reader: MultiFormatOneDReader,
qr_code_reader: QRCodeReader,
data_matrix_reader: DataMatrixReader,
aztec_reader: AztecReader,
pdf417_reader: PDF417Reader,
maxicode_reader: MaxiCodeReader,
} /**
* MultiFormatReader is a convenience class and the main entry point into the library for most uses.
impl Reader for MultiUseMultiFormatReader { * By default it attempts to decode all barcode formats that the library supports. Optionally, you
/** * can provide a hints object to request different behavior, for example only decoding QR codes.
* This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it *
* passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly. * @author Sean Owen
* Use setHints() followed by decodeWithState() for continuous scan applications. * @author dswitkin@google.com (Daniel Switkin)
* */
* @param image The pixel data to decode #[derive(Default)]
* @return The contents of the image pub struct MultiUseMultiFormatReader {
* @throws NotFoundException Any errors which occurred hints: DecodingHintDictionary,
*/ possible_formats: HashSet<BarcodeFormat>,
fn decode<B: Binarizer>(&mut self, image: &mut BinaryBitmap<B>) -> Result<RXingResult> { try_harder: bool,
self.set_hints(&HashMap::new()); one_d_reader: MultiFormatOneDReader,
self.decode_internal(image) qr_code_reader: QRCodeReader,
} data_matrix_reader: DataMatrixReader,
aztec_reader: AztecReader,
/** pdf417_reader: PDF417Reader,
* Decode an image using the hints provided. Does not honor existing state. maxicode_reader: MaxiCodeReader,
* }
* @param image The pixel data to decode
* @param hints The hints to use, clearing the previous state. impl Reader for MultiUseMultiFormatReader {
* @return The contents of the image /**
* @throws NotFoundException Any errors which occurred * This version of decode honors the intent of Reader.decode(BinaryBitmap) in that it
*/ * passes null as a hint to the decoders. However, that makes it inefficient to call repeatedly.
fn decode_with_hints<B: Binarizer>( * Use setHints() followed by decodeWithState() for continuous scan applications.
&mut self, *
image: &mut BinaryBitmap<B>, * @param image The pixel data to decode
hints: &DecodingHintDictionary, * @return The contents of the image
) -> Result<RXingResult> { * @throws NotFoundException Any errors which occurred
self.set_hints(hints); */
self.decode_internal(image) fn decode<B: Binarizer>(&mut self, image: &mut BinaryBitmap<B>) -> Result<RXingResult> {
} self.set_hints(&HashMap::new());
self.decode_internal(image)
fn reset(&mut self) { }
self.one_d_reader.reset();
self.qr_code_reader.reset(); /**
self.data_matrix_reader.reset(); * Decode an image using the hints provided. Does not honor existing state.
self.aztec_reader.reset(); *
self.pdf417_reader.reset(); * @param image The pixel data to decode
self.maxicode_reader.reset(); * @param hints The hints to use, clearing the previous state.
} * @return The contents of the image
} * @throws NotFoundException Any errors which occurred
*/
impl MultiUseMultiFormatReader { fn decode_with_hints<B: Binarizer>(
/** &mut self,
* Decode an image using the state set up by calling setHints() previously. Continuous scan image: &mut BinaryBitmap<B>,
* clients will get a <b>large</b> speed increase by using this instead of decode(). hints: &DecodingHintDictionary,
* ) -> Result<RXingResult> {
* @param image The pixel data to decode self.set_hints(hints);
* @return The contents of the image self.decode_internal(image)
* @throws NotFoundException Any errors which occurred }
*/
pub fn decode_with_state<B: Binarizer>( fn reset(&mut self) {
&mut self, self.one_d_reader.reset();
image: &mut BinaryBitmap<B>, self.qr_code_reader.reset();
) -> Result<RXingResult> { self.data_matrix_reader.reset();
// Make sure to set up the default state so we don't crash self.aztec_reader.reset();
if self.possible_formats.is_empty() { self.pdf417_reader.reset();
self.set_hints(&HashMap::new()); self.maxicode_reader.reset();
} }
self.decode_internal(image) }
}
impl MultiUseMultiFormatReader {
/** /**
* This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls * Decode an image using the state set up by calling setHints() previously. Continuous scan
* to decodeWithState(image) can reuse the same set of readers without reallocating memory. This * clients will get a <b>large</b> speed increase by using this instead of decode().
* is important for performance in continuous scan clients. *
* * @param image The pixel data to decode
* @param hints The set of hints to use for subsequent calls to decode(image) * @return The contents of the image
*/ * @throws NotFoundException Any errors which occurred
pub fn set_hints(&mut self, hints: &DecodingHintDictionary) { */
self.hints = hints.clone(); pub fn decode_with_state<B: Binarizer>(
&mut self,
self.try_harder = matches!( image: &mut BinaryBitmap<B>,
self.hints.get(&DecodeHintType::TRY_HARDER), ) -> Result<RXingResult> {
Some(DecodeHintValue::TryHarder(true)) // Make sure to set up the default state so we don't crash
); if self.possible_formats.is_empty() {
self.possible_formats = if let Some(DecodeHintValue::PossibleFormats(formats)) = self.set_hints(&HashMap::new());
hints.get(&DecodeHintType::POSSIBLE_FORMATS) }
{ self.decode_internal(image)
formats.clone() }
} else {
HashSet::new() /**
}; * This method adds state to the MultiFormatReader. By setting the hints once, subsequent calls
self.one_d_reader = MultiFormatOneDReader::new(hints); * to decodeWithState(image) can reuse the same set of readers without reallocating memory. This
} * is important for performance in continuous scan clients.
*
pub fn decode_internal<B: Binarizer>( * @param hints The set of hints to use for subsequent calls to decode(image)
&mut self, */
image: &mut BinaryBitmap<B>, pub fn set_hints(&mut self, hints: &DecodingHintDictionary) {
) -> Result<RXingResult> { self.hints = hints.clone();
let res = self.decode_formats(image);
if res.is_ok() { self.try_harder = matches!(
return res; self.hints.get(&DecodeHintType::TRY_HARDER),
} Some(DecodeHintValue::TryHarder(true))
if matches!( );
self.hints.get(&DecodeHintType::ALSO_INVERTED), self.possible_formats = if let Some(DecodeHintValue::PossibleFormats(formats)) =
Some(DecodeHintValue::AlsoInverted(true)) hints.get(&DecodeHintType::POSSIBLE_FORMATS)
) { {
// Calling all readers again with inverted image formats.clone()
image.get_black_matrix_mut().flip_self(); } else {
let res = self.decode_formats(image); HashSet::new()
if res.is_ok() { };
return res; self.one_d_reader = MultiFormatOneDReader::new(hints);
} }
}
Err(Exceptions::NOT_FOUND) pub fn decode_internal<B: Binarizer>(
} &mut self,
image: &mut BinaryBitmap<B>,
fn decode_formats<B: Binarizer>(&mut self, image: &mut BinaryBitmap<B>) -> Result<RXingResult> { ) -> Result<RXingResult> {
if !self.possible_formats.is_empty() { let res = self.decode_formats(image);
let one_d = self.possible_formats.contains(&BarcodeFormat::UPC_A) if res.is_ok() {
|| self.possible_formats.contains(&BarcodeFormat::UPC_E) return res;
|| self.possible_formats.contains(&BarcodeFormat::EAN_13) }
|| self.possible_formats.contains(&BarcodeFormat::EAN_8) if matches!(
|| self.possible_formats.contains(&BarcodeFormat::CODABAR) self.hints.get(&DecodeHintType::ALSO_INVERTED),
|| self.possible_formats.contains(&BarcodeFormat::CODE_39) Some(DecodeHintValue::AlsoInverted(true))
|| self.possible_formats.contains(&BarcodeFormat::CODE_93) ) {
|| self.possible_formats.contains(&BarcodeFormat::CODE_128) // Calling all readers again with inverted image
|| self.possible_formats.contains(&BarcodeFormat::ITF) image.get_black_matrix_mut().flip_self();
|| self.possible_formats.contains(&BarcodeFormat::RSS_14) let res = self.decode_formats(image);
|| self.possible_formats.contains(&BarcodeFormat::RSS_EXPANDED); if res.is_ok() {
if one_d && !self.try_harder { return res;
if let Ok(res) = self.one_d_reader.decode_with_hints(image, &self.hints) { }
return Ok(res); }
} Err(Exceptions::NOT_FOUND)
} }
for possible_format in self.possible_formats.iter() {
let res = match possible_format { fn decode_formats<B: Binarizer>(&mut self, image: &mut BinaryBitmap<B>) -> Result<RXingResult> {
BarcodeFormat::QR_CODE => { if !self.possible_formats.is_empty() {
self.qr_code_reader.decode_with_hints(image, &self.hints) let one_d = self.possible_formats.contains(&BarcodeFormat::UPC_A)
} || self.possible_formats.contains(&BarcodeFormat::UPC_E)
BarcodeFormat::DATA_MATRIX => { || self.possible_formats.contains(&BarcodeFormat::EAN_13)
self.data_matrix_reader.decode_with_hints(image, &self.hints) || self.possible_formats.contains(&BarcodeFormat::EAN_8)
} || self.possible_formats.contains(&BarcodeFormat::CODABAR)
BarcodeFormat::AZTEC => { || self.possible_formats.contains(&BarcodeFormat::CODE_39)
self.aztec_reader.decode_with_hints(image, &self.hints) || self.possible_formats.contains(&BarcodeFormat::CODE_93)
} || self.possible_formats.contains(&BarcodeFormat::CODE_128)
BarcodeFormat::PDF_417 => { || self.possible_formats.contains(&BarcodeFormat::ITF)
self.pdf417_reader.decode_with_hints(image, &self.hints) || self.possible_formats.contains(&BarcodeFormat::RSS_14)
} || self.possible_formats.contains(&BarcodeFormat::RSS_EXPANDED);
BarcodeFormat::MAXICODE => { if one_d && !self.try_harder {
self.maxicode_reader.decode_with_hints(image, &self.hints) if let Ok(res) = self.one_d_reader.decode_with_hints(image, &self.hints) {
} return Ok(res);
_ => Err(Exceptions::UNSUPPORTED_OPERATION), }
}; }
if res.is_ok() { for possible_format in self.possible_formats.iter() {
return res; let res = match possible_format {
} BarcodeFormat::QR_CODE => {
} self.qr_code_reader.decode_with_hints(image, &self.hints)
if one_d && self.try_harder { }
if let Ok(res) = self.one_d_reader.decode_with_hints(image, &self.hints) { BarcodeFormat::DATA_MATRIX => self
return Ok(res); .data_matrix_reader
} .decode_with_hints(image, &self.hints),
} BarcodeFormat::AZTEC => self.aztec_reader.decode_with_hints(image, &self.hints),
} else { BarcodeFormat::PDF_417 => {
if !self.try_harder { self.pdf417_reader.decode_with_hints(image, &self.hints)
if let Ok(res) = self.one_d_reader.decode_with_hints(image, &self.hints) { }
return Ok(res); BarcodeFormat::MAXICODE => {
} self.maxicode_reader.decode_with_hints(image, &self.hints)
} }
_ => Err(Exceptions::UNSUPPORTED_OPERATION),
if let Ok(res) = self.qr_code_reader.decode_with_hints(image, &self.hints) { };
return Ok(res); if res.is_ok() {
} return res;
if let Ok(res) = self.data_matrix_reader.decode_with_hints(image, &self.hints) { }
return Ok(res); }
} if one_d && self.try_harder {
if let Ok(res) = self.aztec_reader.decode_with_hints(image, &self.hints) { if let Ok(res) = self.one_d_reader.decode_with_hints(image, &self.hints) {
return Ok(res); return Ok(res);
} }
if let Ok(res) = self.pdf417_reader.decode_with_hints(image, &self.hints) { }
return Ok(res); } else {
} if !self.try_harder {
if let Ok(res) = self.maxicode_reader.decode_with_hints(image, &self.hints) { if let Ok(res) = self.one_d_reader.decode_with_hints(image, &self.hints) {
return Ok(res); return Ok(res);
} }
}
if self.try_harder {
if let Ok(res) = self.one_d_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)
Err(Exceptions::UNSUPPORTED_OPERATION) {
} return Ok(res);
} }
if let Ok(res) = self.aztec_reader.decode_with_hints(image, &self.hints) {
return Ok(res);
}
if let Ok(res) = self.pdf417_reader.decode_with_hints(image, &self.hints) {
return Ok(res);
}
if let Ok(res) = self.maxicode_reader.decode_with_hints(image, &self.hints) {
return Ok(res);
}
if self.try_harder {
if let Ok(res) = self.one_d_reader.decode_with_hints(image, &self.hints) {
return Ok(res);
}
}
}
Err(Exceptions::UNSUPPORTED_OPERATION)
}
}

View File

@@ -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(),
}
} }
} }
@@ -251,8 +254,8 @@ impl From<(f32, f32)> for Point {
} }
} }
impl From<(i32,i32)> for Point { impl From<(i32, i32)> for Point {
fn from(value: (i32,i32)) -> Self { fn from(value: (i32, i32)) -> Self {
Self::new(value.0 as f32, value.1 as f32) Self::new(value.0 as f32, value.1 as f32)
} }
} }