mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
stage: clippy fix and gate dxo_edge_reader
This commit is contained in:
@@ -205,7 +205,7 @@ impl<B: Binarizer> BinaryBitmap<B> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_source(&self) -> &B::Source {
|
pub fn get_source(&self) -> &B::Source {
|
||||||
&self.binarizer.get_luminance_source()
|
self.binarizer.get_luminance_source()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn get_binarizer(&self) -> &B {
|
pub fn get_binarizer(&self) -> &B {
|
||||||
|
|||||||
@@ -320,12 +320,12 @@ fn test_xor_2() {
|
|||||||
match i {
|
match i {
|
||||||
1 => assert_eq!(array_1.getBitArray(), &[0b1]),
|
1 => assert_eq!(array_1.getBitArray(), &[0b1]),
|
||||||
2 => assert_eq!(array_1.getBitArray(), &[0b10]),
|
2 => assert_eq!(array_1.getBitArray(), &[0b10]),
|
||||||
3 => assert_eq!(array_1.getBitArray(), &[0b10_1]),
|
3 => assert_eq!(array_1.getBitArray(), &[0b101]),
|
||||||
4 => assert_eq!(array_1.getBitArray(), &[0b10_10]),
|
4 => assert_eq!(array_1.getBitArray(), &[0b10_10]),
|
||||||
5 => assert_eq!(array_1.getBitArray(), &[0b10_10_1]),
|
5 => assert_eq!(array_1.getBitArray(), &[0b1_0101]),
|
||||||
6 => assert_eq!(array_1.getBitArray(), &[0b10_10_11]),
|
6 => assert_eq!(array_1.getBitArray(), &[0b10_10_11]),
|
||||||
7..=24 => assert_eq!(array_1.getBitArray(), &[0b10_10_11 << (i - 6)], "{i}"),
|
7..=24 => assert_eq!(array_1.getBitArray(), &[0b10_10_11 << (i - 6)], "{i}"),
|
||||||
_ => assert_eq!(array_1.getBitArray(), &[0b10_10_11 << i - 6, 0], "{i}"),
|
_ => assert_eq!(array_1.getBitArray(), &[0b10_10_11 << (i - 6), 0], "{i}"),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ impl<LS: LuminanceSource> AdaptiveThresholdBinarizer<LS> {
|
|||||||
};
|
};
|
||||||
|
|
||||||
let filtered_iamge =
|
let filtered_iamge =
|
||||||
imageproc::contrast::adaptive_threshold(&image_buffer, self.radius.into());
|
imageproc::contrast::adaptive_threshold(&image_buffer, self.radius);
|
||||||
|
|
||||||
let dynamic_filtered = DynamicImage::from(filtered_iamge);
|
let dynamic_filtered = DynamicImage::from(filtered_iamge);
|
||||||
|
|
||||||
@@ -79,7 +79,7 @@ impl<LS: LuminanceSource> Binarizer for AdaptiveThresholdBinarizer<LS> {
|
|||||||
Self: Sized,
|
Self: Sized,
|
||||||
{
|
{
|
||||||
Self {
|
Self {
|
||||||
source: source,
|
source,
|
||||||
matrix: OnceCell::new(),
|
matrix: OnceCell::new(),
|
||||||
radius: self.radius,
|
radius: self.radius,
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -76,10 +76,10 @@ impl BitMatrix {
|
|||||||
Ok(Self {
|
Ok(Self {
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
row_size: ((width as usize + BASE_BITS - 1) / BASE_BITS) as usize,
|
row_size: ((width as usize + BASE_BITS - 1) / BASE_BITS),
|
||||||
bits: vec![
|
bits: vec![
|
||||||
0;
|
0;
|
||||||
(((width as usize + BASE_BITS - 1) / BASE_BITS) * height as usize) as usize
|
((width as usize + BASE_BITS - 1) / BASE_BITS) * height as usize
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
// this.width = width;
|
// this.width = width;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
use crate::common::cpp_essentials::PatternRow;
|
|
||||||
use crate::common::BitMatrix;
|
use crate::common::BitMatrix;
|
||||||
use crate::common::Result;
|
use crate::common::Result;
|
||||||
use crate::point_f;
|
use crate::point_f;
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
use std::iter::Sum;
|
use std::iter::Sum;
|
||||||
use std::ops::Shl;
|
|
||||||
|
|
||||||
use crate::common::Result;
|
use crate::common::Result;
|
||||||
use crate::qrcode::cpp_port::detector::AppendBit;
|
use crate::qrcode::cpp_port::detector::AppendBit;
|
||||||
@@ -80,10 +80,10 @@ pub fn ToInt(a: &[u32]) -> Option<u32> {
|
|||||||
let mut pattern = 0;
|
let mut pattern = 0;
|
||||||
for (i, element) in a.iter().copied().enumerate() {
|
for (i, element) in a.iter().copied().enumerate() {
|
||||||
// for (int i = 0; i < Size(a); i++)
|
// for (int i = 0; i < Size(a); i++)
|
||||||
pattern = (pattern << element) | !(0xffffffff << element) * (!i & 1) as u32;
|
pattern = (pattern << element) | (!(0xffffffff << element) * (!i & 1) as u32);
|
||||||
}
|
}
|
||||||
|
|
||||||
return Some(pattern);
|
Some(pattern)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn ToIntPos(
|
pub fn ToIntPos(
|
||||||
@@ -94,7 +94,7 @@ pub fn ToIntPos(
|
|||||||
// assert(0 <= count && count <= 8 * (int)sizeof(T));
|
// assert(0 <= count && count <= 8 * (int)sizeof(T));
|
||||||
// assert(0 <= pos && pos + count <= bits.size());
|
// assert(0 <= pos && pos + count <= bits.size());
|
||||||
|
|
||||||
let count = std::cmp::min(count as usize, bits.len());
|
let count = std::cmp::min(count, bits.len());
|
||||||
let mut res = 0;
|
let mut res = 0;
|
||||||
for bit in bits.iter().skip(pos).take(count) {
|
for bit in bits.iter().skip(pos).take(count) {
|
||||||
AppendBit(&mut res, bit == &0);
|
AppendBit(&mut res, bit == &0);
|
||||||
@@ -103,5 +103,5 @@ pub fn ToIntPos(
|
|||||||
// for (int i = 0; i < count; ++i, ++it)
|
// for (int i = 0; i < count; ++i, ++it)
|
||||||
// {AppendBit(res, *it);}
|
// {AppendBit(res, *it);}
|
||||||
|
|
||||||
return Some(res as u32);
|
Some(res as u32)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -40,7 +40,7 @@ impl LuminanceSource for Luma8LuminanceSource {
|
|||||||
.chunks_exact(self.original_dimension.0 as usize)
|
.chunks_exact(self.original_dimension.0 as usize)
|
||||||
.skip(self.origin.1 as usize)
|
.skip(self.origin.1 as usize)
|
||||||
.fold(Vec::default(), |mut acc, e| {
|
.fold(Vec::default(), |mut acc, e| {
|
||||||
acc.push(e[self.origin.0 as usize + x as usize]);
|
acc.push(e[self.origin.0 as usize + x]);
|
||||||
acc
|
acc
|
||||||
})
|
})
|
||||||
.iter()
|
.iter()
|
||||||
|
|||||||
@@ -1143,7 +1143,7 @@ mod detector_test {
|
|||||||
.read_to_string(&mut expected_result)
|
.read_to_string(&mut expected_result)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let detection = super::detect(&bitmatrix, true).unwrap();
|
let detection = super::detect(bitmatrix, true).unwrap();
|
||||||
|
|
||||||
// let i: image::DynamicImage = detection.getBits().into();
|
// let i: image::DynamicImage = detection.getBits().into();
|
||||||
// i.save("dbgfle-transformed.png")
|
// i.save("dbgfle-transformed.png")
|
||||||
|
|||||||
@@ -17,6 +17,7 @@
|
|||||||
use std::collections::{HashMap, HashSet};
|
use std::collections::{HashMap, HashSet};
|
||||||
|
|
||||||
use crate::common::Result;
|
use crate::common::Result;
|
||||||
|
#[cfg(feature="experimental_features")]
|
||||||
use crate::oned::cpp::ODReader;
|
use crate::oned::cpp::ODReader;
|
||||||
use crate::qrcode::cpp_port::QrReader;
|
use crate::qrcode::cpp_port::QrReader;
|
||||||
use crate::{
|
use crate::{
|
||||||
@@ -195,6 +196,7 @@ impl MultiFormatReader {
|
|||||||
BarcodeFormat::MAXICODE => {
|
BarcodeFormat::MAXICODE => {
|
||||||
MaxiCodeReader::default().decode_with_hints(image, &self.hints)
|
MaxiCodeReader::default().decode_with_hints(image, &self.hints)
|
||||||
}
|
}
|
||||||
|
#[cfg(feature="experimental_features")]
|
||||||
BarcodeFormat::DXFilmEdge => {
|
BarcodeFormat::DXFilmEdge => {
|
||||||
ODReader::new(&self.hints).decode_with_hints(image, &self.hints)
|
ODReader::new(&self.hints).decode_with_hints(image, &self.hints)
|
||||||
}
|
}
|
||||||
@@ -234,6 +236,7 @@ impl MultiFormatReader {
|
|||||||
if let Ok(res) = MaxiCodeReader::default().decode_with_hints(image, &self.hints) {
|
if let Ok(res) = MaxiCodeReader::default().decode_with_hints(image, &self.hints) {
|
||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
|
#[cfg(feature="experimental_features")]
|
||||||
if let Ok(res) = ODReader::new(&self.hints).decode_with_hints(image, &self.hints) {
|
if let Ok(res) = ODReader::new(&self.hints).decode_with_hints(image, &self.hints) {
|
||||||
return Ok(res);
|
return Ok(res);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -94,4 +94,5 @@ pub use upc_e_writer::*;
|
|||||||
|
|
||||||
mod telepen_common;
|
mod telepen_common;
|
||||||
|
|
||||||
|
#[cfg(feature = "experimental_features")]
|
||||||
pub mod cpp;
|
pub mod cpp;
|
||||||
|
|||||||
@@ -42,7 +42,7 @@ pub struct AI013x0x1xDecoder<'a> {
|
|||||||
impl AI01weightDecoder for AI013x0x1xDecoder<'_> {
|
impl AI01weightDecoder for AI013x0x1xDecoder<'_> {
|
||||||
fn addWeightCode(&self, buf: &mut String, weight: u32) {
|
fn addWeightCode(&self, buf: &mut String, weight: u32) {
|
||||||
buf.push('(');
|
buf.push('(');
|
||||||
buf.push_str(&self.firstAIdigits);
|
buf.push_str(self.firstAIdigits);
|
||||||
buf.push_str(&(weight / 100000).to_string());
|
buf.push_str(&(weight / 100000).to_string());
|
||||||
buf.push(')');
|
buf.push(')');
|
||||||
}
|
}
|
||||||
@@ -108,7 +108,7 @@ impl<'a> AI013x0x1xDecoder<'_> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
buf.push('(');
|
buf.push('(');
|
||||||
buf.push_str(&self.dateCode);
|
buf.push_str(self.dateCode);
|
||||||
buf.push(')');
|
buf.push(')');
|
||||||
|
|
||||||
let day = numericDate % 32;
|
let day = numericDate % 32;
|
||||||
|
|||||||
@@ -259,7 +259,7 @@ impl LuminanceSource for PlanarYUVLuminanceSource {
|
|||||||
row
|
row
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_column(&self, x: usize) -> Vec<u8> {
|
fn get_column(&self, _x: usize) -> Vec<u8> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -332,7 +332,7 @@ impl LuminanceSource for PlanarYUVLuminanceSource {
|
|||||||
self.invert = !self.invert;
|
self.invert = !self.invert;
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_luma8_point(&self, x: usize, y: usize) -> u8 {
|
fn get_luma8_point(&self, _x: usize, _y: usize) -> u8 {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -60,7 +60,7 @@ impl LuminanceSource for RGBLuminanceSource {
|
|||||||
row
|
row
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_column(&self, x: usize) -> Vec<u8> {
|
fn get_column(&self, _x: usize) -> Vec<u8> {
|
||||||
unimplemented!()
|
unimplemented!()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -131,9 +131,9 @@ impl LuminanceSource for RGBLuminanceSource {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_luma8_point(&self, x: usize, y: usize) -> u8 {
|
fn get_luma8_point(&self, x: usize, y: usize) -> u8 {
|
||||||
let width = self.get_width();
|
let _width = self.get_width();
|
||||||
let row_offset = (y + self.top) * self.dataWidth + self.left;
|
let row_offset = (y + self.top) * self.dataWidth + self.left;
|
||||||
let col_offset = (x + self.left);
|
let col_offset = x + self.left;
|
||||||
|
|
||||||
self.luminances[row_offset + col_offset]
|
self.luminances[row_offset + col_offset]
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user