mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
wip: Search & replace RXingResultPoint with Point
Build fails because the OneDReader proc macro expects that a RXingResultPoint type exists.
This commit is contained in:
@@ -21,7 +21,7 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::common::Result;
|
||||
use crate::{Exceptions, RXingResultPoint};
|
||||
use crate::{Exceptions, Point};
|
||||
|
||||
use super::BitArray;
|
||||
|
||||
@@ -213,7 +213,7 @@ impl BitMatrix {
|
||||
((self.bits[offset] >> (x & 0x1f)) & 1) != 0
|
||||
}
|
||||
|
||||
pub fn get_point(&self, point: RXingResultPoint) -> bool {
|
||||
pub fn get_point(&self, point: Point) -> bool {
|
||||
self.get(point.x as u32, point.y as u32)
|
||||
// let offset = self.get_offset(point.y as u32, point.x as u32);
|
||||
// ((self.bits[offset] >> (x & 0x1f)) & 1) != 0
|
||||
@@ -695,7 +695,7 @@ impl BitMatrix {
|
||||
new_bm
|
||||
}
|
||||
|
||||
pub fn isIn(&self, p: RXingResultPoint, b: i32) -> bool {
|
||||
pub fn isIn(&self, p: Point, b: i32) -> bool {
|
||||
b as f32 <= p.x
|
||||
&& p.x < self.getWidth() as f32 - b as f32
|
||||
&& b as f32 <= p.y
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
Exceptions, RXingResultPoint, ResultPoint,
|
||||
Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -45,13 +45,13 @@ impl<'a> MonochromeRectangleDetector<'_> {
|
||||
* <p>Detects a rectangular region of black and white -- mostly black -- with a region of mostly
|
||||
* white, in an image.</p>
|
||||
*
|
||||
* @return {@link RXingResultPoint}[] describing the corners of the rectangular region. The first and
|
||||
* @return {@link Point}[] describing the corners of the rectangular region. The first and
|
||||
* last points are opposed on the diagonal, as are the second and third. The first point will be
|
||||
* the topmost point and the last, the bottommost. The second point will be leftmost and the
|
||||
* third, the rightmost
|
||||
* @throws NotFoundException if no Data Matrix Code can be found
|
||||
*/
|
||||
pub fn detect(&self) -> Result<[RXingResultPoint; 4]> {
|
||||
pub fn detect(&self) -> Result<[Point; 4]> {
|
||||
let height = self.image.getHeight() as i32;
|
||||
let width = self.image.getWidth() as i32;
|
||||
let halfHeight = height / 2;
|
||||
@@ -143,7 +143,7 @@ impl<'a> MonochromeRectangleDetector<'_> {
|
||||
* @param bottom maximum value of y
|
||||
* @param maxWhiteRun maximum run of white pixels that can still be considered to be within
|
||||
* the barcode
|
||||
* @return a {@link RXingResultPoint} encapsulating the corner that was found
|
||||
* @return a {@link Point} encapsulating the corner that was found
|
||||
* @throws NotFoundException if such a point cannot be found
|
||||
*/
|
||||
#[allow(clippy::too_many_arguments)]
|
||||
@@ -158,7 +158,7 @@ impl<'a> MonochromeRectangleDetector<'_> {
|
||||
top: i32,
|
||||
bottom: i32,
|
||||
maxWhiteRun: i32,
|
||||
) -> Result<RXingResultPoint> {
|
||||
) -> Result<Point> {
|
||||
let mut lastRange_z: Option<[i32; 2]> = None;
|
||||
let mut y: i32 = centerY;
|
||||
let mut x: i32 = centerX;
|
||||
@@ -178,27 +178,27 @@ impl<'a> MonochromeRectangleDetector<'_> {
|
||||
if lastRange[0] < centerX {
|
||||
if lastRange[1] > centerX {
|
||||
// straddle, choose one or the other based on direction
|
||||
return Ok(RXingResultPoint::new(
|
||||
return Ok(Point::new(
|
||||
lastRange[usize::from(deltaY <= 0)] as f32,
|
||||
lastY as f32,
|
||||
));
|
||||
}
|
||||
return Ok(RXingResultPoint::new(lastRange[0] as f32, lastY as f32));
|
||||
return Ok(Point::new(lastRange[0] as f32, lastY as f32));
|
||||
} else {
|
||||
return Ok(RXingResultPoint::new(lastRange[1] as f32, lastY as f32));
|
||||
return Ok(Point::new(lastRange[1] as f32, lastY as f32));
|
||||
}
|
||||
} else {
|
||||
let lastX = x - deltaX;
|
||||
if lastRange[0] < centerY {
|
||||
if lastRange[1] > centerY {
|
||||
return Ok(RXingResultPoint::new(
|
||||
return Ok(Point::new(
|
||||
lastX as f32,
|
||||
lastRange[usize::from(deltaX >= 0)] as f32,
|
||||
));
|
||||
}
|
||||
return Ok(RXingResultPoint::new(lastX as f32, lastRange[0] as f32));
|
||||
return Ok(Point::new(lastX as f32, lastRange[0] as f32));
|
||||
} else {
|
||||
return Ok(RXingResultPoint::new(lastX as f32, lastRange[1] as f32));
|
||||
return Ok(Point::new(lastX as f32, lastRange[1] as f32));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
Exceptions, RXingResultPoint, ResultPoint,
|
||||
Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
use super::MathUtils;
|
||||
@@ -101,14 +101,14 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
* region until it finds a white rectangular region.
|
||||
* </p>
|
||||
*
|
||||
* @return {@link RXingResultPoint}[] describing the corners of the rectangular
|
||||
* @return {@link Point}[] describing the corners of the rectangular
|
||||
* region. The first and last points are opposed on the diagonal, as
|
||||
* are the second and third. The first point will be the topmost
|
||||
* point and the last, the bottommost. The second point will be
|
||||
* leftmost and the third, the rightmost
|
||||
* @throws NotFoundException if no Data Matrix Code can be found
|
||||
*/
|
||||
pub fn detect(&self) -> Result<[RXingResultPoint; 4]> {
|
||||
pub fn detect(&self) -> Result<[Point; 4]> {
|
||||
let mut left: i32 = self.leftInit;
|
||||
let mut right: i32 = self.rightInit;
|
||||
let mut up: i32 = self.upInit;
|
||||
@@ -212,7 +212,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
if !size_exceeded {
|
||||
let max_size = right - left;
|
||||
|
||||
let mut z: Option<RXingResultPoint> = None;
|
||||
let mut z: Option<Point> = None;
|
||||
let mut i = 1;
|
||||
while z.is_none() && i < max_size {
|
||||
//for (int i = 1; z == null && i < maxSize; i++) {
|
||||
@@ -229,7 +229,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
}
|
||||
|
||||
let mut t: Option<RXingResultPoint> = None;
|
||||
let mut t: Option<Point> = None;
|
||||
//go down right
|
||||
let mut i = 1;
|
||||
while t.is_none() && i < max_size {
|
||||
@@ -247,7 +247,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
}
|
||||
|
||||
let mut x: Option<RXingResultPoint> = None;
|
||||
let mut x: Option<Point> = None;
|
||||
//go down left
|
||||
let mut i = 1;
|
||||
while x.is_none() && i < max_size {
|
||||
@@ -265,7 +265,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
return Err(Exceptions::NotFoundException(None));
|
||||
}
|
||||
|
||||
let mut y: Option<RXingResultPoint> = None;
|
||||
let mut y: Option<Point> = None;
|
||||
//go up left
|
||||
let mut i = 1;
|
||||
while y.is_none() && i < max_size {
|
||||
@@ -295,7 +295,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
a_y: f32,
|
||||
b_x: f32,
|
||||
b_y: f32,
|
||||
) -> Option<RXingResultPoint> {
|
||||
) -> Option<Point> {
|
||||
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 y_step: f32 = (b_y - a_y) / dist as f32;
|
||||
@@ -304,7 +304,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
let x = MathUtils::round(a_x + i as f32 * x_step);
|
||||
let y = MathUtils::round(a_y + i as f32 * y_step);
|
||||
if self.image.get(x as u32, y as u32) {
|
||||
return Some(RXingResultPoint::new(x as f32, y as f32));
|
||||
return Some(Point::new(x as f32, y as f32));
|
||||
}
|
||||
}
|
||||
None
|
||||
@@ -317,7 +317,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
* @param z left most point
|
||||
* @param x right most point
|
||||
* @param t top most point
|
||||
* @return {@link RXingResultPoint}[] describing the corners of the rectangular
|
||||
* @return {@link Point}[] describing the corners of the rectangular
|
||||
* region. The first and last points are opposed on the diagonal, as
|
||||
* are the second and third. The first point will be the topmost
|
||||
* point and the last, the bottommost. The second point will be
|
||||
@@ -325,11 +325,11 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
*/
|
||||
fn center_edges(
|
||||
&self,
|
||||
y: RXingResultPoint,
|
||||
z: RXingResultPoint,
|
||||
x: RXingResultPoint,
|
||||
t: RXingResultPoint,
|
||||
) -> [RXingResultPoint; 4] {
|
||||
y: Point,
|
||||
z: Point,
|
||||
x: Point,
|
||||
t: Point,
|
||||
) -> [Point; 4] {
|
||||
//
|
||||
// t t
|
||||
// z x
|
||||
@@ -348,17 +348,17 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
|
||||
if yi < self.width as f32 / 2.0f32 {
|
||||
[
|
||||
RXingResultPoint::new(ti - CORR as f32, tj + CORR as f32),
|
||||
RXingResultPoint::new(zi + CORR as f32, zj + CORR as f32),
|
||||
RXingResultPoint::new(xi - CORR as f32, xj - CORR as f32),
|
||||
RXingResultPoint::new(yi + CORR as f32, yj - CORR as f32),
|
||||
Point::new(ti - CORR as f32, tj + CORR as f32),
|
||||
Point::new(zi + CORR as f32, zj + CORR as f32),
|
||||
Point::new(xi - CORR as f32, xj - CORR as f32),
|
||||
Point::new(yi + CORR as f32, yj - CORR as f32),
|
||||
]
|
||||
} else {
|
||||
[
|
||||
RXingResultPoint::new(ti + CORR as f32, tj + CORR as f32),
|
||||
RXingResultPoint::new(zi + CORR as f32, zj - CORR as f32),
|
||||
RXingResultPoint::new(xi - CORR as f32, xj + CORR as f32),
|
||||
RXingResultPoint::new(yi - CORR as f32, yj - CORR as f32),
|
||||
Point::new(ti + CORR as f32, tj + CORR as f32),
|
||||
Point::new(zi + CORR as f32, zj - CORR as f32),
|
||||
Point::new(xi - CORR as f32, xj + CORR as f32),
|
||||
Point::new(yi - CORR as f32, yj - CORR as f32),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
pub mod detector;
|
||||
pub mod reedsolomon;
|
||||
|
||||
use crate::RXingResultPoint;
|
||||
use crate::Point;
|
||||
|
||||
#[cfg(test)]
|
||||
mod StringUtilsTestCase;
|
||||
@@ -44,7 +44,7 @@ pub type Result<T, E = crate::Exceptions> = std::result::Result<T, E>;
|
||||
|
||||
// package com.google.zxing.common;
|
||||
|
||||
// import com.google.zxing.RXingResultPoint;
|
||||
// import com.google.zxing.Point;
|
||||
|
||||
/**
|
||||
* <p>Encapsulates the result of detecting a barcode in an image. This includes the raw
|
||||
@@ -56,12 +56,12 @@ pub type Result<T, E = crate::Exceptions> = std::result::Result<T, E>;
|
||||
pub trait DetectorRXingResult {
|
||||
fn getBits(&self) -> &BitMatrix;
|
||||
|
||||
fn getPoints(&self) -> &[RXingResultPoint];
|
||||
fn getPoints(&self) -> &[Point];
|
||||
}
|
||||
|
||||
// pub struct DetectorRXingResult {
|
||||
// bits: BitMatrix,
|
||||
// points: Vec<RXingResultPoint>,
|
||||
// points: Vec<Point>,
|
||||
// }
|
||||
|
||||
mod bit_matrix;
|
||||
|
||||
Reference in New Issue
Block a user