mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
most qrcode reads pass, some 90 degree rots fail
This commit is contained in:
@@ -109,7 +109,6 @@ impl BufferedImageLuminanceSource {
|
|||||||
if (alpha & 0xFF) == 0 {
|
if (alpha & 0xFF) == 0 {
|
||||||
// white, so we know its luminance is 255
|
// white, so we know its luminance is 255
|
||||||
raster.put_pixel(x, y, Luma([0xFF]))
|
raster.put_pixel(x, y, Luma([0xFF]))
|
||||||
// buffer[x] = 0xFF;
|
|
||||||
} else {
|
} else {
|
||||||
// .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),
|
// .299R + 0.587G + 0.114B (YUV/YIQ for PAL and NTSC),
|
||||||
// (306*R) >> 10 is approximately equal to R*0.299, and so on.
|
// (306*R) >> 10 is approximately equal to R*0.299, and so on.
|
||||||
@@ -117,9 +116,9 @@ impl BufferedImageLuminanceSource {
|
|||||||
raster.put_pixel(
|
raster.put_pixel(
|
||||||
x,
|
x,
|
||||||
y,
|
y,
|
||||||
Luma([((306 * (red as u32)
|
Luma([((306 * (red as u64)
|
||||||
+ 601 * (green as u32)
|
+ 601 * (green as u64)
|
||||||
+ 117 * (blue as u32)
|
+ 117 * (blue as u64)
|
||||||
+ 0x200)
|
+ 0x200)
|
||||||
>> 10) as u8]),
|
>> 10) as u8]),
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -290,7 +290,7 @@ impl AlignmentPatternFinder {
|
|||||||
let centerJ = Self::centerFromEnd(stateCount, j);
|
let centerJ = Self::centerFromEnd(stateCount, j);
|
||||||
let centerI = self.crossCheckVertical(
|
let centerI = self.crossCheckVertical(
|
||||||
i,
|
i,
|
||||||
centerJ.round() as u32,
|
centerJ.floor() as u32,
|
||||||
2 * stateCount[1],
|
2 * stateCount[1],
|
||||||
stateCountTotal,
|
stateCountTotal,
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -304,16 +304,16 @@ impl Detector {
|
|||||||
*/
|
*/
|
||||||
fn calculateModuleSizeOneWay<T: ResultPoint>(&self, pattern: &T, otherPattern: &T) -> f32 {
|
fn calculateModuleSizeOneWay<T: ResultPoint>(&self, pattern: &T, otherPattern: &T) -> f32 {
|
||||||
let moduleSizeEst1 = self.sizeOfBlackWhiteBlackRunBothWays(
|
let moduleSizeEst1 = self.sizeOfBlackWhiteBlackRunBothWays(
|
||||||
pattern.getX() as u32,
|
pattern.getX().floor() as u32,
|
||||||
pattern.getY() as u32,
|
pattern.getY().floor() as u32,
|
||||||
otherPattern.getX() as u32,
|
otherPattern.getX().floor() as u32,
|
||||||
otherPattern.getY() as u32,
|
otherPattern.getY().floor() as u32,
|
||||||
);
|
);
|
||||||
let moduleSizeEst2 = self.sizeOfBlackWhiteBlackRunBothWays(
|
let moduleSizeEst2 = self.sizeOfBlackWhiteBlackRunBothWays(
|
||||||
otherPattern.getX() as u32,
|
otherPattern.getX().floor() as u32,
|
||||||
otherPattern.getY() as u32,
|
otherPattern.getY().floor() as u32,
|
||||||
pattern.getX() as u32,
|
pattern.getX().floor() as u32,
|
||||||
pattern.getY() as u32,
|
pattern.getY().floor() as u32,
|
||||||
);
|
);
|
||||||
if moduleSizeEst1.is_nan() {
|
if moduleSizeEst1.is_nan() {
|
||||||
return moduleSizeEst2 / 7.0;
|
return moduleSizeEst2 / 7.0;
|
||||||
@@ -344,7 +344,7 @@ impl Detector {
|
|||||||
scale = (self.image.getWidth() as i32 - 1 - fromX as i32) as f32 / (otherToX - fromX as i32) as f32;
|
scale = (self.image.getWidth() as i32 - 1 - fromX as i32) as f32 / (otherToX - fromX as i32) as f32;
|
||||||
otherToX = self.image.getWidth() as i32 - 1;
|
otherToX = self.image.getWidth() as i32 - 1;
|
||||||
}
|
}
|
||||||
let mut otherToY = fromY as i32 - (toY as i32 - fromY as i32) * scale as i32;
|
let mut otherToY = fromY as i32 - (toY as i32 - fromY as i32) * scale.floor() as i32;
|
||||||
|
|
||||||
scale = 1.0;
|
scale = 1.0;
|
||||||
if otherToY < 0 {
|
if otherToY < 0 {
|
||||||
@@ -354,7 +354,7 @@ impl Detector {
|
|||||||
scale = (self.image.getHeight() as i32 - 1 - fromY as i32) as f32 / (otherToY - fromY as i32) as f32;
|
scale = (self.image.getHeight() as i32 - 1 - fromY as i32) as f32 / (otherToY - fromY as i32) as f32;
|
||||||
otherToY = self.image.getHeight() as i32 - 1;
|
otherToY = self.image.getHeight() as i32 - 1;
|
||||||
}
|
}
|
||||||
otherToX = fromX as i32+ (otherToX - fromX as i32) * scale as i32;
|
otherToX = fromX as i32+ (otherToX - fromX as i32) * scale.floor() as i32;
|
||||||
|
|
||||||
result += self.sizeOfBlackWhiteBlackRun(fromX as u32, fromY as u32, otherToX as u32, otherToY as u32);
|
result += self.sizeOfBlackWhiteBlackRun(fromX as u32, fromY as u32, otherToX as u32, otherToY as u32);
|
||||||
|
|
||||||
|
|||||||
@@ -136,6 +136,7 @@ impl FinderPatternFinder {
|
|||||||
// of pattern we saw) to be conservative, and also back off by iSkip which
|
// of pattern we saw) to be conservative, and also back off by iSkip which
|
||||||
// is about to be re-added
|
// is about to be re-added
|
||||||
i += (rowSkip as i32 - stateCount[2] as i32 - iSkip as i32).max(0) as u32;
|
i += (rowSkip as i32 - stateCount[2] as i32 - iSkip as i32).max(0) as u32;
|
||||||
|
// i += rowSkip - stateCount[2] - iSkip ;
|
||||||
j = maxJ - 1;
|
j = maxJ - 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -556,16 +557,16 @@ impl FinderPatternFinder {
|
|||||||
let stateCountTotal =
|
let stateCountTotal =
|
||||||
stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
|
stateCount[0] + stateCount[1] + stateCount[2] + stateCount[3] + stateCount[4];
|
||||||
let mut centerJ = Self::centerFromEnd(stateCount, j);
|
let mut centerJ = Self::centerFromEnd(stateCount, j);
|
||||||
let centerI = self.crossCheckVertical(i, centerJ as u32, stateCount[2], stateCountTotal);
|
let centerI = self.crossCheckVertical(i, centerJ.floor() as u32, stateCount[2], stateCountTotal);
|
||||||
if !centerI.is_nan() {
|
if !centerI.is_nan() {
|
||||||
// Re-cross check
|
// Re-cross check
|
||||||
centerJ = self.crossCheckHorizontal(
|
centerJ = self.crossCheckHorizontal(
|
||||||
centerJ as u32,
|
centerJ.floor() as u32,
|
||||||
centerI as u32,
|
centerI.floor() as u32,
|
||||||
stateCount[2],
|
stateCount[2],
|
||||||
stateCountTotal,
|
stateCountTotal,
|
||||||
);
|
);
|
||||||
if !centerJ.is_nan() && self.crossCheckDiagonal(centerI as u32, centerJ as u32) {
|
if !centerJ.is_nan() && self.crossCheckDiagonal(centerI.floor() as u32, centerJ.floor() as u32) {
|
||||||
let estimatedModuleSize = stateCountTotal as f32 / 7.0;
|
let estimatedModuleSize = stateCountTotal as f32 / 7.0;
|
||||||
let mut found = false;
|
let mut found = false;
|
||||||
for index in 0..self.possibleCenters.len() {
|
for index in 0..self.possibleCenters.len() {
|
||||||
@@ -620,7 +621,7 @@ impl FinderPatternFinder {
|
|||||||
return (((fnp.getX() - center.getX().abs())
|
return (((fnp.getX() - center.getX().abs())
|
||||||
- (fnp.getY() - center.getY()).abs())
|
- (fnp.getY() - center.getY()).abs())
|
||||||
/ 2.0)
|
/ 2.0)
|
||||||
.round() as u32;
|
.floor() as u32;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -39,7 +39,6 @@ fn QRCodeBlackBox1TestCase() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// 16 - 0
|
// 16 - 0
|
||||||
// 19 - 0
|
|
||||||
|
|
||||||
// TEST CASE 15 FAILING AT allignment patter finder! (line 88) FROM detector 486
|
// TEST CASE 15 FAILING AT allignment patter finder! (line 88) FROM detector 486
|
||||||
|
|
||||||
|
|||||||
@@ -33,3 +33,4 @@ mod common;
|
|||||||
tester.testBlackBox();
|
tester.testBlackBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 24
|
||||||
|
|||||||
Reference in New Issue
Block a user