mirror of
https://github.com/starovoid/rxing.git
synced 2026-07-26 04:12:34 +00:00
rss_expanded integration partial pass
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
use super::rss::expanded::RSSExpandedReader;
|
||||
use super::rss::RSS14Reader;
|
||||
use super::CodaBarReader;
|
||||
use super::Code128Reader;
|
||||
@@ -90,9 +91,9 @@ impl MultiFormatOneDReader {
|
||||
if possibleFormats.contains(&BarcodeFormat::RSS_14) {
|
||||
readers.push(Box::new(RSS14Reader::new()));
|
||||
}
|
||||
// if (possibleFormats.contains(&BarcodeFormat::RSS_EXPANDED)) {
|
||||
// readers.add(new RSSExpandedReader());
|
||||
// }
|
||||
if possibleFormats.contains(&BarcodeFormat::RSS_EXPANDED) {
|
||||
readers.push(Box::new(RSSExpandedReader::new()));
|
||||
}
|
||||
}
|
||||
if readers.is_empty() {
|
||||
readers.push(Box::new(MultiFormatUPCEANReader::new(hints)));
|
||||
@@ -102,7 +103,7 @@ impl MultiFormatOneDReader {
|
||||
readers.push(Box::new(Code128Reader {}));
|
||||
readers.push(Box::new(ITFReader::default()));
|
||||
readers.push(Box::new(RSS14Reader::new()));
|
||||
// readers.push(new RSSExpandedReader());
|
||||
readers.push(Box::new(RSSExpandedReader::new()));
|
||||
}
|
||||
|
||||
Self(readers)
|
||||
|
||||
@@ -500,7 +500,7 @@ impl<'a> GeneralAppIdDecoder<'_> {
|
||||
}
|
||||
|
||||
let mut i = 0;
|
||||
while i < 4 && pos < self.information.getSize() {
|
||||
while i < 4 && i + pos < self.information.getSize() {
|
||||
// for (int i = 0; i < 4 && i + pos < this.information.getSize(); ++i) {
|
||||
if self.information.get(pos + i) {
|
||||
return false;
|
||||
|
||||
@@ -477,11 +477,12 @@ impl RSSExpandedReader {
|
||||
|
||||
// Remove all the rows that contains only specified pairs
|
||||
fn removePartialRows(pairs: &[ExpandedPair], rows: &mut Vec<ExpandedRow>) {
|
||||
for i in 0..rows.len() {
|
||||
let row_search = rows.clone();
|
||||
for i in 0..row_search.len() {
|
||||
// for r in rows {
|
||||
// for (Iterator<ExpandedRow> iterator = rows.iterator(); iterator.hasNext();) {
|
||||
// ExpandedRow r = iterator.next();
|
||||
let r = rows.get(i).unwrap();
|
||||
let r = row_search.get(i).unwrap();
|
||||
if r.getPairs().len() != pairs.len() {
|
||||
let mut allFound = true;
|
||||
for p in r.getPairs() {
|
||||
@@ -600,7 +601,7 @@ impl RSSExpandedReader {
|
||||
|
||||
checksum %= 211;
|
||||
|
||||
let checkCharacterValue = 211 * (s - 4) + checksum;
|
||||
let checkCharacterValue = (211 * (s as i64 - 4) + checksum as i64) as u32;
|
||||
|
||||
checkCharacterValue == checkCharacter.unwrap().getValue()
|
||||
}
|
||||
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||
*/
|
||||
public final class RSSExpandedBlackBox1TestCase extends AbstractBlackBoxTestCase {
|
||||
|
||||
public RSSExpandedBlackBox1TestCase() {
|
||||
super("src/test/resources/blackbox/rssexpanded-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
addTest(32, 32, 0.0f);
|
||||
addTest(32, 32, 180.0f);
|
||||
}
|
||||
}
|
||||
@@ -1,43 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||
*/
|
||||
public final class RSSExpandedBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||
|
||||
public RSSExpandedBlackBox2TestCase() {
|
||||
super("src/test/resources/blackbox/rssexpanded-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
addTest(21, 23, 0.0f);
|
||||
addTest(21, 23, 180.0f);
|
||||
}
|
||||
}
|
||||
@@ -1,44 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||
*/
|
||||
public final class RSSExpandedBlackBox3TestCase extends AbstractBlackBoxTestCase {
|
||||
|
||||
public RSSExpandedBlackBox3TestCase() {
|
||||
super("src/test/resources/blackbox/rssexpanded-3", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
addTest(117, 117, 0.0f);
|
||||
addTest(117, 117, 180.0f);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images including
|
||||
* stacked RSS barcodes.
|
||||
*/
|
||||
public final class RSSExpandedStackedBlackBox1TestCase extends AbstractBlackBoxTestCase {
|
||||
|
||||
public RSSExpandedStackedBlackBox1TestCase() {
|
||||
super("src/test/resources/blackbox/rssexpandedstacked-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
addTest(59, 64, 0.0f);
|
||||
addTest(59, 64, 180.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
package com.google.zxing.oned.rss.expanded;
|
||||
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.MultiFormatReader;
|
||||
import com.google.zxing.common.AbstractBlackBoxTestCase;
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images including
|
||||
* stacked RSS barcodes.
|
||||
*/
|
||||
public final class RSSExpandedStackedBlackBox2TestCase extends AbstractBlackBoxTestCase {
|
||||
|
||||
public RSSExpandedStackedBlackBox2TestCase() {
|
||||
super("src/test/resources/blackbox/rssexpandedstacked-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
addTest(2, 7, 0.0f);
|
||||
addTest(2, 7, 180.0f);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
123
tests/rss_expanded_blackbox.rs
Normal file
123
tests/rss_expanded_blackbox.rs
Normal file
@@ -0,0 +1,123 @@
|
||||
/*
|
||||
* Copyright (C) 2010 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.
|
||||
*/
|
||||
|
||||
/*
|
||||
* These authors would like to acknowledge the Spanish Ministry of Industry,
|
||||
* Tourism and Trade, for the support in the project TSI020301-2008-2
|
||||
* "PIRAmIDE: Personalizable Interactions with Resources on AmI-enabled
|
||||
* Mobile Dynamic Environments", led by Treelogic
|
||||
* ( http://www.treelogic.com/ ):
|
||||
*
|
||||
* http://www.piramidepse.com/
|
||||
*/
|
||||
|
||||
use rxing::{BarcodeFormat, MultiFormatReader};
|
||||
|
||||
mod common;
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||
*/
|
||||
#[test]
|
||||
fn rssexpanded_black_box1_test_case() {
|
||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||
"test_resources/blackbox/rssexpanded-1",
|
||||
MultiFormatReader::default(),
|
||||
BarcodeFormat::RSS_EXPANDED,
|
||||
);
|
||||
|
||||
// super("src/test/resources/blackbox/rssexpanded-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
tester.add_test(32, 32, 0.0);
|
||||
tester.add_test(32, 32, 180.0);
|
||||
|
||||
tester.test_black_box()
|
||||
}
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||
*/
|
||||
#[test]
|
||||
fn rssexpanded_black_box2_test_case() {
|
||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||
"test_resources/blackbox/rssexpanded-2",
|
||||
MultiFormatReader::default(),
|
||||
BarcodeFormat::RSS_EXPANDED,
|
||||
);
|
||||
|
||||
// super("src/test/resources/blackbox/rssexpanded-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
tester.add_test(21, 23, 0.0);
|
||||
tester.add_test(21, 23, 180.0);
|
||||
|
||||
tester.test_black_box()
|
||||
}
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images.
|
||||
*/
|
||||
#[test]
|
||||
fn rssexpanded_black_box3_test_case() {
|
||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||
"test_resources/blackbox/rssexpanded-3",
|
||||
MultiFormatReader::default(),
|
||||
BarcodeFormat::RSS_EXPANDED,
|
||||
);
|
||||
|
||||
// super("src/test/resources/blackbox/rssexpanded-3", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
tester.add_test(117, 117, 0.0);
|
||||
tester.add_test(117, 117, 180.0);
|
||||
|
||||
tester.test_black_box()
|
||||
}
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images including
|
||||
* stacked RSS barcodes.
|
||||
*/
|
||||
#[test]
|
||||
fn rssexpanded_stacked_black_box1_test_case() {
|
||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||
"test_resources/blackbox/rssexpandedstacked-1",
|
||||
MultiFormatReader::default(),
|
||||
BarcodeFormat::RSS_EXPANDED,
|
||||
);
|
||||
|
||||
// super("src/test/resources/blackbox/rssexpandedstacked-1", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
tester.add_test(59, 64, 0.0);
|
||||
tester.add_test(59, 64, 180.0);
|
||||
|
||||
tester.test_black_box()
|
||||
}
|
||||
|
||||
/**
|
||||
* A test of {@link RSSExpandedReader} against a fixed test set of images including
|
||||
* stacked RSS barcodes.
|
||||
*/
|
||||
#[test]
|
||||
fn rssexpanded_stacked_black_box2_test_case() {
|
||||
let mut tester = common::AbstractBlackBoxTestCase::new(
|
||||
"test_resources/blackbox/rssexpandedstacked-2",
|
||||
MultiFormatReader::default(),
|
||||
BarcodeFormat::RSS_EXPANDED,
|
||||
);
|
||||
|
||||
// super("src/test/resources/blackbox/rssexpandedstacked-2", new MultiFormatReader(), BarcodeFormat.RSS_EXPANDED);
|
||||
tester.add_test(2, 7, 0.0);
|
||||
tester.add_test(2, 7, 180.0);
|
||||
|
||||
tester.test_black_box()
|
||||
}
|
||||
|
||||
/* one too few images are passing on above, probably a problem edge case */
|
||||
Reference in New Issue
Block a user