mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
all tests except SA pass
This commit is contained in:
@@ -137,9 +137,18 @@ impl MultiFormatReader {
|
||||
// Calling all readers again with inverted image
|
||||
image.get_black_matrix_mut().flip_self();
|
||||
let res = self.decode_formats(image);
|
||||
// if let Ok(r) = res.as_mut() {
|
||||
if res.is_ok() {
|
||||
return res;
|
||||
let mut r = res.unwrap();
|
||||
r.putMetadata(
|
||||
crate::RXingResultMetadataType::IS_INVERTED,
|
||||
crate::RXingResultMetadataValue::IsInverted(true),
|
||||
);
|
||||
return Ok(r);
|
||||
}
|
||||
// if res.is_ok() {
|
||||
// return res;
|
||||
// }
|
||||
}
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
@@ -165,12 +174,11 @@ impl MultiFormatReader {
|
||||
for possible_format in self.possible_formats.iter() {
|
||||
let res = match possible_format {
|
||||
BarcodeFormat::QR_CODE => {
|
||||
let default_qr =
|
||||
QRCodeReader::default().decode_with_hints(image, &self.hints);
|
||||
if default_qr.is_ok() {
|
||||
default_qr
|
||||
let cpp = QrReader::default().decode_with_hints(image, &self.hints);
|
||||
if cpp.is_ok() {
|
||||
cpp
|
||||
} else {
|
||||
QrReader::default().decode_with_hints(image, &self.hints)
|
||||
QRCodeReader::default().decode_with_hints(image, &self.hints)
|
||||
}
|
||||
}
|
||||
BarcodeFormat::MICRO_QR_CODE => {
|
||||
@@ -206,10 +214,10 @@ impl MultiFormatReader {
|
||||
}
|
||||
}
|
||||
|
||||
if let Ok(res) = QRCodeReader::default().decode_with_hints(image, &self.hints) {
|
||||
if let Ok(res) = QrReader::default().decode_with_hints(image, &self.hints) {
|
||||
return Ok(res);
|
||||
}
|
||||
if let Ok(res) = QrReader::default().decode_with_hints(image, &self.hints) {
|
||||
if let Ok(res) = QRCodeReader::default().decode_with_hints(image, &self.hints) {
|
||||
return Ok(res);
|
||||
}
|
||||
if let Ok(res) = DataMatrixReader::default().decode_with_hints(image, &self.hints) {
|
||||
|
||||
@@ -150,8 +150,16 @@ impl MultiUseMultiFormatReader {
|
||||
image.get_black_matrix_mut().flip_self();
|
||||
let res = self.decode_formats(image);
|
||||
if res.is_ok() {
|
||||
return res;
|
||||
let mut r = res.unwrap();
|
||||
r.putMetadata(
|
||||
crate::RXingResultMetadataType::IS_INVERTED,
|
||||
crate::RXingResultMetadataValue::IsInverted(true),
|
||||
);
|
||||
return Ok(r);
|
||||
}
|
||||
// if res.is_ok() {
|
||||
// return res;
|
||||
// }
|
||||
}
|
||||
Err(Exceptions::NOT_FOUND)
|
||||
}
|
||||
@@ -177,11 +185,11 @@ impl MultiUseMultiFormatReader {
|
||||
for possible_format in self.possible_formats.iter() {
|
||||
let res = match possible_format {
|
||||
BarcodeFormat::QR_CODE => {
|
||||
let a = self.qr_code_reader.decode_with_hints(image, &self.hints);
|
||||
let a = self.cpp_qrcode_reader.decode_with_hints(image, &self.hints);
|
||||
if a.is_ok() {
|
||||
a
|
||||
} else {
|
||||
self.cpp_qrcode_reader.decode_with_hints(image, &self.hints)
|
||||
self.qr_code_reader.decode_with_hints(image, &self.hints)
|
||||
}
|
||||
}
|
||||
BarcodeFormat::MICRO_QR_CODE => {
|
||||
@@ -214,10 +222,10 @@ impl MultiUseMultiFormatReader {
|
||||
return Ok(res);
|
||||
}
|
||||
}
|
||||
if let Ok(res) = self.qr_code_reader.decode_with_hints(image, &self.hints) {
|
||||
if let Ok(res) = self.cpp_qrcode_reader.decode_with_hints(image, &self.hints) {
|
||||
return Ok(res);
|
||||
}
|
||||
if let Ok(res) = self.cpp_qrcode_reader.decode_with_hints(image, &self.hints) {
|
||||
if let Ok(res) = self.qr_code_reader.decode_with_hints(image, &self.hints) {
|
||||
return Ok(res);
|
||||
}
|
||||
if let Ok(res) = self
|
||||
|
||||
@@ -251,11 +251,13 @@ pub fn GenerateFinderPatternSets(patterns: &mut FinderPatterns) -> FinderPattern
|
||||
// convert from multimap to vector
|
||||
let mut res: FinderPatternSets = Vec::with_capacity(sets.len());
|
||||
|
||||
for (k, v) in sets {
|
||||
for (_, v) in sets {
|
||||
// for (auto& [d, s] : sets)
|
||||
res.extend(v);
|
||||
}
|
||||
|
||||
res.sort_by_key(|i| i.bl.size);
|
||||
|
||||
res
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,8 @@ pub enum RXingResultMetadataType {
|
||||
IS_MIRRORED,
|
||||
|
||||
CONTENT_TYPE,
|
||||
|
||||
IS_INVERTED,
|
||||
}
|
||||
|
||||
impl From<String> for RXingResultMetadataType {
|
||||
@@ -141,6 +143,7 @@ impl From<String> for RXingResultMetadataType {
|
||||
}
|
||||
"IS_MIRRORED" | "ISMIRRORED" => RXingResultMetadataType::IS_MIRRORED,
|
||||
"CONTENT_TYPE" | "CONTENTTYPE" => RXingResultMetadataType::CONTENT_TYPE,
|
||||
"ISINVERTED" => RXingResultMetadataType::IS_INVERTED,
|
||||
_ => RXingResultMetadataType::OTHER,
|
||||
}
|
||||
}
|
||||
@@ -229,4 +232,6 @@ pub enum RXingResultMetadataValue {
|
||||
IsMirrored(bool),
|
||||
|
||||
ContentType(String),
|
||||
|
||||
IsInverted(bool),
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user