mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
DetectPureQR ported
This commit is contained in:
@@ -559,33 +559,6 @@ impl BitMatrix {
|
||||
Some([left, top, right - left + 1, bottom - top + 1])
|
||||
}
|
||||
|
||||
pub fn
|
||||
findBoundingBox(&self, left:&mut u32, top:&mut u32, width:&mut u32, height:&mut u32, minSize:u32) -> bool
|
||||
{
|
||||
todo!()
|
||||
// let right;
|
||||
// let bottom;
|
||||
// if (!self.getTopLeftOnBitWithPosition(left, top) || !self.getBottomRightOnBitWithPosition(right, bottom) || bottom - top + 1 < minSize)
|
||||
// {return false;}
|
||||
|
||||
// for (int y = top; y <= bottom; y++ ) {
|
||||
// for (int x = 0; x < left; ++x)
|
||||
// if (get(x, y)) {
|
||||
// left = x;
|
||||
// break;
|
||||
// }
|
||||
// for (int x = _width-1; x > right; x--)
|
||||
// if (get(x, y)) {
|
||||
// right = x;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// width = right - left + 1;
|
||||
// height = bottom - top + 1;
|
||||
// return width >= minSize && height >= minSize;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is useful in detecting a corner of a 'pure' barcode.
|
||||
*
|
||||
|
||||
61
src/common/cpp_essentials/bitmatrix.rs
Normal file
61
src/common/cpp_essentials/bitmatrix.rs
Normal file
@@ -0,0 +1,61 @@
|
||||
use crate::common::BitMatrix;
|
||||
use crate::common::Result;
|
||||
use crate::point;
|
||||
|
||||
impl BitMatrix {
|
||||
pub fn Deflate(
|
||||
&self,
|
||||
width: u32,
|
||||
height: u32,
|
||||
top: f32,
|
||||
left: f32,
|
||||
subSampling: f32,
|
||||
) -> Result<Self> {
|
||||
let mut result = BitMatrix::new(width, height)?;
|
||||
|
||||
for y in 0..result.height() {
|
||||
// for (int y = 0; y < result.height(); y++) {
|
||||
let yOffset = top + y as f32 * subSampling;
|
||||
for x in 0..result.width() {
|
||||
// for (int x = 0; x < result.width(); x++) {
|
||||
if (self.get_point(point(left + x as f32 * subSampling, yOffset))) {
|
||||
result.set(x, y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(result)
|
||||
}
|
||||
|
||||
pub fn findBoundingBox(
|
||||
&self,
|
||||
left: &mut u32,
|
||||
top: &mut u32,
|
||||
width: &mut u32,
|
||||
height: &mut u32,
|
||||
minSize: u32,
|
||||
) -> bool {
|
||||
todo!()
|
||||
// let right;
|
||||
// let bottom;
|
||||
// if (!self.getTopLeftOnBitWithPosition(left, top) || !self.getBottomRightOnBitWithPosition(right, bottom) || bottom - top + 1 < minSize)
|
||||
// {return false;}
|
||||
|
||||
// for (int y = top; y <= bottom; y++ ) {
|
||||
// for (int x = 0; x < left; ++x)
|
||||
// if (get(x, y)) {
|
||||
// left = x;
|
||||
// break;
|
||||
// }
|
||||
// for (int x = _width-1; x > right; x--)
|
||||
// if (get(x, y)) {
|
||||
// right = x;
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
|
||||
// width = right - left + 1;
|
||||
// height = bottom - top + 1;
|
||||
// return width >= minSize && height >= minSize;
|
||||
}
|
||||
}
|
||||
@@ -165,27 +165,27 @@ pub trait BitMatrixCursorTrait {
|
||||
|
||||
fn d(&self) -> Point;
|
||||
|
||||
|
||||
fn readPattern<T>(&self, range : Option<u32>) -> Option<T>
|
||||
{
|
||||
fn readPattern<T>(&self, range: Option<u32>) -> Option<T> {
|
||||
// let range = range.unwrap_or(0);
|
||||
// let mut res :T;
|
||||
// let mut res :T;
|
||||
// for i in res.into_iter() {
|
||||
// i = self.stepToEdge(1, range);
|
||||
// }
|
||||
// // for (auto& i : res)
|
||||
// // i = stepToEdge(1, range);
|
||||
// return res;
|
||||
// // for (auto& i : res)
|
||||
// // i = stepToEdge(1, range);
|
||||
// return res;
|
||||
todo!()
|
||||
}
|
||||
|
||||
|
||||
fn readPatternFromBlack<T>(&self, maxWhitePrefix:i32, range: Option<u32>) -> Option<T>
|
||||
{
|
||||
fn readPatternFromBlack<T>(&self, maxWhitePrefix: i32, range: Option<u32>) -> Option<T> {
|
||||
let range = range.unwrap_or(0);
|
||||
if (maxWhitePrefix != 0 && self.isWhite() && !self.stepToEdge(Some(1), Some(maxWhitePrefix), None) > 0)
|
||||
{return None;}
|
||||
// return readPattern<ARRAY>(range);
|
||||
if (maxWhitePrefix != 0
|
||||
&& self.isWhite()
|
||||
&& !self.stepToEdge(Some(1), Some(maxWhitePrefix), None) > 0)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
// return readPattern<ARRAY>(range);
|
||||
self.readPattern(Some(range))
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
mod bitmatrix;
|
||||
pub mod bitmatrix_cursor;
|
||||
pub mod bitmatrix_cursor_trait;
|
||||
pub mod concentric_finder;
|
||||
|
||||
@@ -54,6 +54,12 @@ impl std::ops::IndexMut<usize> for PatternRow {
|
||||
}
|
||||
}
|
||||
|
||||
impl From<Vec<PatternType>> for PatternRow {
|
||||
fn from(value: Vec<PatternType>) -> Self {
|
||||
Self(value)
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> Iterator for PatternView<'_> {
|
||||
type Item = PatternType;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user