port integration for pdf 417 1-3

This commit is contained in:
Henry Schimke
2022-12-26 14:22:37 -06:00
parent 3021c163d4
commit cba6a10c4b
7 changed files with 69 additions and 121 deletions

View File

@@ -1,38 +0,0 @@
/*
* Copyright 2008 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.pdf417;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
/**
* This test consists of perfect, computer-generated images. We should have 100% passing.
*
* @author SITA Lab (kevin.osullivan@sita.aero)
*/
public final class PDF417BlackBox1TestCase extends AbstractBlackBoxTestCase {
public PDF417BlackBox1TestCase() {
super("src/test/resources/blackbox/pdf417-1", new MultiFormatReader(), BarcodeFormat.PDF_417);
addTest(10, 10, 0.0f);
addTest(10, 10, 90.0f);
addTest(10, 10, 180.0f);
addTest(10, 10, 270.0f);
}
}

View File

@@ -1,36 +0,0 @@
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.pdf417;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
/**
* This test contains 480x240 images captured from an Android device at preview resolution.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
public final class PDF417BlackBox2TestCase extends AbstractBlackBoxTestCase {
public PDF417BlackBox2TestCase() {
super("src/test/resources/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF_417);
addTest(25, 25, 0, 0, 0.0f);
addTest(25, 25, 0, 0, 180.0f);
}
}

View File

@@ -1,34 +0,0 @@
/*
* Copyright 2009 ZXing authors
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.zxing.pdf417;
import com.google.zxing.BarcodeFormat;
import com.google.zxing.MultiFormatReader;
import com.google.zxing.common.AbstractBlackBoxTestCase;
/**
* Tests {@link PDF417Reader} against more sample images.
*/
public final class PDF417BlackBox3TestCase extends AbstractBlackBoxTestCase {
public PDF417BlackBox3TestCase() {
super("src/test/resources/blackbox/pdf417-3", new MultiFormatReader(), BarcodeFormat.PDF_417);
addTest(19, 19, 0, 0, 0.0f);
addTest(19, 19, 0, 0, 180.0f);
}
}

View File

@@ -23,7 +23,7 @@ use std::{
use rxing::{
common::HybridBinarizer, BarcodeFormat, BinaryBitmap, BufferedImageLuminanceSource,
DecodeHintType, DecodeHintValue, RXingResultMetadataType, RXingResultMetadataValue, Reader,
DecodeHintType, DecodeHintValue, RXingResultMetadataType, RXingResultMetadataValue, Reader, pdf417::PDF417RXingResultMetadata,
};
use super::TestRXingResult;
@@ -208,7 +208,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
RXingResultMetadataValue::UpcEanExtension(v)
}
RXingResultMetadataType::PDF417_EXTRA_METADATA => {
RXingResultMetadataValue::Pdf417ExtraMetadata(v)
RXingResultMetadataValue::Pdf417ExtraMetadata(Rc::new(PDF417RXingResultMetadata::default()))
}
RXingResultMetadataType::STRUCTURED_APPEND_SEQUENCE => {
RXingResultMetadataValue::StructuredAppendSequence(
@@ -222,7 +222,7 @@ impl<T: Reader> AbstractBlackBoxTestCase<T> {
}
RXingResultMetadataType::SYMBOLOGY_IDENTIFIER => {
RXingResultMetadataValue::SymbologyIdentifier(v)
}
},
};
}

View File

@@ -0,0 +1,58 @@
use rxing::{qrcode::QRCodeReader, BarcodeFormat, MultiFormatReader};
mod common;
/**
* This test consists of perfect, computer-generated images. We should have 100% passing.
*
* @author SITA Lab (kevin.osullivan@sita.aero)
*/
#[test]
fn pdf417_black_box1_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/pdf417-1",
MultiFormatReader::default(),
rxing::BarcodeFormat::PDF_417,
);
// super("src/test/resources/blackbox/pdf417-1", new MultiFormatReader(), BarcodeFormat.PDF_417);
tester.add_test(10, 10, 0.0);
tester.add_test(10, 10, 90.0);
tester.add_test(10, 10, 180.0);
tester.add_test(10, 10, 270.0);
tester.test_black_box()
}
/**
* This test contains 480x240 images captured from an Android device at preview resolution.
*
* @author dswitkin@google.com (Daniel Switkin)
*/
#[test]
fn pdf417_black_box2_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/pdf417-2",
MultiFormatReader::default(),
rxing::BarcodeFormat::PDF_417,
);
// super("src/test/resources/blackbox/pdf417-2", new MultiFormatReader(), BarcodeFormat.PDF_417);
tester.add_test_complex(25, 25, 0, 0, 0.0);
tester.add_test_complex(25, 25, 0, 0, 180.0);
tester.test_black_box()
}
/**
* Tests {@link PDF417Reader} against more sample images.
*/
#[test]
fn pdf417_black_box3_test_case() {
let mut tester = common::AbstractBlackBoxTestCase::new(
"test_resources/blackbox/pdf417-3",
MultiFormatReader::default(),
rxing::BarcodeFormat::PDF_417,
);
// super("src/test/resources/blackbox/pdf417-3", new MultiFormatReader(), BarcodeFormat.PDF_417);
tester.add_test_complex(19, 19, 0, 0, 0.0);
tester.add_test_complex(19, 19, 0, 0, 180.0);
tester.test_black_box()
}