Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

rMQR port from zxing-cpp #43

Merged
merged 36 commits into from
Jan 16, 2024
Merged
Changes from 1 commit
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
bef115a
Gate tests based on feature macros
SamWilsn Jan 11, 2024
7cb00fa
Test --no-default-features in CI
SamWilsn Jan 11, 2024
169f2f6
Allow disabling image features
SamWilsn Jan 11, 2024
4ed49e1
feat: ported qr-model1 support from zxing-cpp
hschimke Jan 11, 2024
d93a515
port: migrate to new cpp Version / FormatInformation
hschimke Jan 11, 2024
5e50394
chore: clippy cleanups
hschimke Jan 11, 2024
415001f
perf: QRCode: skip extra version check
hschimke Jan 11, 2024
86689a8
feat: initial port for Rectangular Micro QR
hschimke Jan 13, 2024
693d1c2
chore: convert bitwise is_odd check to is_odd()
hschimke Jan 13, 2024
6a06762
chore: clippy cleanup
hschimke Jan 13, 2024
c742219
port: QRCode: restructure Format and Version code after rRMQ addition
hschimke Jan 13, 2024
d87ebc5
chore: clippy cleanup
hschimke Jan 14, 2024
3d07788
chore: cargo fmt
hschimke Jan 14, 2024
1a9cc55
port: rMQR: improve pure detection of large symbols
hschimke Jan 14, 2024
30f9ed8
port: rMQR: improve detection rate by using finder sub pattern
hschimke Jan 14, 2024
4136a31
chore: clippy cleanup
hschimke Jan 14, 2024
1ed9adb
port: QRCode: fix crash reported in cpp issue 700
hschimke Jan 14, 2024
b7ea06b
chore: clippy fixes
hschimke Jan 14, 2024
d2b3bf6
Merge pull request #42 from SamWilsn/feature-fixes
hschimke Jan 16, 2024
eea448a
feat: ported qr-model1 support from zxing-cpp
hschimke Jan 11, 2024
deb2de7
port: migrate to new cpp Version / FormatInformation
hschimke Jan 11, 2024
37bde9b
chore: clippy cleanups
hschimke Jan 11, 2024
cf47d8a
perf: QRCode: skip extra version check
hschimke Jan 11, 2024
d31da2f
feat: initial port for Rectangular Micro QR
hschimke Jan 13, 2024
7d6a3ce
chore: convert bitwise is_odd check to is_odd()
hschimke Jan 13, 2024
f4d9766
chore: clippy cleanup
hschimke Jan 13, 2024
42e2910
port: QRCode: restructure Format and Version code after rRMQ addition
hschimke Jan 13, 2024
c9e10ea
chore: clippy cleanup
hschimke Jan 14, 2024
6faf506
chore: cargo fmt
hschimke Jan 14, 2024
9aebf3a
port: rMQR: improve pure detection of large symbols
hschimke Jan 14, 2024
7f02bd0
port: rMQR: improve detection rate by using finder sub pattern
hschimke Jan 14, 2024
4139d83
chore: clippy cleanup
hschimke Jan 14, 2024
595c51a
port: QRCode: fix crash reported in cpp issue 700
hschimke Jan 14, 2024
6edd1f0
chore: clippy fixes
hschimke Jan 14, 2024
fe9e997
Merge branch 'rmqr_port' of github.com:rxing-core/rxing into rmqr_port
hschimke Jan 16, 2024
9261c40
fix: include cfg directive for new test case
hschimke Jan 16, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
chore: clippy cleanup
hschimke committed Jan 14, 2024
commit d87ebc5f73cf097ac4f2176a215864fe19ef24f9
33 changes: 16 additions & 17 deletions src/common/cpp_essentials/base_extentions/qrcode_version.rs
Original file line number Diff line number Diff line change
@@ -150,7 +150,7 @@ impl Version {
let square = |s: i32| point(s, s);
let valid = |v: i32, max: i32| v >= 1 && v <= max;

match (qr_type) {
match qr_type {
Type::Model1 => {
if valid(version, 32) {
square(17 + 4 * version)
@@ -183,7 +183,7 @@ impl Version {
}

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::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),
@@ -200,40 +200,39 @@ impl Version {
}
}
pub fn HasValidSizeType(bitMatrix: &BitMatrix, qr_type: Type) -> bool {
return Self::IsValidSize(
Self::IsValidSize(
point(bitMatrix.width() as i32, bitMatrix.height() as i32),
qr_type,
);
)
}

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::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
.iter()
.position(|p| *p == search)
.and_then(|x| Some(x as i32))
.position(|p| *p == search).map(|x| x as i32)
.unwrap_or(-1)
}

pub fn NumberPoint(size: PointI) -> u32 {
if (size.x != size.y) {
return (Self::IndexOf(&RMQR_SIZES, size) + 1) as u32;
} else if (Self::IsValidSize(size, Type::Model2)) {
return ((size.x as i32 - 17) / 4) as u32;
} else if (Self::IsValidSize(size, Type::Micro)) {
return ((size.x as i32 - 9) / 2) as u32;
if size.x != size.y {
(Self::IndexOf(&RMQR_SIZES, size) + 1) as u32
} else if Self::IsValidSize(size, Type::Model2) {
((size.x - 17) / 4) as u32
} else if Self::IsValidSize(size, Type::Micro) {
((size.x - 9) / 2) as u32
} else {
return 0;
0
}
}

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))
}
}
10 changes: 5 additions & 5 deletions src/qrcode/cpp_port/detector.rs
Original file line number Diff line number Diff line change
@@ -13,7 +13,7 @@ use crate::{
Exceptions, point,
};
use multimap::MultiMap;
use num::Integer;


use crate::{
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]),
)?;

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);

// 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 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);}

// Finder sub pattern
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);
if IsPattern::<E2E, 4, 4, false>(&view, &SUBPATTERN, None, 0.0, 0.0) != 0.0
{return Err(Exceptions::NOT_FOUND);}
@@ -1012,7 +1012,7 @@ pub fn DetectPureRMQR(image: &BitMatrix) -> Result<QRCodeDetectorResult> {
// skip corner / finder / sub pattern edge
cur.stepToEdge(Some(2 + i32::from(cur.isWhite())), None, None);
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);
if !(IsPattern::<E2E, 10,10, false>(&view, &TIMINGPATTERN, None, 0.0, 0.0) != 0.0)
{return Err(Exceptions::NOT_FOUND);}