mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
partial success on parse, missing symbology id
This commit is contained in:
@@ -469,7 +469,9 @@ impl<'a> Detector<'_> {
|
||||
point(low, high),
|
||||
);
|
||||
|
||||
sampler.sample_grid_detailed(image, dimension, dimension, dst, quad)
|
||||
let (res, _) = sampler.sample_grid_detailed(image, dimension, dimension, dst, quad)?;
|
||||
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::common::Result;
|
||||
use crate::{point, Exceptions, Point};
|
||||
use crate::{point, Exceptions, Point, point_i};
|
||||
|
||||
use super::BitArray;
|
||||
|
||||
@@ -223,7 +223,14 @@ impl BitMatrix {
|
||||
}
|
||||
|
||||
pub fn get_index<T: Into<usize>>(&self, index: T) -> bool {
|
||||
todo!()
|
||||
self.get_point(self.calculate_point_from_index(index.into()))
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn calculate_point_from_index(&self, index: usize) -> Point {
|
||||
let row = index / (self.getWidth() as usize);
|
||||
let column = index % (self.getWidth() as usize);
|
||||
point_i(column as u32, row as u32)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use crate::common::BitMatrix;
|
||||
|
||||
use super::BitMatrixCursorTrait;
|
||||
|
||||
pub struct FastEdgeToEdgeCounter {
|
||||
@@ -9,11 +11,11 @@ pub struct FastEdgeToEdgeCounter {
|
||||
stepsToBorder: i32, // = 0;
|
||||
//arr: BitArray,
|
||||
_arr: isize,
|
||||
under_arry: Vec<bool>,
|
||||
under_arry: Vec<bool>//&'a BitMatrix//,
|
||||
}
|
||||
|
||||
impl FastEdgeToEdgeCounter {
|
||||
pub fn new<T: BitMatrixCursorTrait>(cur: &T) -> Self {
|
||||
pub fn new<T: BitMatrixCursorTrait>(cur: &T) -> FastEdgeToEdgeCounter {
|
||||
let stride = cur.d().y as isize * cur.img().width() as isize + cur.d().x as isize;
|
||||
let p = ((cur.p().y as isize * cur.img().width() as isize).abs() as i32 + cur.p().x as i32) as u32; // P IS SET WRONG IN REVERSE
|
||||
|
||||
@@ -37,7 +39,7 @@ impl FastEdgeToEdgeCounter {
|
||||
};
|
||||
let stepsToBorder = std::cmp::min(maxStepsX, maxStepsY) as i32;
|
||||
|
||||
Self {
|
||||
FastEdgeToEdgeCounter {
|
||||
p,
|
||||
stride,
|
||||
stepsToBorder,
|
||||
@@ -63,6 +65,7 @@ impl FastEdgeToEdgeCounter {
|
||||
|
||||
if !(self.under_arry[idx_pt]
|
||||
== self.under_arry[self.p as usize])
|
||||
// if !(self.under_arry.get_index(idx_pt) == self.under_arry.get_index(self.p as usize))
|
||||
{
|
||||
break true;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,7 @@ impl GridSampler for DefaultGridSampler {
|
||||
Point::default()
|
||||
};
|
||||
|
||||
let tl = projectCorner(point(0.0, 0.0));
|
||||
let tl = projectCorner(Point::default());
|
||||
let tr = projectCorner(Point::from((dimensionX, 0)));
|
||||
let bl = projectCorner(Point::from((dimensionX, dimensionY)));
|
||||
let br = projectCorner(Point::from((0, dimensionX)));
|
||||
|
||||
@@ -343,7 +343,8 @@ impl<'a> Detector<'_> {
|
||||
);
|
||||
let src = Quadrilateral::new(topRight, topLeft, bottomRight, bottomLeft);
|
||||
|
||||
sampler.sample_grid_detailed(image, dimensionX, dimensionY, dst, src)
|
||||
let(res,_)=sampler.sample_grid_detailed(image, dimensionX, dimensionY, dst, src)?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -233,8 +233,10 @@ fn Scan(
|
||||
|
||||
CHECK!(res.is_ok());
|
||||
|
||||
let (res, _) = res?;
|
||||
|
||||
return Ok(DatamatrixDetectorResult::new(
|
||||
res?,
|
||||
res,
|
||||
sourcePoints.points().to_vec(),
|
||||
));
|
||||
}
|
||||
|
||||
@@ -356,7 +356,7 @@ pub fn detect(image: &BitMatrix, try_harder: bool) -> Result<MaxicodeDetectionRe
|
||||
);
|
||||
let src = Quadrilateral::new(tl, tr, br, bl);
|
||||
|
||||
let Ok(bits) = grid_sampler.sample_grid_detailed(
|
||||
let Ok((bits,_)) = grid_sampler.sample_grid_detailed(
|
||||
image,
|
||||
target_width.round() as u32,
|
||||
target_height.round() as u32,
|
||||
|
||||
@@ -91,7 +91,7 @@ pub fn ReadFormatInformation(bitMatrix: &BitMatrix, isMicro: bool) -> Result<For
|
||||
AppendBit(&mut formatInfoBits1, getBit(bitMatrix, 8, 8, None));
|
||||
AppendBit(&mut formatInfoBits1, getBit(bitMatrix, 8, 7, None));
|
||||
// .. and skip a bit in the timing pattern ...
|
||||
for y in (0..=6).rev() {
|
||||
for y in (0..=5).rev() {
|
||||
// for (int y = 5; y >= 0; y--)
|
||||
AppendBit(&mut formatInfoBits1, getBit(bitMatrix, 8, y, None));
|
||||
}
|
||||
@@ -130,7 +130,7 @@ pub fn ReadQRCodewords(
|
||||
let mut bitsRead = 0;
|
||||
let dimension = bitMatrix.height();
|
||||
// Read columns in pairs, from right to left
|
||||
let mut x = dimension - 1;
|
||||
let mut x = (dimension as i32) - 1;
|
||||
while x > 0 {
|
||||
// for (int x = dimension - 1; x > 0; x -= 2) {
|
||||
// Skip whole column with vertical timing pattern.
|
||||
@@ -143,7 +143,7 @@ pub fn ReadQRCodewords(
|
||||
let y = if readingUp { dimension - 1 - row } else { row };
|
||||
for col in 0..2 {
|
||||
// for (int col = 0; col < 2; col++) {
|
||||
let xx = x - col;
|
||||
let xx = (x - col) as u32;
|
||||
// Ignore bits covered by the function pattern
|
||||
if (!functionPattern.get(xx, y)) {
|
||||
// Read a bit
|
||||
|
||||
@@ -428,7 +428,7 @@ pub fn Decode(bits: &BitMatrix) -> Result<DecoderResult<bool>> {
|
||||
}
|
||||
|
||||
// resultIterator = std::copy_n(codewordBytes.begin(), numDataCodewords, resultIterator);
|
||||
resultBytes[resultIterator..numDataCodewords]
|
||||
resultBytes[resultIterator..(resultIterator+numDataCodewords)]
|
||||
.copy_from_slice(&codewordBytes[..numDataCodewords]);
|
||||
resultIterator += numDataCodewords;
|
||||
}
|
||||
|
||||
@@ -747,8 +747,8 @@ pub fn SampleQR(image: &BitMatrix, fp: &FinderPatternSet) -> Result<QRCodeDetect
|
||||
dimension as u32,
|
||||
dimension as u32,
|
||||
&[SamplerControl {
|
||||
p0: point_i(0, dimension as u32),
|
||||
p1: point_i(0, dimension as u32),
|
||||
p1: point_i(dimension as u32, dimension as u32),
|
||||
p0: point_i(0,0 ),
|
||||
transform: mod2Pix,
|
||||
}],
|
||||
)?;
|
||||
|
||||
@@ -218,12 +218,13 @@ impl<'a> Detector<'_> {
|
||||
dimension: u32,
|
||||
) -> Result<BitMatrix> {
|
||||
let sampler = DefaultGridSampler::default();
|
||||
sampler.sample_grid(
|
||||
let (res, _) = sampler.sample_grid(
|
||||
image,
|
||||
dimension,
|
||||
dimension,
|
||||
&[SamplerControl::new(dimension, dimension, transform)],
|
||||
)
|
||||
)?;
|
||||
Ok(res)
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user