mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
chore: clippy cleanup
This commit is contained in:
@@ -150,7 +150,7 @@ impl Version {
|
|||||||
let square = |s: i32| point(s, s);
|
let square = |s: i32| point(s, s);
|
||||||
let valid = |v: i32, max: i32| v >= 1 && v <= max;
|
let valid = |v: i32, max: i32| v >= 1 && v <= max;
|
||||||
|
|
||||||
match (qr_type) {
|
match qr_type {
|
||||||
Type::Model1 => {
|
Type::Model1 => {
|
||||||
if valid(version, 32) {
|
if valid(version, 32) {
|
||||||
square(17 + 4 * version)
|
square(17 + 4 * version)
|
||||||
@@ -183,7 +183,7 @@ impl Version {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn IsValidSize(size: PointI, qr_type: Type) -> bool {
|
pub fn IsValidSize(size: PointI, qr_type: Type) -> bool {
|
||||||
match (qr_type) {
|
match qr_type {
|
||||||
Type::Model1 => size.x == size.y && size.x >= 21 && size.x <= 145 && (size.x % 4 == 1),
|
Type::Model1 => size.x == size.y && size.x >= 21 && size.x <= 145 && (size.x % 4 == 1),
|
||||||
Type::Model2 => size.x == size.y && size.x >= 21 && size.x <= 177 && (size.x % 4 == 1),
|
Type::Model2 => size.x == size.y && size.x >= 21 && size.x <= 177 && (size.x % 4 == 1),
|
||||||
Type::Micro => size.x == size.y && size.x >= 11 && size.x <= 17 && (size.x % 2 == 1),
|
Type::Micro => size.x == size.y && size.x >= 11 && size.x <= 17 && (size.x % 2 == 1),
|
||||||
@@ -200,40 +200,39 @@ impl Version {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub fn HasValidSizeType(bitMatrix: &BitMatrix, qr_type: Type) -> bool {
|
pub fn HasValidSizeType(bitMatrix: &BitMatrix, qr_type: Type) -> bool {
|
||||||
return Self::IsValidSize(
|
Self::IsValidSize(
|
||||||
point(bitMatrix.width() as i32, bitMatrix.height() as i32),
|
point(bitMatrix.width() as i32, bitMatrix.height() as i32),
|
||||||
qr_type,
|
qr_type,
|
||||||
);
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn HasValidSize(matrix: &BitMatrix) -> bool {
|
pub fn HasValidSize(matrix: &BitMatrix) -> bool {
|
||||||
return Self::HasValidSizeType(matrix, Type::Model1)
|
Self::HasValidSizeType(matrix, Type::Model1)
|
||||||
|| Self::HasValidSizeType(matrix, Type::Model2)
|
|| Self::HasValidSizeType(matrix, Type::Model2)
|
||||||
|| Self::HasValidSizeType(matrix, Type::Micro)
|
|| Self::HasValidSizeType(matrix, Type::Micro)
|
||||||
|| Self::HasValidSizeType(matrix, Type::RectMicro);
|
|| Self::HasValidSizeType(matrix, Type::RectMicro)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn IndexOf(points: &[PointI], search: PointI) -> i32 {
|
fn IndexOf(_points: &[PointI], search: PointI) -> i32 {
|
||||||
RMQR_SIZES
|
RMQR_SIZES
|
||||||
.iter()
|
.iter()
|
||||||
.position(|p| *p == search)
|
.position(|p| *p == search).map(|x| x as i32)
|
||||||
.and_then(|x| Some(x as i32))
|
|
||||||
.unwrap_or(-1)
|
.unwrap_or(-1)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn NumberPoint(size: PointI) -> u32 {
|
pub fn NumberPoint(size: PointI) -> u32 {
|
||||||
if (size.x != size.y) {
|
if size.x != size.y {
|
||||||
return (Self::IndexOf(&RMQR_SIZES, size) + 1) as u32;
|
(Self::IndexOf(&RMQR_SIZES, size) + 1) as u32
|
||||||
} else if (Self::IsValidSize(size, Type::Model2)) {
|
} else if Self::IsValidSize(size, Type::Model2) {
|
||||||
return ((size.x as i32 - 17) / 4) as u32;
|
((size.x - 17) / 4) as u32
|
||||||
} else if (Self::IsValidSize(size, Type::Micro)) {
|
} else if Self::IsValidSize(size, Type::Micro) {
|
||||||
return ((size.x as i32 - 9) / 2) as u32;
|
((size.x - 9) / 2) as u32
|
||||||
} else {
|
} else {
|
||||||
return 0;
|
0
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn Number(bitMatrix: &BitMatrix) -> u32 {
|
pub fn Number(bitMatrix: &BitMatrix) -> u32 {
|
||||||
return Self::NumberPoint(point(bitMatrix.width() as i32, bitMatrix.height() as i32));
|
Self::NumberPoint(point(bitMatrix.width() as i32, bitMatrix.height() as i32))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ use crate::{
|
|||||||
Exceptions, point,
|
Exceptions, point,
|
||||||
};
|
};
|
||||||
use multimap::MultiMap;
|
use multimap::MultiMap;
|
||||||
use num::Integer;
|
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
common::{
|
common::{
|
||||||
@@ -570,7 +570,7 @@ pub fn SampleQR(image: &BitMatrix, fp: &FinderPatternSet) -> Result<QRCodeDetect
|
|||||||
Quadrilateral::from([fp.tl.p, fp.tr.p, br.p, fp.bl.p]),
|
Quadrilateral::from([fp.tl.p, fp.tr.p, br.p, fp.bl.p]),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
if dimension >= Version::SymbolSize(7, Type::Model2).x as i32 {
|
if dimension >= Version::SymbolSize(7, Type::Model2).x {
|
||||||
let version = ReadVersion(image, dimension as u32, mod2Pix);
|
let version = ReadVersion(image, dimension as u32, mod2Pix);
|
||||||
|
|
||||||
// if the version bits are garbage -> discard the detection
|
// if the version bits are garbage -> discard the detection
|
||||||
@@ -995,12 +995,12 @@ pub fn DetectPureRMQR(image: &BitMatrix) -> Result<QRCodeDetectorResult> {
|
|||||||
let dimW = (width as f32 / moduleSize as f32).floor() as u32;
|
let dimW = (width as f32 / moduleSize as f32).floor() as u32;
|
||||||
let dimH = (height as f32 / moduleSize as f32).floor() as u32;
|
let dimH = (height as f32 / moduleSize as f32).floor() as u32;
|
||||||
|
|
||||||
if (!Version::IsValidSize(point(dimW as i32, dimH as i32), Type::RectMicro))
|
if !Version::IsValidSize(point(dimW as i32, dimH as i32), Type::RectMicro)
|
||||||
{return Err(Exceptions::NOT_FOUND);}
|
{return Err(Exceptions::NOT_FOUND);}
|
||||||
|
|
||||||
// Finder sub pattern
|
// Finder sub pattern
|
||||||
let subdiagonal : SubPattern = EdgeTracer::new(image, br, point_i(-1, -1)).readPatternFromBlack(1,None).ok_or(Exceptions::ILLEGAL_STATE)?;
|
let subdiagonal : SubPattern = EdgeTracer::new(image, br, point_i(-1, -1)).readPatternFromBlack(1,None).ok_or(Exceptions::ILLEGAL_STATE)?;
|
||||||
let subdiagonal_hld = diagonal.to_vec().into();
|
let subdiagonal_hld = subdiagonal.to_vec().into();
|
||||||
let view = PatternView::new(&subdiagonal_hld);
|
let view = PatternView::new(&subdiagonal_hld);
|
||||||
if IsPattern::<E2E, 4, 4, false>(&view, &SUBPATTERN, None, 0.0, 0.0) != 0.0
|
if IsPattern::<E2E, 4, 4, false>(&view, &SUBPATTERN, None, 0.0, 0.0) != 0.0
|
||||||
{return Err(Exceptions::NOT_FOUND);}
|
{return Err(Exceptions::NOT_FOUND);}
|
||||||
@@ -1012,7 +1012,7 @@ pub fn DetectPureRMQR(image: &BitMatrix) -> Result<QRCodeDetectorResult> {
|
|||||||
// skip corner / finder / sub pattern edge
|
// skip corner / finder / sub pattern edge
|
||||||
cur.stepToEdge(Some(2 + i32::from(cur.isWhite())), None, None);
|
cur.stepToEdge(Some(2 + i32::from(cur.isWhite())), None, None);
|
||||||
let timing : TimingPattern = cur.readPattern(None).ok_or(Exceptions::ILLEGAL_STATE)?;
|
let timing : TimingPattern = cur.readPattern(None).ok_or(Exceptions::ILLEGAL_STATE)?;
|
||||||
let timing_hld = diagonal.to_vec().into();
|
let timing_hld = timing.to_vec().into();
|
||||||
let view = PatternView::new(&timing_hld);
|
let view = PatternView::new(&timing_hld);
|
||||||
if !(IsPattern::<E2E, 10,10, false>(&view, &TIMINGPATTERN, None, 0.0, 0.0) != 0.0)
|
if !(IsPattern::<E2E, 10,10, false>(&view, &TIMINGPATTERN, None, 0.0, 0.0) != 0.0)
|
||||||
{return Err(Exceptions::NOT_FOUND);}
|
{return Err(Exceptions::NOT_FOUND);}
|
||||||
|
|||||||
Reference in New Issue
Block a user