mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-27 21:02:35 +00:00
datamatrix integration passes
This commit is contained in:
@@ -203,7 +203,7 @@ impl GlobalHistogramBinarizer {
|
|||||||
let mut secondPeakScore = 0;
|
let mut secondPeakScore = 0;
|
||||||
for x in 0..numBuckets {
|
for x in 0..numBuckets {
|
||||||
// for (int x = 0; x < numBuckets; x++) {
|
// for (int x = 0; x < numBuckets; x++) {
|
||||||
let distanceToBiggest = x - firstPeak;
|
let distanceToBiggest = (x as i32 - firstPeak as i32).abs() as u32;
|
||||||
// Encourage more distant second peaks by multiplying by square of distance.
|
// Encourage more distant second peaks by multiplying by square of distance.
|
||||||
let score = buckets[x] * distanceToBiggest as u32 * distanceToBiggest as u32;
|
let score = buckets[x] * distanceToBiggest as u32 * distanceToBiggest as u32;
|
||||||
if score > secondPeakScore {
|
if score > secondPeakScore {
|
||||||
|
|||||||
@@ -139,13 +139,16 @@ impl DataMatrixReader {
|
|||||||
let mut left = leftTopBlack[0];
|
let mut left = leftTopBlack[0];
|
||||||
let right = rightBottomBlack[0];
|
let right = rightBottomBlack[0];
|
||||||
|
|
||||||
let matrixWidth = (right - left + 1) / moduleSize;
|
let matrixWidth = (right as i32 - left as i32 + 1) / moduleSize as i32;
|
||||||
let matrixHeight = (bottom - top + 1) / moduleSize;
|
let matrixHeight = (bottom as i32 - top as i32 + 1) / moduleSize as i32;
|
||||||
if matrixWidth <= 0 || matrixHeight <= 0 {
|
if matrixWidth <= 0 || matrixHeight <= 0 {
|
||||||
return Err(Exceptions::NotFoundException("".to_owned()));
|
return Err(Exceptions::NotFoundException("".to_owned()));
|
||||||
// throw NotFoundException.getNotFoundInstance();
|
// throw NotFoundException.getNotFoundInstance();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
let matrixWidth = matrixWidth as u32;
|
||||||
|
let matrixHeight = matrixHeight as u32;
|
||||||
|
|
||||||
// Push in the "border" by half the module width so that we start
|
// Push in the "border" by half the module width so that we start
|
||||||
// sampling in the middle of the module. Just in case the image is a
|
// sampling in the middle of the module. Just in case the image is a
|
||||||
// little off, this will help recover.
|
// little off, this will help recover.
|
||||||
|
|||||||
@@ -83,10 +83,10 @@ impl BitMatrixParser {
|
|||||||
let mut resultOffset = 0;
|
let mut resultOffset = 0;
|
||||||
|
|
||||||
let mut row = 4;
|
let mut row = 4;
|
||||||
let mut column = 0_usize;
|
let mut column = 0;
|
||||||
|
|
||||||
let numRows = self.mappingBitMatrix.getHeight() as usize;
|
let numRows = self.mappingBitMatrix.getHeight().try_into().unwrap();
|
||||||
let numColumns = self.mappingBitMatrix.getWidth() as usize;
|
let numColumns = self.mappingBitMatrix.getWidth().try_into().unwrap();
|
||||||
|
|
||||||
let mut corner1Read = false;
|
let mut corner1Read = false;
|
||||||
let mut corner2Read = false;
|
let mut corner2Read = false;
|
||||||
@@ -193,7 +193,7 @@ impl BitMatrixParser {
|
|||||||
* @param numColumns Number of columns in the mapping matrix
|
* @param numColumns Number of columns in the mapping matrix
|
||||||
* @return value of the given bit in the mapping matrix
|
* @return value of the given bit in the mapping matrix
|
||||||
*/
|
*/
|
||||||
fn readModule(&mut self, row: usize, column: usize, numRows: usize, numColumns: usize) -> bool {
|
fn readModule(&mut self, row: isize, column: isize, numRows: isize, numColumns: isize) -> bool {
|
||||||
let mut row = row;
|
let mut row = row;
|
||||||
let mut column = column;
|
let mut column = column;
|
||||||
// Adjust the row and column indices based on boundary wrapping
|
// Adjust the row and column indices based on boundary wrapping
|
||||||
@@ -224,7 +224,7 @@ impl BitMatrixParser {
|
|||||||
* @param numColumns Number of columns in the mapping matrix
|
* @param numColumns Number of columns in the mapping matrix
|
||||||
* @return byte from the utah shape
|
* @return byte from the utah shape
|
||||||
*/
|
*/
|
||||||
fn readUtah(&mut self, row: usize, column: usize, numRows: usize, numColumns: usize) -> u32 {
|
fn readUtah(&mut self, row: isize, column: isize, numRows: isize, numColumns: isize) -> u32 {
|
||||||
let mut currentByte = 0;
|
let mut currentByte = 0;
|
||||||
if self.readModule(row - 2, column - 2, numRows, numColumns) {
|
if self.readModule(row - 2, column - 2, numRows, numColumns) {
|
||||||
currentByte |= 1;
|
currentByte |= 1;
|
||||||
@@ -269,7 +269,7 @@ impl BitMatrixParser {
|
|||||||
* @param numColumns Number of columns in the mapping matrix
|
* @param numColumns Number of columns in the mapping matrix
|
||||||
* @return byte from the Corner condition 1
|
* @return byte from the Corner condition 1
|
||||||
*/
|
*/
|
||||||
fn readCorner1(&mut self, numRows: usize, numColumns: usize) -> u32 {
|
fn readCorner1(&mut self, numRows: isize, numColumns: isize) -> u32 {
|
||||||
let mut currentByte = 0;
|
let mut currentByte = 0;
|
||||||
if self.readModule(numRows - 1, 0, numRows, numColumns) {
|
if self.readModule(numRows - 1, 0, numRows, numColumns) {
|
||||||
currentByte |= 1;
|
currentByte |= 1;
|
||||||
@@ -314,7 +314,7 @@ impl BitMatrixParser {
|
|||||||
* @param numColumns Number of columns in the mapping matrix
|
* @param numColumns Number of columns in the mapping matrix
|
||||||
* @return byte from the Corner condition 2
|
* @return byte from the Corner condition 2
|
||||||
*/
|
*/
|
||||||
fn readCorner2(&mut self, numRows: usize, numColumns: usize) -> u32 {
|
fn readCorner2(&mut self, numRows: isize, numColumns: isize) -> u32 {
|
||||||
let mut currentByte = 0;
|
let mut currentByte = 0;
|
||||||
if self.readModule(numRows - 3, 0, numRows, numColumns) {
|
if self.readModule(numRows - 3, 0, numRows, numColumns) {
|
||||||
currentByte |= 1;
|
currentByte |= 1;
|
||||||
@@ -359,7 +359,7 @@ impl BitMatrixParser {
|
|||||||
* @param numColumns Number of columns in the mapping matrix
|
* @param numColumns Number of columns in the mapping matrix
|
||||||
* @return byte from the Corner condition 3
|
* @return byte from the Corner condition 3
|
||||||
*/
|
*/
|
||||||
fn readCorner3(&mut self, numRows: usize, numColumns: usize) -> u32 {
|
fn readCorner3(&mut self, numRows: isize, numColumns: isize) -> u32 {
|
||||||
let mut currentByte = 0;
|
let mut currentByte = 0;
|
||||||
if self.readModule(numRows - 1, 0, numRows, numColumns) {
|
if self.readModule(numRows - 1, 0, numRows, numColumns) {
|
||||||
currentByte |= 1;
|
currentByte |= 1;
|
||||||
@@ -404,7 +404,7 @@ impl BitMatrixParser {
|
|||||||
* @param numColumns Number of columns in the mapping matrix
|
* @param numColumns Number of columns in the mapping matrix
|
||||||
* @return byte from the Corner condition 4
|
* @return byte from the Corner condition 4
|
||||||
*/
|
*/
|
||||||
fn readCorner4(&mut self, numRows: usize, numColumns: usize) -> u32 {
|
fn readCorner4(&mut self, numRows: isize, numColumns: isize) -> u32 {
|
||||||
let mut currentByte = 0;
|
let mut currentByte = 0;
|
||||||
if self.readModule(numRows - 3, 0, numRows, numColumns) {
|
if self.readModule(numRows - 3, 0, numRows, numColumns) {
|
||||||
currentByte |= 1;
|
currentByte |= 1;
|
||||||
|
|||||||
@@ -64,7 +64,7 @@ impl DataBlock {
|
|||||||
|
|
||||||
// Now establish DataBlocks of the appropriate size and number of data codewords
|
// Now establish DataBlocks of the appropriate size and number of data codewords
|
||||||
let mut result = Vec::with_capacity(totalBlocks);
|
let mut result = Vec::with_capacity(totalBlocks);
|
||||||
let numRXingResultBlocks = 0;
|
let mut numRXingResultBlocks = 0;
|
||||||
for ecBlock in ecBlockArray {
|
for ecBlock in ecBlockArray {
|
||||||
for _i in 0..ecBlock.getCount() {
|
for _i in 0..ecBlock.getCount() {
|
||||||
// for (int i = 0; i < ecBlock.getCount(); i++) {
|
// for (int i = 0; i < ecBlock.getCount(); i++) {
|
||||||
@@ -75,6 +75,7 @@ impl DataBlock {
|
|||||||
numDataCodewords as u32,
|
numDataCodewords as u32,
|
||||||
vec![0; numBlockCodewords],
|
vec![0; numBlockCodewords],
|
||||||
));
|
));
|
||||||
|
numRXingResultBlocks +=1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -693,12 +693,12 @@ fn decodeECISegment(bits: &mut BitSource, result: &mut ECIStringBuilder) -> Resu
|
|||||||
*/
|
*/
|
||||||
fn unrandomize255State(randomizedBase256Codeword: u32, base256CodewordPosition: usize) -> u32 {
|
fn unrandomize255State(randomizedBase256Codeword: u32, base256CodewordPosition: usize) -> u32 {
|
||||||
let pseudoRandomNumber = ((149 * base256CodewordPosition as u32) % 255) + 1;
|
let pseudoRandomNumber = ((149 * base256CodewordPosition as u32) % 255) + 1;
|
||||||
let tempVariable = randomizedBase256Codeword - pseudoRandomNumber;
|
let tempVariable = randomizedBase256Codeword as i32 - pseudoRandomNumber as i32;
|
||||||
|
|
||||||
if tempVariable >= 0 {
|
if tempVariable >= 0 {
|
||||||
tempVariable
|
tempVariable as u32
|
||||||
} else {
|
} else {
|
||||||
tempVariable + 256
|
(tempVariable + 256) as u32
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -48,8 +48,8 @@ impl Detector {
|
|||||||
pub fn detect(&self) -> Result<DatamatrixDetectorResult, Exceptions> {
|
pub fn detect(&self) -> Result<DatamatrixDetectorResult, Exceptions> {
|
||||||
let cornerPoints = self.rectangleDetector.detect()?;
|
let cornerPoints = self.rectangleDetector.detect()?;
|
||||||
|
|
||||||
let mut points = self.detectSolid1(&cornerPoints);
|
let mut points = self.detectSolid1(cornerPoints);
|
||||||
points = self.detectSolid2(&points);
|
points = self.detectSolid2(points);
|
||||||
if let Some(point) = self.correctTopRight(&points) {
|
if let Some(point) = self.correctTopRight(&points) {
|
||||||
points[3] = point;
|
points[3] = point;
|
||||||
} else {
|
} else {
|
||||||
@@ -59,7 +59,7 @@ impl Detector {
|
|||||||
// if points[3] == null {
|
// if points[3] == null {
|
||||||
// throw NotFoundException.getNotFoundInstance();
|
// throw NotFoundException.getNotFoundInstance();
|
||||||
// }
|
// }
|
||||||
points = self.shiftToModuleCenter(&points);
|
points = self.shiftToModuleCenter(points);
|
||||||
|
|
||||||
let topLeft = points[0];
|
let topLeft = points[0];
|
||||||
let bottomLeft = points[1];
|
let bottomLeft = points[1];
|
||||||
@@ -125,7 +125,7 @@ impl Detector {
|
|||||||
/**
|
/**
|
||||||
* Detect a solid side which has minimum transition.
|
* Detect a solid side which has minimum transition.
|
||||||
*/
|
*/
|
||||||
fn detectSolid1(&self, cornerPoints: &[RXingResultPoint]) -> [RXingResultPoint; 4] {
|
fn detectSolid1(&self, cornerPoints: Vec<RXingResultPoint>) -> [RXingResultPoint; 4] {
|
||||||
// 0 2
|
// 0 2
|
||||||
// 1 3
|
// 1 3
|
||||||
let pointA = cornerPoints[0];
|
let pointA = cornerPoints[0];
|
||||||
@@ -170,7 +170,7 @@ impl Detector {
|
|||||||
/**
|
/**
|
||||||
* Detect a second solid side next to first solid side.
|
* Detect a second solid side next to first solid side.
|
||||||
*/
|
*/
|
||||||
fn detectSolid2(&self, points: &[RXingResultPoint]) -> [RXingResultPoint; 4] {
|
fn detectSolid2(&self, points: [RXingResultPoint;4]) -> [RXingResultPoint; 4] {
|
||||||
// A..D
|
// A..D
|
||||||
// : :
|
// : :
|
||||||
// B--C
|
// B--C
|
||||||
@@ -262,7 +262,7 @@ impl Detector {
|
|||||||
/**
|
/**
|
||||||
* Shift the edge points to the module center.
|
* Shift the edge points to the module center.
|
||||||
*/
|
*/
|
||||||
fn shiftToModuleCenter(&self, points: &[RXingResultPoint]) -> [RXingResultPoint; 4] {
|
fn shiftToModuleCenter(&self, points: [RXingResultPoint;4]) -> [RXingResultPoint; 4] {
|
||||||
// A..D
|
// A..D
|
||||||
// | :
|
// | :
|
||||||
// B--C
|
// B--C
|
||||||
|
|||||||
@@ -17,9 +17,9 @@
|
|||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
aztec::AztecReader, maxicode::MaxiCodeReader, qrcode::QRCodeReader, BarcodeFormat,
|
aztec::AztecReader, datamatrix::DataMatrixReader, maxicode::MaxiCodeReader,
|
||||||
BinaryBitmap, DecodeHintType, DecodeHintValue, DecodingHintDictionary, Exceptions, RXingResult,
|
qrcode::QRCodeReader, BarcodeFormat, BinaryBitmap, DecodeHintType, DecodeHintValue,
|
||||||
Reader,
|
DecodingHintDictionary, Exceptions, RXingResult, Reader,
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -133,8 +133,7 @@ impl MultiFormatReader {
|
|||||||
readers.push(Box::new(QRCodeReader {}));
|
readers.push(Box::new(QRCodeReader {}));
|
||||||
}
|
}
|
||||||
if formats.contains(&BarcodeFormat::DATA_MATRIX) {
|
if formats.contains(&BarcodeFormat::DATA_MATRIX) {
|
||||||
unimplemented!("");
|
readers.push(Box::new(DataMatrixReader {}));
|
||||||
// readers.push(DataMatrixReader{});
|
|
||||||
}
|
}
|
||||||
if formats.contains(&BarcodeFormat::AZTEC) {
|
if formats.contains(&BarcodeFormat::AZTEC) {
|
||||||
readers.push(Box::new(AztecReader {}));
|
readers.push(Box::new(AztecReader {}));
|
||||||
@@ -155,11 +154,11 @@ impl MultiFormatReader {
|
|||||||
if readers.is_empty() {
|
if readers.is_empty() {
|
||||||
if !tryHarder {
|
if !tryHarder {
|
||||||
// readers.push( MultiFormatOneDReader::new(hints));
|
// readers.push( MultiFormatOneDReader::new(hints));
|
||||||
unimplemented!("");
|
//TODO: ADD MultiformatOneDReader here
|
||||||
}
|
}
|
||||||
|
|
||||||
readers.push(Box::new(QRCodeReader {}));
|
readers.push(Box::new(QRCodeReader {}));
|
||||||
// readers.push( Box::new(DataMatrixReader{}));
|
readers.push(Box::new(DataMatrixReader {}));
|
||||||
readers.push(Box::new(AztecReader {}));
|
readers.push(Box::new(AztecReader {}));
|
||||||
// readers.push( PDF417Reader());
|
// readers.push( PDF417Reader());
|
||||||
readers.push(Box::new(MaxiCodeReader {}));
|
readers.push(Box::new(MaxiCodeReader {}));
|
||||||
@@ -167,10 +166,10 @@ impl MultiFormatReader {
|
|||||||
|
|
||||||
if tryHarder {
|
if tryHarder {
|
||||||
// readers.push( Box::new(MultiFormatOneDReader::new(hints)));
|
// readers.push( Box::new(MultiFormatOneDReader::new(hints)));
|
||||||
unimplemented!("");
|
//TODO: ADD MultiformatOneDReader here
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
self.readers = Vec::new(); //readers.toArray(EMPTY_READER_ARRAY);
|
self.readers = readers;//Vec::new(); //readers.toArray(EMPTY_READER_ARRAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn decodeInternal(&mut self, image: &BinaryBitmap) -> Result<RXingResult, Exceptions> {
|
pub fn decodeInternal(&mut self, image: &BinaryBitmap) -> Result<RXingResult, Exceptions> {
|
||||||
@@ -212,3 +211,12 @@ impl MultiFormatReader {
|
|||||||
return Err(Exceptions::NotFoundException("".to_owned()));
|
return Err(Exceptions::NotFoundException("".to_owned()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for MultiFormatReader {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
hints: HashMap::new(),
|
||||||
|
readers: Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
|
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
|
|
||||||
use crate::{aztec::AztecWriter, qrcode::QRCodeWriter, BarcodeFormat, Exceptions, Writer};
|
use crate::{aztec::AztecWriter, qrcode::QRCodeWriter, BarcodeFormat, Exceptions, Writer, datamatrix::DataMatrixWriter};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is a factory class which finds the appropriate Writer subclass for the BarcodeFormat
|
* This is a factory class which finds the appropriate Writer subclass for the BarcodeFormat
|
||||||
@@ -67,8 +67,8 @@ impl Writer for MultiFormatWriter {
|
|||||||
// writer = PDF417Writer(),
|
// writer = PDF417Writer(),
|
||||||
BarcodeFormat::CODABAR => unimplemented!(""),
|
BarcodeFormat::CODABAR => unimplemented!(""),
|
||||||
// writer = CodaBarWriter(),
|
// writer = CodaBarWriter(),
|
||||||
BarcodeFormat::DATA_MATRIX => unimplemented!(""),
|
BarcodeFormat::DATA_MATRIX =>
|
||||||
// DataMatrixWriter{},
|
Box::new(DataMatrixWriter{}),
|
||||||
BarcodeFormat::AZTEC => Box::new(AztecWriter {}),
|
BarcodeFormat::AZTEC => Box::new(AztecWriter {}),
|
||||||
_ => {
|
_ => {
|
||||||
return Err(Exceptions::IllegalArgumentException(format!(
|
return Err(Exceptions::IllegalArgumentException(format!(
|
||||||
|
|||||||
@@ -1,36 +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.datamatrix;
|
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
|
||||||
import com.google.zxing.MultiFormatReader;
|
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author bbrown@google.com (Brian Brown)
|
|
||||||
*/
|
|
||||||
public final class DataMatrixBlackBox1TestCase extends AbstractBlackBoxTestCase {
|
|
||||||
|
|
||||||
public DataMatrixBlackBox1TestCase() {
|
|
||||||
super("src/test/resources/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
|
||||||
addTest(21, 21, 0.0f);
|
|
||||||
addTest(21, 21, 90.0f);
|
|
||||||
addTest(21, 21, 180.0f);
|
|
||||||
addTest(21, 21, 270.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,36 +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.datamatrix;
|
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
|
||||||
import com.google.zxing.MultiFormatReader;
|
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author dswitkin@google.com (Daniel Switkin)
|
|
||||||
*/
|
|
||||||
public final class DataMatrixBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
|
||||||
|
|
||||||
public DataMatrixBlackBox2TestCase() {
|
|
||||||
super("src/test/resources/blackbox/datamatrix-2", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
|
||||||
addTest(13, 13, 0, 1, 0.0f);
|
|
||||||
addTest(15, 15, 0, 1, 90.0f);
|
|
||||||
addTest(17, 16, 0, 1, 180.0f);
|
|
||||||
addTest(15, 15, 0, 1, 270.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,36 +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.datamatrix;
|
|
||||||
|
|
||||||
import com.google.zxing.BarcodeFormat;
|
|
||||||
import com.google.zxing.MultiFormatReader;
|
|
||||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author gitlost
|
|
||||||
*/
|
|
||||||
public final class DataMatrixBlackBox3TestCase extends AbstractBlackBoxTestCase {
|
|
||||||
|
|
||||||
public DataMatrixBlackBox3TestCase() {
|
|
||||||
super("src/test/resources/blackbox/datamatrix-3", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
|
||||||
addTest(18, 18, 0.0f);
|
|
||||||
addTest(17, 17, 90.0f);
|
|
||||||
addTest(18, 18, 180.0f);
|
|
||||||
addTest(18, 18, 270.0f);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
76
tests/datamatrix_black_box_test_cases.rs
Normal file
76
tests/datamatrix_black_box_test_cases.rs
Normal file
@@ -0,0 +1,76 @@
|
|||||||
|
/*
|
||||||
|
* 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.
|
||||||
|
*/
|
||||||
|
|
||||||
|
use rxing::MultiFormatReader;
|
||||||
|
|
||||||
|
mod common;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author bbrown@google.com (Brian Brown)
|
||||||
|
*/
|
||||||
|
#[test]
|
||||||
|
fn data_matrix_black_box1_test_case() {
|
||||||
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
|
"test_resources/blackbox/datamatrix-1",
|
||||||
|
MultiFormatReader::default(),
|
||||||
|
rxing::BarcodeFormat::DATA_MATRIX,
|
||||||
|
);
|
||||||
|
// super("src/test/resources/blackbox/datamatrix-1", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
||||||
|
tester.add_test(21, 21, 0.0);
|
||||||
|
tester.add_test(21, 21, 90.0);
|
||||||
|
tester.add_test(21, 21, 180.0);
|
||||||
|
tester.add_test(21, 21, 270.0);
|
||||||
|
|
||||||
|
tester.test_black_box();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author dswitkin@google.com (Daniel Switkin)
|
||||||
|
*/
|
||||||
|
#[test]
|
||||||
|
fn data_matrix_black_box2_test_case() {
|
||||||
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
|
"test_resources/blackbox/datamatrix-2",
|
||||||
|
MultiFormatReader::default(),
|
||||||
|
rxing::BarcodeFormat::DATA_MATRIX,
|
||||||
|
);
|
||||||
|
|
||||||
|
// super("src/test/resources/blackbox/datamatrix-2", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
||||||
|
tester.add_test_complex(13, 13, 0, 1, 0.0);
|
||||||
|
tester.add_test_complex(15, 15, 0, 1, 90.0);
|
||||||
|
tester.add_test_complex(17, 16, 0, 1, 180.0);
|
||||||
|
tester.add_test_complex(15, 15, 0, 1, 270.0);
|
||||||
|
tester.test_black_box();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author gitlost
|
||||||
|
*/
|
||||||
|
#[test]
|
||||||
|
fn data_matrix_black_box3_test_case() {
|
||||||
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
|
"test_resources/blackbox/datamatrix-3",
|
||||||
|
MultiFormatReader::default(),
|
||||||
|
rxing::BarcodeFormat::DATA_MATRIX,
|
||||||
|
);
|
||||||
|
|
||||||
|
// super("src/test/resources/blackbox/datamatrix-3", new MultiFormatReader(), BarcodeFormat.DATA_MATRIX);
|
||||||
|
tester.add_test(18, 18, 0.0);
|
||||||
|
tester.add_test(17, 17, 90.0);
|
||||||
|
tester.add_test(18, 18, 180.0);
|
||||||
|
tester.add_test(18, 18, 270.0);
|
||||||
|
tester.test_black_box();
|
||||||
|
}
|
||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{maxicode::MaxiCodeReader, BarcodeFormat, DecodeHintType};
|
use rxing::{maxicode::MaxiCodeReader, BarcodeFormat, DecodeHintType, MultiFormatReader};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
@@ -25,7 +25,7 @@ mod common;
|
|||||||
fn maxicode1_test_case() {
|
fn maxicode1_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/maxicode-1",
|
"test_resources/blackbox/maxicode-1",
|
||||||
MaxiCodeReader {},
|
MultiFormatReader::default(),
|
||||||
BarcodeFormat::MAXICODE,
|
BarcodeFormat::MAXICODE,
|
||||||
);
|
);
|
||||||
// super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE);
|
// super("src/test/resources/blackbox/maxicode-1", new MultiFormatReader(), BarcodeFormat.MAXICODE);
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
* limitations under the License.
|
* limitations under the License.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
use rxing::{qrcode::QRCodeReader, BarcodeFormat};
|
use rxing::{qrcode::QRCodeReader, BarcodeFormat, MultiFormatReader};
|
||||||
|
|
||||||
mod common;
|
mod common;
|
||||||
|
|
||||||
@@ -26,7 +26,7 @@ mod common;
|
|||||||
fn qrcode_black_box1_test_case() {
|
fn qrcode_black_box1_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-1",
|
"test_resources/blackbox/qrcode-1",
|
||||||
QRCodeReader {},
|
MultiFormatReader::default(),
|
||||||
rxing::BarcodeFormat::QR_CODE,
|
rxing::BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
// super("src/test/resources/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
// super("src/test/resources/blackbox/qrcode-1", new MultiFormatReader(), BarcodeFormat.QR_CODE);
|
||||||
@@ -46,6 +46,7 @@ fn qrcode_black_box1_test_case() {
|
|||||||
fn qrcode_black_box2_test_case() {
|
fn qrcode_black_box2_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-2",
|
"test_resources/blackbox/qrcode-2",
|
||||||
|
// MultiFormatReader::default(),
|
||||||
QRCodeReader {},
|
QRCodeReader {},
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
@@ -65,7 +66,7 @@ fn qrcode_black_box2_test_case() {
|
|||||||
fn qrcode_black_box3_test_case() {
|
fn qrcode_black_box3_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-3",
|
"test_resources/blackbox/qrcode-3",
|
||||||
QRCodeReader {},
|
MultiFormatReader::default(),
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.add_test(38, 38, 0.0);
|
tester.add_test(38, 38, 0.0);
|
||||||
@@ -86,7 +87,7 @@ fn qrcode_black_box3_test_case() {
|
|||||||
fn qrcode_black_box4_test_case() {
|
fn qrcode_black_box4_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-4",
|
"test_resources/blackbox/qrcode-4",
|
||||||
QRCodeReader {},
|
MultiFormatReader::default(),
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.add_test(36, 36, 0.0);
|
tester.add_test(36, 36, 0.0);
|
||||||
@@ -109,7 +110,7 @@ fn qrcode_black_box4_test_case() {
|
|||||||
fn qrcode_black_box5_test_case() {
|
fn qrcode_black_box5_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-5",
|
"test_resources/blackbox/qrcode-5",
|
||||||
QRCodeReader {},
|
MultiFormatReader::default(),
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.add_test(19, 19, 0.0);
|
tester.add_test(19, 19, 0.0);
|
||||||
@@ -129,7 +130,7 @@ fn qrcode_black_box5_test_case() {
|
|||||||
fn qrcode_black_box6_test_case() {
|
fn qrcode_black_box6_test_case() {
|
||||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||||
"test_resources/blackbox/qrcode-6",
|
"test_resources/blackbox/qrcode-6",
|
||||||
QRCodeReader {},
|
MultiFormatReader::default(),
|
||||||
BarcodeFormat::QR_CODE,
|
BarcodeFormat::QR_CODE,
|
||||||
);
|
);
|
||||||
tester.add_test(15, 15, 0.0);
|
tester.add_test(15, 15, 0.0);
|
||||||
|
|||||||
Reference in New Issue
Block a user