mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-28 05:12:34 +00:00
partially working qrcode blackbox
This commit is contained in:
@@ -169,7 +169,7 @@ fn decode_bitmatrix_parser_with_hints(
|
|||||||
// for (DataBlock dataBlock : dataBlocks) {
|
// for (DataBlock dataBlock : dataBlocks) {
|
||||||
let mut codewordBytes = dataBlock.getCodewords().to_vec();
|
let mut codewordBytes = dataBlock.getCodewords().to_vec();
|
||||||
let numDataCodewords = dataBlock.getNumDataCodewords() as usize;
|
let numDataCodewords = dataBlock.getNumDataCodewords() as usize;
|
||||||
correctErrors(&mut codewordBytes, numDataCodewords);
|
correctErrors(&mut codewordBytes, numDataCodewords)?;
|
||||||
for i in 0..numDataCodewords {
|
for i in 0..numDataCodewords {
|
||||||
// for (int i = 0; i < numDataCodewords; i++) {
|
// for (int i = 0; i < numDataCodewords; i++) {
|
||||||
resultBytes[resultOffset] = codewordBytes[i];
|
resultBytes[resultOffset] = codewordBytes[i];
|
||||||
|
|||||||
@@ -37,3 +37,6 @@ fn QRCodeBlackBox1TestCase() {
|
|||||||
|
|
||||||
tester.testBlackBox();
|
tester.testBlackBox();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// TEST CASE 15 FAILING AT allignment patter finder! (line 88) FROM detector 486
|
||||||
@@ -17,7 +17,8 @@
|
|||||||
use std::{
|
use std::{
|
||||||
collections::HashMap,
|
collections::HashMap,
|
||||||
fs::{read_dir, read_to_string, File},
|
fs::{read_dir, read_to_string, File},
|
||||||
path::{Path, PathBuf}, io::Write,
|
io::Write,
|
||||||
|
path::{Path, PathBuf},
|
||||||
};
|
};
|
||||||
|
|
||||||
use rxing::{
|
use rxing::{
|
||||||
@@ -114,7 +115,7 @@ impl AbstractBlackBoxTestCase {
|
|||||||
let path_search = read_dir(&self.test_base);
|
let path_search = read_dir(&self.test_base);
|
||||||
const possible_extensions: &str = "jpg,jpeg,gif,png,JPG,JPEG,GIF,PNG";
|
const possible_extensions: &str = "jpg,jpeg,gif,png,JPG,JPEG,GIF,PNG";
|
||||||
|
|
||||||
let paths = path_search
|
let mut paths = path_search
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.filter(|r| r.is_ok()) // Get rid of Err variants for Result<DirEntry>
|
.filter(|r| r.is_ok()) // Get rid of Err variants for Result<DirEntry>
|
||||||
@@ -122,7 +123,9 @@ impl AbstractBlackBoxTestCase {
|
|||||||
.filter(|r| r.is_file()) // Filter out non-folders
|
.filter(|r| r.is_file()) // Filter out non-folders
|
||||||
.filter(|r| possible_extensions.contains(r.extension().unwrap().to_str().unwrap()))
|
.filter(|r| possible_extensions.contains(r.extension().unwrap().to_str().unwrap()))
|
||||||
// .map(|r| r.into_boxed_path())
|
// .map(|r| r.into_boxed_path())
|
||||||
.collect();
|
.collect::<Vec<PathBuf>>();
|
||||||
|
|
||||||
|
paths.sort();
|
||||||
|
|
||||||
paths
|
paths
|
||||||
}
|
}
|
||||||
@@ -232,13 +235,14 @@ impl AbstractBlackBoxTestCase {
|
|||||||
let source = BufferedImageLuminanceSource::new(rotated_image);
|
let source = BufferedImageLuminanceSource::new(rotated_image);
|
||||||
let bitmap = BinaryBitmap::new(Box::new(HybridBinarizer::new(Box::new(source))));
|
let bitmap = BinaryBitmap::new(Box::new(HybridBinarizer::new(Box::new(source))));
|
||||||
|
|
||||||
// if file_base_name == "09" {
|
#[cfg(test)]
|
||||||
// let mut f = File::create("test_file_output.txt").unwrap();
|
if file_base_name == "13" {
|
||||||
// dbg!("dumb");
|
let mut f = File::create("test_file_output.txt").unwrap();
|
||||||
// write!(f,"{}", bitmap.getBlackMatrix().unwrap());
|
dbg!("dumb");
|
||||||
// drop(f);
|
write!(f,"{}", bitmap.getBlackMatrix().unwrap());
|
||||||
// Self::rotate_image(&image, rotation).save("test_image.png").unwrap();
|
drop(f);
|
||||||
// }
|
Self::rotate_image(&image, rotation).save("test_image.png").unwrap();
|
||||||
|
}
|
||||||
|
|
||||||
if let Ok(decoded) =
|
if let Ok(decoded) =
|
||||||
self.decode(&bitmap, rotation, &expected_text, &expected_metadata, false)
|
self.decode(&bitmap, rotation, &expected_text, &expected_metadata, false)
|
||||||
@@ -497,6 +501,13 @@ impl AbstractBlackBoxTestCase {
|
|||||||
// break;
|
// break;
|
||||||
// }
|
// }
|
||||||
|
|
||||||
|
if degrees == 90.0 {
|
||||||
|
original.rotate90()
|
||||||
|
} else if degrees == 180.0 {
|
||||||
|
original.rotate180()
|
||||||
|
} else if degrees == 270.0 {
|
||||||
|
original.rotate270()
|
||||||
|
} else {
|
||||||
let radians = degrees.to_radians();
|
let radians = degrees.to_radians();
|
||||||
|
|
||||||
{
|
{
|
||||||
@@ -508,11 +519,29 @@ impl AbstractBlackBoxTestCase {
|
|||||||
&original.to_luma8(),
|
&original.to_luma8(),
|
||||||
radians,
|
radians,
|
||||||
Interpolation::Nearest,
|
Interpolation::Nearest,
|
||||||
Luma([u8::MAX/2; 1]),
|
Luma([u8::MAX / 2; 1]),
|
||||||
);
|
);
|
||||||
|
|
||||||
DynamicImage::from(i)
|
DynamicImage::from(i)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// let radians = degrees.to_radians();
|
||||||
|
|
||||||
|
// {
|
||||||
|
// use image::DynamicImage;
|
||||||
|
// use image::Luma;
|
||||||
|
// use imageproc::geometric_transformations::*;
|
||||||
|
|
||||||
|
// let i = rotate_about_center(
|
||||||
|
// &original.to_luma8(),
|
||||||
|
// radians,
|
||||||
|
// Interpolation::Nearest,
|
||||||
|
// Luma([u8::MAX / 2; 1]),
|
||||||
|
// );
|
||||||
|
|
||||||
|
// DynamicImage::from(i)
|
||||||
|
// }
|
||||||
|
|
||||||
// // Transform simply to find out the new bounding box (don't actually run the image through it)
|
// // Transform simply to find out the new bounding box (don't actually run the image through it)
|
||||||
// AffineTransform at = new AffineTransform();
|
// AffineTransform at = new AffineTransform();
|
||||||
|
|||||||
Reference in New Issue
Block a user