Search in sources :

Example 1 with ExpandedProductParsedResult

use of com.google.zxing.client.result.ExpandedProductParsedResult in project zxing by zxing.

the class RSSExpandedImage2resultTestCase method assertCorrectImage2result.

private static void assertCorrectImage2result(String fileName, ExpandedProductParsedResult expected) throws IOException, NotFoundException {
    Path path = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/rssexpanded-1/").resolve(fileName);
    BufferedImage image = ImageIO.read(path.toFile());
    BinaryBitmap binaryMap = new BinaryBitmap(new GlobalHistogramBinarizer(new BufferedImageLuminanceSource(image)));
    int rowNumber = binaryMap.getHeight() / 2;
    BitArray row = binaryMap.getBlackRow(rowNumber, null);
    Result theResult;
    try {
        RSSExpandedReader rssExpandedReader = new RSSExpandedReader();
        theResult = rssExpandedReader.decodeRow(rowNumber, row, null);
    } catch (ReaderException re) {
        fail(re.toString());
        return;
    }
    assertSame(BarcodeFormat.RSS_EXPANDED, theResult.getBarcodeFormat());
    ParsedResult result = ResultParser.parseResult(theResult);
    assertEquals(expected, result);
}
Also used : Path(java.nio.file.Path) GlobalHistogramBinarizer(com.google.zxing.common.GlobalHistogramBinarizer) BufferedImageLuminanceSource(com.google.zxing.BufferedImageLuminanceSource) ParsedResult(com.google.zxing.client.result.ParsedResult) ExpandedProductParsedResult(com.google.zxing.client.result.ExpandedProductParsedResult) BitArray(com.google.zxing.common.BitArray) BinaryBitmap(com.google.zxing.BinaryBitmap) BufferedImage(java.awt.image.BufferedImage) Result(com.google.zxing.Result) ParsedResult(com.google.zxing.client.result.ParsedResult) ExpandedProductParsedResult(com.google.zxing.client.result.ExpandedProductParsedResult) ReaderException(com.google.zxing.ReaderException)

Example 2 with ExpandedProductParsedResult

use of com.google.zxing.client.result.ExpandedProductParsedResult in project zxing by zxing.

the class RSSExpandedImage2resultTestCase method testDecodeRow2result_2.

@Test
public void testDecodeRow2result_2() throws Exception {
    // (01)90012345678908(3103)001750
    ExpandedProductParsedResult expected = new ExpandedProductParsedResult("(01)90012345678908(3103)001750", "90012345678908", null, null, null, null, null, null, "001750", ExpandedProductParsedResult.KILOGRAM, "3", null, null, null, new HashMap<String, String>());
    assertCorrectImage2result("2.png", expected);
}
Also used : ExpandedProductParsedResult(com.google.zxing.client.result.ExpandedProductParsedResult) Test(org.junit.Test)

Aggregations

ExpandedProductParsedResult (com.google.zxing.client.result.ExpandedProductParsedResult)2 BinaryBitmap (com.google.zxing.BinaryBitmap)1 BufferedImageLuminanceSource (com.google.zxing.BufferedImageLuminanceSource)1 ReaderException (com.google.zxing.ReaderException)1 Result (com.google.zxing.Result)1 ParsedResult (com.google.zxing.client.result.ParsedResult)1 BitArray (com.google.zxing.common.BitArray)1 GlobalHistogramBinarizer (com.google.zxing.common.GlobalHistogramBinarizer)1 BufferedImage (java.awt.image.BufferedImage)1 Path (java.nio.file.Path)1 Test (org.junit.Test)1