Merge branch 'main' into pr/exception_helpers

This commit is contained in:
Vukašin Stepanović
2023-02-16 07:15:51 +00:00
161 changed files with 900 additions and 933 deletions

View File

@@ -15,7 +15,7 @@
*/
use crate::{
common::BitMatrix,
common::{BitMatrix, Result},
qrcode::detector::{Detector, QRCodeDetectorResult},
DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
};
@@ -37,10 +37,7 @@ impl<'a> MultiDetector<'_> {
// private static final DetectorRXingResult[] EMPTY_DETECTOR_RESULTS = new DetectorRXingResult[0];
pub fn detectMulti(
&self,
hints: &DecodingHintDictionary,
) -> Result<Vec<QRCodeDetectorResult>, Exceptions> {
pub fn detectMulti(&self, hints: &DecodingHintDictionary) -> Result<Vec<QRCodeDetectorResult>> {
let image = self.0.getImage();
let resultPointCallback = if let Some(DecodeHintValue::NeedResultPointCallback(cb)) =
hints.get(&DecodeHintType::NEED_RESULT_POINT_CALLBACK)

View File

@@ -17,7 +17,7 @@
use std::cmp::Ordering;
use crate::{
common::BitMatrix,
common::{BitMatrix, Result},
qrcode::detector::{FinderPattern, FinderPatternFinder, FinderPatternInfo},
result_point_utils, DecodeHintType, DecodingHintDictionary, Exceptions,
RXingResultPointCallback,
@@ -82,7 +82,7 @@ impl<'a> MultiFinderPatternFinder<'_> {
* size differs from the average among those patterns the least
* @throws NotFoundException if 3 such finder patterns do not exist
*/
fn selectMultipleBestPatterns(&self) -> Result<Vec<[FinderPattern; 3]>, Exceptions> {
fn selectMultipleBestPatterns(&self) -> Result<Vec<[FinderPattern; 3]>> {
let mut possibleCenters = Vec::new();
for fp in self.0.getPossibleCenters() {
if fp.getCount() >= 2 {
@@ -216,10 +216,7 @@ impl<'a> MultiFinderPatternFinder<'_> {
}
}
pub fn findMulti(
&mut self,
hints: &DecodingHintDictionary,
) -> Result<Vec<FinderPatternInfo>, Exceptions> {
pub fn findMulti(&mut self, hints: &DecodingHintDictionary) -> Result<Vec<FinderPatternInfo>> {
let tryHarder = hints.contains_key(&DecodeHintType::TRY_HARDER);
let image = self.0.getImage().clone();
let maxI = image.getHeight();

View File

@@ -17,7 +17,7 @@
use std::{cmp::Ordering, collections::HashMap};
use crate::{
common::DetectorRXingResult,
common::{DetectorRXingResult, Result},
multi::MultipleBarcodeReader,
qrcode::{
decoder::{self, QRCodeDecoderMetaData},
@@ -40,7 +40,7 @@ impl MultipleBarcodeReader for QRCodeMultiReader {
fn decode_multiple(
&mut self,
image: &mut crate::BinaryBitmap,
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
) -> Result<Vec<crate::RXingResult>> {
self.decode_multiple_with_hints(image, &HashMap::new())
}
@@ -48,11 +48,11 @@ impl MultipleBarcodeReader for QRCodeMultiReader {
&mut self,
image: &mut crate::BinaryBitmap,
hints: &crate::DecodingHintDictionary,
) -> Result<Vec<crate::RXingResult>, crate::Exceptions> {
) -> Result<Vec<crate::RXingResult>> {
let mut results = Vec::new();
let detectorRXingResults = MultiDetector::new(image.getBlackMatrix()).detectMulti(hints)?;
for detectorRXingResult in detectorRXingResults {
let mut proc = || -> Result<(), Exceptions> {
let mut proc = || -> Result<()> {
let decoderRXingResult = decoder::qrcode_decoder::decode_bitmatrix_with_hints(
detectorRXingResult.getBits(),
hints,
@@ -126,7 +126,7 @@ impl QRCodeMultiReader {
Self(QRCodeReader::new())
}
fn processStructuredAppend(results: Vec<RXingResult>) -> Result<Vec<RXingResult>, Exceptions> {
fn processStructuredAppend(results: Vec<RXingResult>) -> Result<Vec<RXingResult>> {
let mut newRXingResults = Vec::new();
let mut saRXingResults = Vec::new();
for result in &results {