qr_code partially working

This commit is contained in:
Henry Schimke
2022-10-09 22:01:36 -05:00
parent 50a675c693
commit 79aafa200d
26 changed files with 839 additions and 604 deletions

View File

@@ -14,23 +14,26 @@
* limitations under the License.
*/
package com.google.zxing.qrcode;
use rxing::qrcode::QRCodeReader;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
mod common;
/**
* @author Sean Owen
*/
public final class QRCodeBlackBox2TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox2TestCase() {
super("src/test/resources/blackbox/qrcode-2", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(31, 31, 0.0f);
addTest(30, 30, 90.0f);
addTest(30, 30, 180.0f);
addTest(30, 30, 270.0f);
}
#[test]
fn QRCodeBlackBox1TestCase() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/qrcode-1",
Box::new(QRCodeReader {}),
rxing::BarcodeFormat::QR_CODE,
);
// super("src/test/resources/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE);
tester.addTest(17, 17, 0.0);
tester.addTest(14, 14, 90.0);
tester.addTest(17, 17, 180.0);
tester.addTest(14, 14, 270.0);
tester.testBlackBox();
}

View File

@@ -14,23 +14,22 @@
* limitations under the License.
*/
package com.google.zxing.qrcode;
use rxing::{qrcode::QRCodeReader, BarcodeFormat};
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
mod common;
/**
* @author Sean Owen
*/
public final class QRCodeBlackBox1TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox1TestCase() {
super("src/test/resources/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(17, 17, 0.0f);
addTest(14, 14, 90.0f);
addTest(17, 17, 180.0f);
addTest(14, 14, 270.0f);
#[test]
fn QRCodeBlackBox2TestCase() {
let mut tester = common::AbstractBlackBoxTestCase::new("test_resources/blackbox/qrcode-2", Box::new(QRCodeReader{}), BarcodeFormat::QR_CODE);
tester.addTest(31, 31, 0.0);
tester.addTest(30, 30, 90.0);
tester.addTest(30, 30, 180.0);
tester.addTest(30, 30, 270.0);
tester.testBlackBox();
}
}

View File

@@ -14,23 +14,22 @@
* limitations under the License.
*/
package com.google.zxing.qrcode;
use rxing::{qrcode::QRCodeReader, BarcodeFormat};
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
mod common;
/**
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class QRCodeBlackBox3TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox3TestCase() {
super("src/test/resources/blackbox/qrcode-3", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(38, 38, 0.0f);
addTest(39, 39, 90.0f);
addTest(36, 36, 180.0f);
addTest(39, 39, 270.0f);
#[test]
fn QRCodeBlackBox3TestCase() {
let mut tester = common::AbstractBlackBoxTestCase::new("test_resources/blackbox/qrcode-3", Box::new(QRCodeReader{}), BarcodeFormat::QR_CODE);
tester.addTest(38, 38, 0.0);
tester.addTest(39, 39, 90.0);
tester.addTest(36, 36, 180.0);
tester.addTest(39, 39, 270.0);
tester.testBlackBox();
}
}

View File

@@ -14,25 +14,24 @@
* limitations under the License.
*/
package com.google.zxing.qrcode;
use rxing::{qrcode::QRCodeReader, BarcodeFormat};
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
mod common;
/**
* Tests of various QR Codes from t-shirts, which are notoriously not flat.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class QRCodeBlackBox4TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox4TestCase() {
super("src/test/resources/blackbox/qrcode-4", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(36, 36, 0.0f);
addTest(35, 35, 90.0f);
addTest(35, 35, 180.0f);
addTest(35, 35, 270.0f);
#[test]
fn QRCodeBlackBox4TestCase() {
let mut tester = common::AbstractBlackBoxTestCase::new("test_resources/blackbox/qrcode-4", Box::new(QRCodeReader{}), BarcodeFormat::QR_CODE);
tester.addTest(36, 36, 0.0);
tester.addTest(35, 35, 90.0);
tester.addTest(35, 35, 180.0);
tester.addTest(35, 35, 270.0);
tester.testBlackBox();
}
}

View File

@@ -14,11 +14,9 @@
* limitations under the License.
*/
package com.google.zxing.qrcode;
use rxing::{BarcodeFormat, qrcode::QRCodeReader};
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
mod common;
/**
* Some very difficult exposure conditions including self-shadowing, which happens a lot when
@@ -27,14 +25,15 @@ import com.google.zxing.common.AbstractBlackBoxTestCase;
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class QRCodeBlackBox5TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox5TestCase() {
super("src/test/resources/blackbox/qrcode-5", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(19, 19, 0.0f);
addTest(19, 19, 90.0f);
addTest(19, 19, 180.0f);
addTest(19, 19, 270.0f);
#[test]
fn QRCodeBlackBox5TestCase() {
let mut tester = common::AbstractBlackBoxTestCase::new("test_resources/blackbox/qrcode-5", Box::new(QRCodeReader{}), BarcodeFormat::QR_CODE);
tester.addTest(19, 19, 0.0);
tester.addTest(19, 19, 90.0);
tester.addTest(19, 19, 180.0);
tester.addTest(19, 19, 270.0);
tester.testBlackBox();
}
}

View File

@@ -14,24 +14,22 @@
* limitations under the License.
*/
package com.google.zxing.qrcode;
use rxing::{qrcode::QRCodeReader, BarcodeFormat};
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
mod common;
/**
* These tests are supplied by Tim Gernat and test finder pattern detection at small size and under
* rotation, which was a weak spot.
*/
public final class QRCodeBlackBox6TestCase extends AbstractBlackBoxTestCase {
public QRCodeBlackBox6TestCase() {
super("src/test/resources/blackbox/qrcode-6", new MultiFormatReader(), BarcodeFormat.QR_CODE);
addTest(15, 15, 0.0f);
addTest(14, 14, 90.0f);
addTest(13, 13, 180.0f);
addTest(14, 14, 270.0f);
#[test]
fn QRCodeBlackBox6TestCase() {
let mut tester = common::AbstractBlackBoxTestCase::new("test_resources/blackbox/qrcode-6", Box::new(QRCodeReader{}), BarcodeFormat::QR_CODE);
tester.addTest(15, 15, 0.0);
tester.addTest(14, 14, 90.0);
tester.addTest(13, 13, 180.0);
tester.addTest(14, 14, 270.0);
tester.testBlackBox();
}
}

View File

@@ -189,7 +189,7 @@ impl AbstractBlackBoxTestCase {
RXingResultMetadataValue::Orientation(v.parse().unwrap_or_default())
}
RXingResultMetadataType::BYTE_SEGMENTS => {
RXingResultMetadataValue::ByteSegments(v.into_bytes())
RXingResultMetadataValue::ByteSegments(vec![v.into_bytes()])
}
RXingResultMetadataType::ERROR_CORRECTION_LEVEL => {
RXingResultMetadataValue::ErrorCorrectionLevel(v)