mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 12:22:34 +00:00
Merge branch 'main' into pr/point_refactor
This commit is contained in:
@@ -55,9 +55,7 @@ impl<'a> Detector<'_> {
|
||||
if let Some(point) = self.correctTopRight(&points) {
|
||||
points[3] = point;
|
||||
} else {
|
||||
return Err(Exceptions::NotFoundException(Some(
|
||||
"point 4 unfound".to_owned(),
|
||||
)));
|
||||
return Err(Exceptions::notFoundWith("point 4 unfound"));
|
||||
}
|
||||
// points[3] = self.correctTopRight(&points);
|
||||
// if points[3] == null {
|
||||
|
||||
@@ -247,7 +247,7 @@ fn Scan(
|
||||
));
|
||||
}
|
||||
|
||||
Err(Exceptions::NotFoundException(None))
|
||||
Err(Exceptions::notFound)
|
||||
}
|
||||
|
||||
pub fn detect(
|
||||
@@ -351,6 +351,6 @@ pub fn detect(
|
||||
}
|
||||
|
||||
// #ifndef __cpp_impl_coroutine
|
||||
Err(Exceptions::NotFoundException(None))
|
||||
Err(Exceptions::notFound)
|
||||
// #endif
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ impl RegressionLine for DMRegressionLine {
|
||||
|
||||
fn add(&mut self, p: Point) -> Result<()> {
|
||||
if self.direction_inward == Point::default() {
|
||||
return Err(Exceptions::IllegalStateException(None));
|
||||
return Err(Exceptions::illegalState);
|
||||
}
|
||||
self.points.push(p);
|
||||
if self.points.len() == 1 {
|
||||
@@ -237,7 +237,7 @@ impl DMRegressionLine {
|
||||
|
||||
pub fn modules(&mut self, beg: Point, end: Point) -> Result<f64> {
|
||||
if self.points.len() <= 3 {
|
||||
return Err(Exceptions::IllegalStateException(None));
|
||||
return Err(Exceptions::illegalState);
|
||||
}
|
||||
|
||||
// re-evaluate and filter out all points too far away. required for the gapSizes calculation.
|
||||
@@ -263,12 +263,12 @@ impl DMRegressionLine {
|
||||
self.points
|
||||
.last()
|
||||
.copied()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?
|
||||
.ok_or(Exceptions::indexOutOfBounds)?
|
||||
- self
|
||||
.points
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?,
|
||||
.ok_or(Exceptions::indexOutOfBounds)?,
|
||||
)) as f64;
|
||||
|
||||
// calculate the width of 2 modules (first black pixel to first black pixel)
|
||||
@@ -295,7 +295,7 @@ impl DMRegressionLine {
|
||||
self.points
|
||||
.last()
|
||||
.copied()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?,
|
||||
.ok_or(Exceptions::indexOutOfBounds)?,
|
||||
),
|
||||
) as f64,
|
||||
);
|
||||
|
||||
@@ -203,7 +203,7 @@ impl<'a> EdgeTracer<'_> {
|
||||
if self.whiteAt(pEdge) {
|
||||
// if we are not making any progress, we still have another endless loop bug
|
||||
if self.p == pEdge.centered() {
|
||||
return Err(Exceptions::IllegalStateException(None));
|
||||
return Err(Exceptions::illegalState);
|
||||
}
|
||||
self.p = pEdge.centered();
|
||||
|
||||
@@ -274,7 +274,7 @@ impl<'a> EdgeTracer<'_> {
|
||||
.points()
|
||||
.first()
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?,
|
||||
.ok_or(Exceptions::indexOutOfBounds)?,
|
||||
) {
|
||||
return Ok(false);
|
||||
}
|
||||
@@ -304,9 +304,9 @@ impl<'a> EdgeTracer<'_> {
|
||||
.points()
|
||||
.last()
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?)
|
||||
.ok_or(Exceptions::indexOutOfBounds)?)
|
||||
{
|
||||
return Err(Exceptions::IllegalStateException(None));
|
||||
return Err(Exceptions::illegalState);
|
||||
}
|
||||
if !line.points().is_empty()
|
||||
&& &&self.p
|
||||
@@ -314,7 +314,7 @@ impl<'a> EdgeTracer<'_> {
|
||||
.points()
|
||||
.last()
|
||||
.as_ref()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?
|
||||
.ok_or(Exceptions::indexOutOfBounds)?
|
||||
{
|
||||
return Ok(false);
|
||||
}
|
||||
@@ -358,7 +358,7 @@ impl<'a> EdgeTracer<'_> {
|
||||
line.points()
|
||||
.last()
|
||||
.copied()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?,
|
||||
.ok_or(Exceptions::indexOutOfBounds)?,
|
||||
),
|
||||
) < 1.0
|
||||
{
|
||||
@@ -376,7 +376,7 @@ impl<'a> EdgeTracer<'_> {
|
||||
.points()
|
||||
.last()
|
||||
.copied()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?,
|
||||
.ok_or(Exceptions::indexOutOfBounds)?,
|
||||
)
|
||||
};
|
||||
line.add(self.p)?;
|
||||
@@ -393,7 +393,7 @@ impl<'a> EdgeTracer<'_> {
|
||||
.points()
|
||||
.first()
|
||||
.copied()
|
||||
.ok_or(Exceptions::IndexOutOfBoundsException(None))?,
|
||||
.ok_or(Exceptions::indexOutOfBounds)?,
|
||||
) {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
@@ -24,7 +24,7 @@ pub fn float_max<T: PartialOrd>(a: T, b: T) -> T {
|
||||
#[inline(always)]
|
||||
pub fn intersect(l1: &DMRegressionLine, l2: &DMRegressionLine) -> Result<Point> {
|
||||
if !(l1.isValid() && l2.isValid()) {
|
||||
return Err(Exceptions::IllegalStateException(None));
|
||||
return Err(Exceptions::illegalState);
|
||||
}
|
||||
let d = l1.a * l2.b - l1.b * l2.a;
|
||||
let x = (l1.c * l2.b - l1.b * l2.c) / d;
|
||||
|
||||
Reference in New Issue
Block a user