mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-28 05:12:34 +00:00
progress on passing tests
This commit is contained in:
@@ -5,9 +5,11 @@ use crate::{
|
|||||||
},
|
},
|
||||||
BitMatrix, Quadrilateral,
|
BitMatrix, Quadrilateral,
|
||||||
},
|
},
|
||||||
point, Point,
|
point, Point, Exceptions,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
use crate::common::Result;
|
||||||
|
|
||||||
use super::{
|
use super::{
|
||||||
BitMatrixCursorTrait, EdgeTracer, FastEdgeToEdgeCounter, Pattern, RegressionLine,
|
BitMatrixCursorTrait, EdgeTracer, FastEdgeToEdgeCounter, Pattern, RegressionLine,
|
||||||
RegressionLineTrait, UpdateMinMax, UpdateMinMaxFloat,
|
RegressionLineTrait, UpdateMinMax, UpdateMinMaxFloat,
|
||||||
@@ -223,7 +225,7 @@ pub fn CenterOfRing(
|
|||||||
neighbourMask |= 1
|
neighbourMask |= 1
|
||||||
<< (4.0
|
<< (4.0
|
||||||
+ Point::dot(
|
+ Point::dot(
|
||||||
Point::round(Point::bresenhamDirection(cur.p() - center)),
|
Point::floor(Point::bresenhamDirection(cur.p() - center)),
|
||||||
point(1.0, 3.0),
|
point(1.0, 3.0),
|
||||||
)) as u32;
|
)) as u32;
|
||||||
|
|
||||||
@@ -400,12 +402,27 @@ pub fn FitQadrilateralToPoints(center: Point, points: &mut [Point]) -> Option<Qu
|
|||||||
points.iter().position(|p| *p == corners[3])?,
|
points.iter().position(|p| *p == corners[3])?,
|
||||||
];
|
];
|
||||||
|
|
||||||
let lines = [
|
let try_get_range = |a:usize, b:usize| -> Option<&[Point]> {
|
||||||
RegressionLine::with_point_slice(&points[corner_positions[0] + 1..corner_positions[1]]),
|
if a > b {
|
||||||
RegressionLine::with_point_slice(&points[corner_positions[1] + 1..corner_positions[2]]),
|
None
|
||||||
RegressionLine::with_point_slice(&points[corner_positions[2] + 1..corner_positions[3]]),
|
}else{
|
||||||
RegressionLine::with_point_slice(&points[corner_positions[3] + 1..points.len()]),
|
Some(&points[a + 1..b])
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
let lines = [
|
||||||
|
RegressionLine::with_point_slice(try_get_range(corner_positions[0],corner_positions[1])?),
|
||||||
|
RegressionLine::with_point_slice(try_get_range(corner_positions[1],corner_positions[2])?),
|
||||||
|
RegressionLine::with_point_slice(try_get_range(corner_positions[2],corner_positions[3])?),
|
||||||
|
RegressionLine::with_point_slice(try_get_range(corner_positions[3],points.len())?),
|
||||||
];
|
];
|
||||||
|
|
||||||
|
// let lines = [
|
||||||
|
// RegressionLine::with_point_slice(&points[corner_positions[0] + 1..corner_positions[1]]),
|
||||||
|
// RegressionLine::with_point_slice(&points[corner_positions[1] + 1..corner_positions[2]]),
|
||||||
|
// RegressionLine::with_point_slice(&points[corner_positions[2] + 1..corner_positions[3]]),
|
||||||
|
// RegressionLine::with_point_slice(&points[corner_positions[3] + 1..points.len()]),
|
||||||
|
// ];
|
||||||
// std::array lines{RegressionLine{corners[0] + 1, corners[1]}, RegressionLine{corners[1] + 1, corners[2]},
|
// std::array lines{RegressionLine{corners[0] + 1, corners[1]}, RegressionLine{corners[1] + 1, corners[2]},
|
||||||
// RegressionLine{corners[2] + 1, corners[3]}, RegressionLine{corners[3] + 1, &points.back() + 1}};
|
// RegressionLine{corners[2] + 1, corners[3]}, RegressionLine{corners[3] + 1, &points.back() + 1}};
|
||||||
if lines.iter().any(|line| !line.isValid()) {
|
if lines.iter().any(|line| !line.isValid()) {
|
||||||
|
|||||||
@@ -225,7 +225,7 @@ impl RegressionLineTrait for DMRegressionLine {
|
|||||||
impl DMRegressionLine {
|
impl DMRegressionLine {
|
||||||
pub fn new(point_1: Point, point_2: Point) -> Self {
|
pub fn new(point_1: Point, point_2: Point) -> Self {
|
||||||
let mut new = Self::default();
|
let mut new = Self::default();
|
||||||
RegressionLineTrait::evaluate(&mut new, &[point_1, point_1]);
|
RegressionLineTrait::evaluate(&mut new, &[point_1, point_2]);
|
||||||
new
|
new
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -128,7 +128,7 @@ impl ECIStringBuilder {
|
|||||||
|
|
||||||
let ecis = self.list_ecis();
|
let ecis = self.list_ecis();
|
||||||
|
|
||||||
if ecis.len() <= 1 && (ecis.contains(&Eci::Unknown)) {
|
if ecis.len() == 1 && (ecis.contains(&Eci::Unknown)) {
|
||||||
self.has_eci = false;
|
self.has_eci = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use crate::common::Result;
|
use crate::common::Result;
|
||||||
|
use crate::qrcode::cpp_port::QrReader;
|
||||||
use crate::{
|
use crate::{
|
||||||
aztec::AztecReader, datamatrix::DataMatrixReader, maxicode::MaxiCodeReader,
|
aztec::AztecReader, datamatrix::DataMatrixReader, maxicode::MaxiCodeReader,
|
||||||
oned::MultiFormatOneDReader, pdf417::PDF417Reader, qrcode::QRCodeReader, BarcodeFormat,
|
oned::MultiFormatOneDReader, pdf417::PDF417Reader, qrcode::QRCodeReader, BarcodeFormat,
|
||||||
@@ -43,6 +44,7 @@ pub struct MultiUseMultiFormatReader {
|
|||||||
aztec_reader: AztecReader,
|
aztec_reader: AztecReader,
|
||||||
pdf417_reader: PDF417Reader,
|
pdf417_reader: PDF417Reader,
|
||||||
maxicode_reader: MaxiCodeReader,
|
maxicode_reader: MaxiCodeReader,
|
||||||
|
cpp_qrcode_reader: QrReader,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reader for MultiUseMultiFormatReader {
|
impl Reader for MultiUseMultiFormatReader {
|
||||||
@@ -84,6 +86,7 @@ impl Reader for MultiUseMultiFormatReader {
|
|||||||
self.aztec_reader.reset();
|
self.aztec_reader.reset();
|
||||||
self.pdf417_reader.reset();
|
self.pdf417_reader.reset();
|
||||||
self.maxicode_reader.reset();
|
self.maxicode_reader.reset();
|
||||||
|
self.cpp_qrcode_reader.reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,7 +177,15 @@ impl MultiUseMultiFormatReader {
|
|||||||
for possible_format in self.possible_formats.iter() {
|
for possible_format in self.possible_formats.iter() {
|
||||||
let res = match possible_format {
|
let res = match possible_format {
|
||||||
BarcodeFormat::QR_CODE => {
|
BarcodeFormat::QR_CODE => {
|
||||||
self.qr_code_reader.decode_with_hints(image, &self.hints)
|
let a = self.qr_code_reader.decode_with_hints(image, &self.hints);
|
||||||
|
if a.is_ok() {
|
||||||
|
a
|
||||||
|
}else {
|
||||||
|
self.cpp_qrcode_reader.decode_with_hints(image, &self.hints)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
BarcodeFormat::MICRO_QR_CODE => {
|
||||||
|
self.cpp_qrcode_reader.decode_with_hints(image, &self.hints)
|
||||||
}
|
}
|
||||||
BarcodeFormat::DATA_MATRIX => self
|
BarcodeFormat::DATA_MATRIX => self
|
||||||
.data_matrix_reader
|
.data_matrix_reader
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{qrcode::cpp_port::QrReader, BarcodeFormat};
|
use rxing::{qrcode::cpp_port::QrReader, BarcodeFormat, MultiUseMultiFormatReader};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
@@ -187,7 +187,7 @@ fn cpp_qrcode_black_box2_test_case() {
|
|||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/cpp/qrcode-2",
|
"test_resources/blackbox/cpp/qrcode-2",
|
||||||
// MultiFormatReader::default(),
|
// MultiFormatReader::default(),
|
||||||
QrReader {},
|
QrReader::default(),
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.add_test(45, 47, 0.0);
|
tester.add_test(45, 47, 0.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user