mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
add point(x: f32, y: f32) function
Shorter than writing `Point::new`
This commit is contained in:
@@ -23,7 +23,7 @@ use crate::{
|
||||
BitMatrix, DefaultGridSampler, GridSampler, Result,
|
||||
},
|
||||
exceptions::Exceptions,
|
||||
Point, ResultPoint,
|
||||
point, Point, ResultPoint,
|
||||
};
|
||||
|
||||
use super::aztec_detector_result::AztecDetectorRXingResult;
|
||||
@@ -325,10 +325,10 @@ impl<'a> Detector<'_> {
|
||||
|
||||
// Expand the square by .5 pixel in each direction so that we're on the border
|
||||
// between the white square and the black square
|
||||
let pinax = Point::new(pina.get_x() as f32 + 0.5f32, pina.get_y() as f32 - 0.5f32);
|
||||
let pinbx = Point::new(pinb.get_x() as f32 + 0.5f32, pinb.get_y() as f32 + 0.5f32);
|
||||
let pincx = Point::new(pinc.get_x() as f32 - 0.5f32, pinc.get_y() as f32 + 0.5f32);
|
||||
let pindx = Point::new(pind.get_x() as f32 - 0.5f32, pind.get_y() as f32 - 0.5f32);
|
||||
let pinax = point(pina.get_x() as f32 + 0.5f32, pina.get_y() as f32 - 0.5f32);
|
||||
let pinbx = point(pinb.get_x() as f32 + 0.5f32, pinb.get_y() as f32 + 0.5f32);
|
||||
let pincx = point(pinc.get_x() as f32 - 0.5f32, pinc.get_y() as f32 + 0.5f32);
|
||||
let pindx = point(pind.get_x() as f32 - 0.5f32, pind.get_y() as f32 - 0.5f32);
|
||||
|
||||
// Expand the square so that its corners are the centers of the points
|
||||
// just outside the bull's eye.
|
||||
@@ -563,20 +563,20 @@ impl<'a> Detector<'_> {
|
||||
0.max(p1.get_x() - corr),
|
||||
(self.image.getHeight() as i32 - 1).min(p1.get_y() + corr),
|
||||
);
|
||||
// let p1 = Point::new(Math.max(0, p1.getX() - corr), Math.min(image.getHeight() - 1, p1.getY() + corr));
|
||||
// let p1 = point(Math.max(0, p1.getX() - corr), Math.min(image.getHeight() - 1, p1.getY() + corr));
|
||||
let p2 = AztecPoint::new(0.max(p2.get_x() - corr), 0.max(p2.get_y() - corr));
|
||||
// let p2 = Point::new(Math.max(0, p2.getX() - corr), Math.max(0, p2.getY() - corr));
|
||||
// let p2 = point(Math.max(0, p2.getX() - corr), Math.max(0, p2.getY() - corr));
|
||||
let p3 = AztecPoint::new(
|
||||
(self.image.getWidth() as i32 - 1).min(p3.get_x() + corr),
|
||||
0.max((self.image.getHeight() as i32 - 1).min(p3.get_y() - corr)),
|
||||
);
|
||||
// let p3 = Point::new(Math.min(image.getWidth() - 1, p3.getX() + corr),
|
||||
// let p3 = point(Math.min(image.getWidth() - 1, p3.getX() + corr),
|
||||
// Math.max(0, Math.min(image.getHeight() - 1, p3.getY() - corr)));
|
||||
let p4 = AztecPoint::new(
|
||||
(self.image.getWidth() as i32 - 1).min(p4.get_x() + corr),
|
||||
(self.image.getHeight() as i32 - 1).min(p4.get_y() + corr),
|
||||
);
|
||||
// let p4 = Point::new(Math.min(image.getWidth() - 1, p4.getX() + corr),
|
||||
// let p4 = point(Math.min(image.getWidth() - 1, p4.getX() + corr),
|
||||
// Math.min(image.getHeight() - 1, p4.getY() + corr));
|
||||
|
||||
let c_init = self.get_color(p4, p1);
|
||||
@@ -746,7 +746,7 @@ impl AztecPoint {
|
||||
|
||||
impl From<AztecPoint> for Point {
|
||||
fn from(value: AztecPoint) -> Self {
|
||||
Point::new(value.x as f32, value.y as f32)
|
||||
point(value.x as f32, value.y as f32)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -19,7 +19,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
Exceptions, Point, ResultPoint,
|
||||
point, Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -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(Point::new(
|
||||
return Ok(point(
|
||||
lastRange[usize::from(deltaY <= 0)] as f32,
|
||||
lastY as f32,
|
||||
));
|
||||
}
|
||||
return Ok(Point::new(lastRange[0] as f32, lastY as f32));
|
||||
return Ok(point(lastRange[0] as f32, lastY as f32));
|
||||
} else {
|
||||
return Ok(Point::new(lastRange[1] as f32, lastY as f32));
|
||||
return Ok(point(lastRange[1] as f32, lastY as f32));
|
||||
}
|
||||
} else {
|
||||
let lastX = x - deltaX;
|
||||
if lastRange[0] < centerY {
|
||||
if lastRange[1] > centerY {
|
||||
return Ok(Point::new(
|
||||
return Ok(point(
|
||||
lastX as f32,
|
||||
lastRange[usize::from(deltaX >= 0)] as f32,
|
||||
));
|
||||
}
|
||||
return Ok(Point::new(lastX as f32, lastRange[0] as f32));
|
||||
return Ok(point(lastX as f32, lastRange[0] as f32));
|
||||
} else {
|
||||
return Ok(Point::new(lastX as f32, lastRange[1] as f32));
|
||||
return Ok(point(lastX as f32, lastRange[1] as f32));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
Exceptions, Point, ResultPoint,
|
||||
point, Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -288,8 +288,8 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
}
|
||||
|
||||
fn get_black_point_on_segment(&self, a_x: f32, a_y: f32, b_x: f32, b_y: f32) -> Option<Point> {
|
||||
let a = Point::new(a_x, a_y);
|
||||
let b = Point::new(b_x, b_y);
|
||||
let a = point(a_x, a_y);
|
||||
let b = point(b_x, b_y);
|
||||
|
||||
let dist = a.distance(b).round() as i32;
|
||||
let x_step: f32 = (b_x - a_x) / dist as f32;
|
||||
@@ -299,7 +299,7 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
let x = (a_x + i as f32 * x_step).round() as i32;
|
||||
let y = (a_y + i as f32 * y_step).round() as i32;
|
||||
if self.image.get(x as u32, y as u32) {
|
||||
return Some(Point::new(x as f32, y as f32));
|
||||
return Some(point(x as f32, y as f32));
|
||||
}
|
||||
}
|
||||
None
|
||||
@@ -337,17 +337,17 @@ impl<'a> WhiteRectangleDetector<'_> {
|
||||
|
||||
if yi < self.width as f32 / 2.0f32 {
|
||||
[
|
||||
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),
|
||||
point(ti - CORR as f32, tj + CORR as f32),
|
||||
point(zi + CORR as f32, zj + CORR as f32),
|
||||
point(xi - CORR as f32, xj - CORR as f32),
|
||||
point(yi + CORR as f32, yj - CORR as f32),
|
||||
]
|
||||
} else {
|
||||
[
|
||||
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),
|
||||
point(ti + CORR as f32, tj + CORR as f32),
|
||||
point(zi + CORR as f32, zj - CORR as f32),
|
||||
point(xi - CORR as f32, xj + CORR as f32),
|
||||
point(yi - CORR as f32, yj - CORR as f32),
|
||||
]
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ use crate::{
|
||||
common::{
|
||||
detector::WhiteRectangleDetector, BitMatrix, DefaultGridSampler, GridSampler, Result,
|
||||
},
|
||||
Exceptions, Point, ResultPoint,
|
||||
point, Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
use super::DatamatrixDetectorResult;
|
||||
@@ -101,15 +101,15 @@ impl<'a> Detector<'_> {
|
||||
))
|
||||
}
|
||||
|
||||
fn shiftPoint(point: Point, to: Point, div: u32) -> Point {
|
||||
let x = (to.getX() - point.getX()) / (div as f32 + 1.0);
|
||||
let y = (to.getY() - point.getY()) / (div as f32 + 1.0);
|
||||
Point::new(point.getX() + x, point.getY() + y)
|
||||
fn shiftPoint(p: Point, to: Point, div: u32) -> Point {
|
||||
let x = (to.getX() - p.getX()) / (div as f32 + 1.0);
|
||||
let y = (to.getY() - p.getY()) / (div as f32 + 1.0);
|
||||
point(p.getX() + x, p.getY() + y)
|
||||
}
|
||||
|
||||
fn moveAway(point: Point, fromX: f32, fromY: f32) -> Point {
|
||||
let mut x = point.getX();
|
||||
let mut y = point.getY();
|
||||
fn moveAway(p: Point, fromX: f32, fromY: f32) -> Point {
|
||||
let mut x = p.getX();
|
||||
let mut y = p.getY();
|
||||
|
||||
if x < fromX {
|
||||
x -= 1.0;
|
||||
@@ -123,7 +123,7 @@ impl<'a> Detector<'_> {
|
||||
y += 1.0;
|
||||
}
|
||||
|
||||
Point::new(x, y)
|
||||
point(x, y)
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -232,11 +232,11 @@ impl<'a> Detector<'_> {
|
||||
trTop = self.transitionsBetween(pointAs, pointD);
|
||||
trRight = self.transitionsBetween(pointCs, pointD);
|
||||
|
||||
let candidate1 = Point::new(
|
||||
let candidate1 = point(
|
||||
pointD.getX() + (pointC.getX() - pointB.getX()) / (trTop as f32 + 1.0),
|
||||
pointD.getY() + (pointC.getY() - pointB.getY()) / (trTop as f32 + 1.0),
|
||||
);
|
||||
let candidate2 = Point::new(
|
||||
let candidate2 = point(
|
||||
pointD.getX() + (pointA.getX() - pointB.getX()) / (trRight as f32 + 1.0),
|
||||
pointD.getY() + (pointA.getY() - pointB.getY()) / (trRight as f32 + 1.0),
|
||||
);
|
||||
|
||||
@@ -3,7 +3,7 @@ use num::integer::Roots;
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, DefaultGridSampler, DetectorRXingResult, GridSampler, Result},
|
||||
Exceptions, Point,
|
||||
point, Exceptions, Point,
|
||||
};
|
||||
|
||||
use super::MaxiCodeReader;
|
||||
@@ -714,10 +714,10 @@ fn box_symbol(image: &BitMatrix, circle: &mut Circle) -> Result<([(f32, f32); 4]
|
||||
calculate_simple_boundary(circle, Some(image), None, false);
|
||||
|
||||
let naive_box = [
|
||||
Point::new(left_boundary as f32, bottom_boundary as f32),
|
||||
Point::new(left_boundary as f32, top_boundary as f32),
|
||||
Point::new(right_boundary as f32, bottom_boundary as f32),
|
||||
Point::new(right_boundary as f32, top_boundary as f32),
|
||||
point(left_boundary as f32, bottom_boundary as f32),
|
||||
point(left_boundary as f32, top_boundary as f32),
|
||||
point(right_boundary as f32, bottom_boundary as f32),
|
||||
point(right_boundary as f32, top_boundary as f32),
|
||||
];
|
||||
|
||||
#[allow(unused_mut)]
|
||||
@@ -952,10 +952,10 @@ fn attempt_rotation_box(
|
||||
|
||||
Some((
|
||||
[
|
||||
Point::new(new_1.0, new_1.1),
|
||||
Point::new(new_2.0, new_2.1),
|
||||
Point::new(new_3.0, new_3.1),
|
||||
Point::new(new_4.0, new_4.1),
|
||||
point(new_1.0, new_1.1),
|
||||
point(new_2.0, new_2.1),
|
||||
point(new_3.0, new_3.1),
|
||||
point(new_4.0, new_4.1),
|
||||
],
|
||||
final_rotation,
|
||||
))
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::common::Result;
|
||||
use crate::{Exceptions, Point, RXingResult, Reader, ResultPoint};
|
||||
use crate::{point, Exceptions, Point, RXingResult, Reader, ResultPoint};
|
||||
|
||||
/**
|
||||
* This class attempts to decode a barcode from an image, not by scanning the whole image,
|
||||
@@ -124,7 +124,7 @@ impl<T: Reader> ByQuadrantReader<T> {
|
||||
// if !points.is_empty() {
|
||||
|
||||
// // for relative in points {
|
||||
// // result.push(Point::new(
|
||||
// // result.push(point(
|
||||
// // relative.getX() + leftOffset,
|
||||
// // relative.getY() + topOffset,
|
||||
// // ));
|
||||
@@ -133,7 +133,7 @@ impl<T: Reader> ByQuadrantReader<T> {
|
||||
// result
|
||||
points
|
||||
.iter()
|
||||
.map(|relative| Point::new(relative.getX() + leftOffset, relative.getY() + topOffset))
|
||||
.map(|relative| point(relative.getX() + leftOffset, relative.getY() + topOffset))
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,8 +17,8 @@
|
||||
use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
common::Result, BinaryBitmap, DecodingHintDictionary, Exceptions, Point, RXingResult, Reader,
|
||||
ResultPoint,
|
||||
common::Result, point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point, RXingResult,
|
||||
Reader, ResultPoint,
|
||||
};
|
||||
|
||||
use super::MultipleBarcodeReader;
|
||||
@@ -186,7 +186,7 @@ impl<T: Reader> GenericMultipleBarcodeReader<T> {
|
||||
let newPoints: Vec<Point> = oldPoints
|
||||
.iter()
|
||||
.map(|oldPoint| {
|
||||
Point::new(
|
||||
point(
|
||||
oldPoint.getX() + xOffset as f32,
|
||||
oldPoint.getY() + yOffset as f32,
|
||||
)
|
||||
@@ -195,7 +195,7 @@ impl<T: Reader> GenericMultipleBarcodeReader<T> {
|
||||
|
||||
// let mut newPoints = Vec::with_capacity(oldPoints.len());
|
||||
// for oldPoint in oldPoints {
|
||||
// newPoints.push(Point::new(
|
||||
// newPoints.push(point(
|
||||
// oldPoint.getX() + xOffset as f32,
|
||||
// oldPoint.getY() + yOffset as f32,
|
||||
// ));
|
||||
|
||||
@@ -20,7 +20,7 @@ use crate::common::{BitArray, Result};
|
||||
use crate::DecodeHintValue;
|
||||
use crate::Exceptions;
|
||||
use crate::RXingResult;
|
||||
use crate::{BarcodeFormat, Point};
|
||||
use crate::{point, BarcodeFormat};
|
||||
|
||||
use super::OneDReader;
|
||||
|
||||
@@ -171,8 +171,8 @@ impl OneDReader for CodaBarReader {
|
||||
&self.decodeRowRXingResult,
|
||||
Vec::new(),
|
||||
vec![
|
||||
Point::new(left, rowNumber as f32),
|
||||
Point::new(right, rowNumber as f32),
|
||||
point(left, rowNumber as f32),
|
||||
point(right, rowNumber as f32),
|
||||
],
|
||||
BarcodeFormat::CODABAR,
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ use rxing_one_d_proc_derive::OneDReader;
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, Result},
|
||||
BarcodeFormat, Exceptions, Point, RXingResult,
|
||||
point, BarcodeFormat, Exceptions, RXingResult,
|
||||
};
|
||||
|
||||
use super::{one_d_reader, OneDReader};
|
||||
@@ -342,8 +342,8 @@ impl OneDReader for Code128Reader {
|
||||
&result,
|
||||
rawBytes,
|
||||
vec![
|
||||
Point::new(left, rowNumber as f32),
|
||||
Point::new(right, rowNumber as f32),
|
||||
point(left, rowNumber as f32),
|
||||
point(right, rowNumber as f32),
|
||||
],
|
||||
BarcodeFormat::CODE_128,
|
||||
);
|
||||
|
||||
@@ -17,7 +17,7 @@
|
||||
use rxing_one_d_proc_derive::OneDReader;
|
||||
|
||||
use crate::common::{BitArray, Result};
|
||||
use crate::{BarcodeFormat, Exceptions, Point, RXingResult};
|
||||
use crate::{point, BarcodeFormat, Exceptions, RXingResult};
|
||||
|
||||
use super::{one_d_reader, OneDReader};
|
||||
|
||||
@@ -134,8 +134,8 @@ impl OneDReader for Code39Reader {
|
||||
&resultString,
|
||||
Vec::new(),
|
||||
vec![
|
||||
Point::new(left, rowNumber as f32),
|
||||
Point::new(right, rowNumber as f32),
|
||||
point(left, rowNumber as f32),
|
||||
point(right, rowNumber as f32),
|
||||
],
|
||||
BarcodeFormat::CODE_39,
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ use rxing_one_d_proc_derive::OneDReader;
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, Result},
|
||||
BarcodeFormat, Exceptions, Point, RXingResult,
|
||||
point, BarcodeFormat, Exceptions, RXingResult,
|
||||
};
|
||||
|
||||
use super::{one_d_reader, OneDReader};
|
||||
@@ -117,8 +117,8 @@ impl OneDReader for Code93Reader {
|
||||
&resultString,
|
||||
Vec::new(),
|
||||
vec![
|
||||
Point::new(left, rowNumber as f32),
|
||||
Point::new(right, rowNumber as f32),
|
||||
point(left, rowNumber as f32),
|
||||
point(right, rowNumber as f32),
|
||||
],
|
||||
BarcodeFormat::CODE_93,
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ use rxing_one_d_proc_derive::OneDReader;
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, Result},
|
||||
BarcodeFormat, DecodeHintValue, Exceptions, Point, RXingResult,
|
||||
point, BarcodeFormat, DecodeHintValue, Exceptions, RXingResult,
|
||||
};
|
||||
|
||||
use super::{one_d_reader, OneDReader};
|
||||
@@ -150,8 +150,8 @@ impl OneDReader for ITFReader {
|
||||
&resultString,
|
||||
Vec::new(), // no natural byte representation for these barcodes
|
||||
vec![
|
||||
Point::new(startRange[1] as f32, rowNumber as f32),
|
||||
Point::new(endRange[0] as f32, rowNumber as f32),
|
||||
point(startRange[1] as f32, rowNumber as f32),
|
||||
point(endRange[0] as f32, rowNumber as f32),
|
||||
],
|
||||
BarcodeFormat::ITF,
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, Result},
|
||||
BinaryBitmap, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Point,
|
||||
point, BinaryBitmap, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
|
||||
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader, ResultPoint,
|
||||
};
|
||||
|
||||
@@ -117,10 +117,8 @@ pub trait OneDReader: Reader {
|
||||
// And remember to flip the result points horizontally.
|
||||
let points = result.getPointsMut();
|
||||
if !points.is_empty() && points.len() >= 2 {
|
||||
points[0] =
|
||||
Point::new(width as f32 - points[0].getX() - 1.0, points[0].getY());
|
||||
points[1] =
|
||||
Point::new(width as f32 - points[1].getX() - 1.0, points[1].getY());
|
||||
points[0] = point(width as f32 - points[0].getX() - 1.0, points[0].getY());
|
||||
points[1] = point(width as f32 - points[1].getX() - 1.0, points[1].getY());
|
||||
}
|
||||
}
|
||||
return Ok(result);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use std::hash::Hash;
|
||||
|
||||
use crate::Point;
|
||||
use crate::{point, Point};
|
||||
|
||||
/**
|
||||
* Encapsulates an RSS barcode finder pattern, including its start/end position and row.
|
||||
@@ -34,8 +34,8 @@ impl FinderPattern {
|
||||
value,
|
||||
startEnd,
|
||||
resultPoints: vec![
|
||||
Point::new(start as f32, rowNumber as f32),
|
||||
Point::new(end as f32, rowNumber as f32),
|
||||
point(start as f32, rowNumber as f32),
|
||||
point(end as f32, rowNumber as f32),
|
||||
],
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,7 +19,7 @@ use std::collections::HashMap;
|
||||
use crate::{
|
||||
common::{BitArray, Result},
|
||||
oned::{one_d_reader, OneDReader},
|
||||
BarcodeFormat, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Point,
|
||||
point, BarcodeFormat, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions,
|
||||
RXingResult, RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||
};
|
||||
|
||||
@@ -259,7 +259,7 @@ impl RSS14Reader {
|
||||
// row is actually reversed
|
||||
center = row.getSize() as f32 - 1.0 - center;
|
||||
}
|
||||
cb(&Point::new(center, rowNumber as f32));
|
||||
cb(&point(center, rowNumber as f32));
|
||||
}
|
||||
|
||||
let outside = self.decodeDataCharacter(row, &pattern, true)?;
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, Result},
|
||||
BarcodeFormat, Exceptions, Point, RXingResult, RXingResultMetadataType,
|
||||
point, BarcodeFormat, Exceptions, RXingResult, RXingResultMetadataType,
|
||||
RXingResultMetadataValue,
|
||||
};
|
||||
|
||||
@@ -49,11 +49,11 @@ impl UPCEANExtension2Support {
|
||||
&resultString,
|
||||
Vec::new(),
|
||||
vec![
|
||||
Point::new(
|
||||
point(
|
||||
(extensionStartRange[0] + extensionStartRange[1]) as f32 / 2.0,
|
||||
rowNumber as f32,
|
||||
),
|
||||
Point::new(end as f32, rowNumber as f32),
|
||||
point(end as f32, rowNumber as f32),
|
||||
],
|
||||
BarcodeFormat::UPC_EAN_EXTENSION,
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, Result},
|
||||
BarcodeFormat, Exceptions, Point, RXingResult, RXingResultMetadataType,
|
||||
point, BarcodeFormat, Exceptions, RXingResult, RXingResultMetadataType,
|
||||
RXingResultMetadataValue,
|
||||
};
|
||||
|
||||
@@ -51,11 +51,11 @@ impl UPCEANExtension5Support {
|
||||
&resultString,
|
||||
Vec::new(),
|
||||
vec![
|
||||
Point::new(
|
||||
point(
|
||||
(extensionStartRange[0] + extensionStartRange[1]) as f32 / 2.0,
|
||||
rowNumber as f32,
|
||||
),
|
||||
Point::new(end as f32, rowNumber as f32),
|
||||
point(end as f32, rowNumber as f32),
|
||||
],
|
||||
BarcodeFormat::UPC_EAN_EXTENSION,
|
||||
);
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitArray, Result},
|
||||
BarcodeFormat, DecodeHintType, DecodeHintValue, Exceptions, Point, RXingResult,
|
||||
point, BarcodeFormat, DecodeHintType, DecodeHintValue, Exceptions, RXingResult,
|
||||
RXingResultMetadataType, RXingResultMetadataValue, Reader,
|
||||
};
|
||||
|
||||
@@ -156,7 +156,7 @@ pub trait UPCEANReader: OneDReader {
|
||||
let mut symbologyIdentifier = 0;
|
||||
|
||||
if let Some(DecodeHintValue::NeedResultPointCallback(cb)) = resultPointCallback {
|
||||
cb(&Point::new(
|
||||
cb(&point(
|
||||
(startGuardRange[0] + startGuardRange[1]) as f32 / 2.0,
|
||||
rowNumber as f32,
|
||||
));
|
||||
@@ -166,13 +166,13 @@ pub trait UPCEANReader: OneDReader {
|
||||
let endStart = self.decodeMiddle(row, startGuardRange, &mut result)?;
|
||||
|
||||
if let Some(DecodeHintValue::NeedResultPointCallback(cb)) = resultPointCallback {
|
||||
cb(&Point::new(endStart as f32, rowNumber as f32));
|
||||
cb(&point(endStart as f32, rowNumber as f32));
|
||||
}
|
||||
|
||||
let endRange = self.decodeEnd(row, endStart)?;
|
||||
|
||||
if let Some(DecodeHintValue::NeedResultPointCallback(cb)) = resultPointCallback {
|
||||
cb(&Point::new(
|
||||
cb(&point(
|
||||
(endRange[0] + endRange[1]) as f32 / 2.0,
|
||||
rowNumber as f32,
|
||||
));
|
||||
@@ -204,8 +204,8 @@ pub trait UPCEANReader: OneDReader {
|
||||
&resultString,
|
||||
Vec::new(), // no natural byte representation for these barcodes
|
||||
vec![
|
||||
Point::new(left, rowNumber as f32),
|
||||
Point::new(right, rowNumber as f32),
|
||||
point(left, rowNumber as f32),
|
||||
point(right, rowNumber as f32),
|
||||
],
|
||||
format,
|
||||
);
|
||||
|
||||
@@ -18,7 +18,7 @@ use std::rc::Rc;
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
Exceptions, Point, ResultPoint,
|
||||
point, Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -58,13 +58,13 @@ impl BoundingBox {
|
||||
if leftUnspecified {
|
||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomRight = bottomRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopLeft = Point::new(0.0, newTopRight.getY());
|
||||
newBottomLeft = Point::new(0.0, newBottomRight.getY());
|
||||
newTopLeft = point(0.0, newTopRight.getY());
|
||||
newBottomLeft = point(0.0, newBottomRight.getY());
|
||||
} else if rightUnspecified {
|
||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newBottomLeft = bottomLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopRight = Point::new(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
||||
newBottomRight = Point::new(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
||||
newTopRight = point(image.getWidth() as f32 - 1.0, newTopLeft.getY());
|
||||
newBottomRight = point(image.getWidth() as f32 - 1.0, newBottomLeft.getY());
|
||||
} else {
|
||||
newTopLeft = topLeft.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
newTopRight = topRight.ok_or(Exceptions::IllegalStateException(None))?;
|
||||
@@ -144,7 +144,7 @@ impl BoundingBox {
|
||||
if newMinY < 0.0 {
|
||||
newMinY = 0.0;
|
||||
}
|
||||
let newTop = Point::new(top.getX(), newMinY);
|
||||
let newTop = point(top.getX(), newMinY);
|
||||
if isLeft {
|
||||
newTopLeft = newTop;
|
||||
} else {
|
||||
@@ -162,7 +162,7 @@ impl BoundingBox {
|
||||
if newMaxY >= self.image.getHeight() {
|
||||
newMaxY = self.image.getHeight() - 1;
|
||||
}
|
||||
let newBottom = Point::new(bottom.getX(), newMaxY as f32);
|
||||
let newBottom = point(bottom.getX(), newMaxY as f32);
|
||||
if isLeft {
|
||||
newBottomLeft = newBottom;
|
||||
} else {
|
||||
|
||||
@@ -16,7 +16,7 @@
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, Result},
|
||||
BinaryBitmap, DecodingHintDictionary, Exceptions, Point, ResultPoint,
|
||||
point, BinaryBitmap, DecodingHintDictionary, Exceptions, Point, ResultPoint,
|
||||
};
|
||||
|
||||
use std::borrow::Cow;
|
||||
@@ -245,8 +245,8 @@ fn findRowsWithPattern(
|
||||
break;
|
||||
}
|
||||
}
|
||||
result[0] = Some(Point::new(loc_store.as_ref()?[0] as f32, startRow as f32));
|
||||
result[1] = Some(Point::new(loc_store.as_ref()?[1] as f32, startRow as f32));
|
||||
result[0] = Some(point(loc_store.as_ref()?[0] as f32, startRow as f32));
|
||||
result[1] = Some(point(loc_store.as_ref()?[1] as f32, startRow as f32));
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
@@ -294,8 +294,8 @@ fn findRowsWithPattern(
|
||||
stopRow += 1;
|
||||
}
|
||||
stopRow -= skippedRowCount + 1;
|
||||
result[2] = Some(Point::new(previousRowLoc[0] as f32, stopRow as f32));
|
||||
result[3] = Some(Point::new(previousRowLoc[1] as f32, stopRow as f32));
|
||||
result[2] = Some(point(previousRowLoc[0] as f32, stopRow as f32));
|
||||
result[3] = Some(point(previousRowLoc[1] as f32, stopRow as f32));
|
||||
}
|
||||
if stopRow - startRow < BARCODE_MIN_HEIGHT {
|
||||
result.fill(None);
|
||||
|
||||
@@ -18,6 +18,7 @@ use std::collections::HashMap;
|
||||
|
||||
use crate::{
|
||||
common::{BitMatrix, DefaultGridSampler, GridSampler, PerspectiveTransform, Result},
|
||||
point,
|
||||
qrcode::decoder::Version,
|
||||
result_point_utils, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, Point,
|
||||
PointCallback, ResultPoint,
|
||||
@@ -377,8 +378,8 @@ impl<'a> Detector<'_> {
|
||||
if (state == 1) == self.image.get(realX as u32, realY as u32) {
|
||||
if state == 2 {
|
||||
return Point::distance(
|
||||
Point::new(x as f32, y as f32),
|
||||
Point::new(fromX as f32, fromY as f32),
|
||||
point(x as f32, y as f32),
|
||||
point(fromX as f32, fromY as f32),
|
||||
);
|
||||
}
|
||||
state += 1;
|
||||
@@ -400,8 +401,8 @@ impl<'a> Detector<'_> {
|
||||
// small approximation; (toX+xStep,toY+yStep) might be really correct. Ignore this.
|
||||
if state == 2 {
|
||||
return Point::distance(
|
||||
Point::new((toX as i32 + xstep) as f32, toY as f32),
|
||||
Point::new(fromX as f32, fromY as f32),
|
||||
point((toX as i32 + xstep) as f32, toY as f32),
|
||||
point(fromX as f32, fromY as f32),
|
||||
);
|
||||
}
|
||||
// else we didn't find even black-white-black; no estimate is really possible
|
||||
|
||||
@@ -19,6 +19,11 @@ pub struct Point {
|
||||
pub(crate) y: f32,
|
||||
}
|
||||
|
||||
/** An alias for `Point::new`. */
|
||||
pub fn point(x: f32, y: f32) -> Point {
|
||||
Point::new(x, y)
|
||||
}
|
||||
|
||||
/** Currently necessary because the external OneDReader proc macro uses it. */
|
||||
pub type RXingResultPoint = Point;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user