refactor to use common result type

This commit is contained in:
Vukašin Stepanović
2023-02-14 22:56:03 +00:00
parent 145cf704fe
commit 8ee616d96b
160 changed files with 829 additions and 901 deletions

View File

@@ -17,7 +17,10 @@
//package com.google.zxing.common.detector;
use crate::{common::BitMatrix, Exceptions, RXingResultPoint, ResultPoint};
use crate::{
common::{BitMatrix, Result},
Exceptions, RXingResultPoint, ResultPoint,
};
/**
* <p>A somewhat generic detector that looks for a barcode-like rectangular region within an image.
@@ -48,7 +51,7 @@ impl<'a> MonochromeRectangleDetector<'_> {
* third, the rightmost
* @throws NotFoundException if no Data Matrix Code can be found
*/
pub fn detect(&self) -> Result<[RXingResultPoint; 4], Exceptions> {
pub fn detect(&self) -> Result<[RXingResultPoint; 4]> {
let height = self.image.getHeight() as i32;
let width = self.image.getWidth() as i32;
let halfHeight = height / 2;
@@ -155,7 +158,7 @@ impl<'a> MonochromeRectangleDetector<'_> {
top: i32,
bottom: i32,
maxWhiteRun: i32,
) -> Result<RXingResultPoint, Exceptions> {
) -> Result<RXingResultPoint> {
let mut lastRange_z: Option<[i32; 2]> = None;
let mut y: i32 = centerY;
let mut x: i32 = centerX;

View File

@@ -16,7 +16,10 @@
//package com.google.zxing.common.detector;
use crate::{common::BitMatrix, Exceptions, RXingResultPoint, ResultPoint};
use crate::{
common::{BitMatrix, Result},
Exceptions, RXingResultPoint, ResultPoint,
};
use super::MathUtils;
@@ -43,7 +46,7 @@ pub struct WhiteRectangleDetector<'a> {
}
impl<'a> WhiteRectangleDetector<'_> {
pub fn new_from_image(image: &'a BitMatrix) -> Result<WhiteRectangleDetector<'a>, Exceptions> {
pub fn new_from_image(image: &'a BitMatrix) -> Result<WhiteRectangleDetector<'a>> {
WhiteRectangleDetector::new(
image,
INIT_SIZE,
@@ -64,7 +67,7 @@ impl<'a> WhiteRectangleDetector<'_> {
initSize: i32,
x: i32,
y: i32,
) -> Result<WhiteRectangleDetector<'a>, Exceptions> {
) -> Result<WhiteRectangleDetector<'a>> {
let halfsize = initSize / 2;
let leftInit = x - halfsize;
@@ -105,7 +108,7 @@ impl<'a> WhiteRectangleDetector<'_> {
* leftmost and the third, the rightmost
* @throws NotFoundException if no Data Matrix Code can be found
*/
pub fn detect(&self) -> Result<[RXingResultPoint; 4], Exceptions> {
pub fn detect(&self) -> Result<[RXingResultPoint; 4]> {
let mut left: i32 = self.leftInit;
let mut right: i32 = self.rightInit;
let mut up: i32 = self.upInit;