Search in sources :

Example 6 with MultiFormatReader

use of com.google.zxing.MultiFormatReader in project zxing by zxing.

the class MultiTestCase method testMulti.

@Test
public void testMulti() throws Exception {
    // Very basic test for now
    Path testBase = AbstractBlackBoxTestCase.buildTestBase("src/test/resources/blackbox/multi-1");
    Path testImage = testBase.resolve("1.png");
    BufferedImage image = ImageIO.read(testImage.toFile());
    LuminanceSource source = new BufferedImageLuminanceSource(image);
    BinaryBitmap bitmap = new BinaryBitmap(new HybridBinarizer(source));
    MultipleBarcodeReader reader = new GenericMultipleBarcodeReader(new MultiFormatReader());
    Result[] results = reader.decodeMultiple(bitmap);
    assertNotNull(results);
    assertEquals(2, results.length);
    assertEquals("031415926531", results[0].getText());
    assertEquals(BarcodeFormat.UPC_A, results[0].getBarcodeFormat());
    assertEquals("www.airtable.com/jobs", results[1].getText());
    assertEquals(BarcodeFormat.QR_CODE, results[1].getBarcodeFormat());
}
Also used : Path(java.nio.file.Path) MultiFormatReader(com.google.zxing.MultiFormatReader) LuminanceSource(com.google.zxing.LuminanceSource) BufferedImageLuminanceSource(com.google.zxing.BufferedImageLuminanceSource) BufferedImageLuminanceSource(com.google.zxing.BufferedImageLuminanceSource) BinaryBitmap(com.google.zxing.BinaryBitmap) HybridBinarizer(com.google.zxing.common.HybridBinarizer) BufferedImage(java.awt.image.BufferedImage) Result(com.google.zxing.Result) Test(org.junit.Test)

Example 7 with MultiFormatReader

use of com.google.zxing.MultiFormatReader in project smartmodule by carozhu.

the class DecodeHandler method setHints.

public void setHints(Hashtable<DecodeHintType, Object> paramHashtable) {
    multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(paramHashtable);
}
Also used : MultiFormatReader(com.google.zxing.MultiFormatReader)

Example 8 with MultiFormatReader

use of com.google.zxing.MultiFormatReader in project BGAQRCode-Android by bingoogolapple.

the class ZXingView method initMultiFormatReader.

private void initMultiFormatReader() {
    mMultiFormatReader = new MultiFormatReader();
    mMultiFormatReader.setHints(QRCodeDecoder.HINTS);
}
Also used : MultiFormatReader(com.google.zxing.MultiFormatReader)

Example 9 with MultiFormatReader

use of com.google.zxing.MultiFormatReader in project SimplifyReader by chentao0707.

the class DecodeUtils method decodeWithZxing.

public String decodeWithZxing(Bitmap bitmap) {
    MultiFormatReader multiFormatReader = new MultiFormatReader();
    multiFormatReader.setHints(changeZXingDecodeDataMode());
    int width = bitmap.getWidth();
    int height = bitmap.getHeight();
    int[] pixels = new int[width * height];
    bitmap.getPixels(pixels, 0, width, 0, 0, width, height);
    Result rawResult = null;
    RGBLuminanceSource source = new RGBLuminanceSource(width, height, pixels);
    if (source != null) {
        BinaryBitmap binaryBitmap = new BinaryBitmap(new HybridBinarizer(source));
        try {
            rawResult = multiFormatReader.decodeWithState(binaryBitmap);
        } catch (ReaderException re) {
        // continue
        } finally {
            multiFormatReader.reset();
        }
    }
    return rawResult != null ? rawResult.getText() : null;
}
Also used : MultiFormatReader(com.google.zxing.MultiFormatReader) BinaryBitmap(com.google.zxing.BinaryBitmap) HybridBinarizer(com.google.zxing.common.HybridBinarizer) RGBLuminanceSource(com.google.zxing.RGBLuminanceSource) Result(com.google.zxing.Result) ReaderException(com.google.zxing.ReaderException)

Example 10 with MultiFormatReader

use of com.google.zxing.MultiFormatReader in project zxing-android-embedded by journeyapps.

the class DecoratedBarcodeView method initializeFromIntent.

/**
     * Convenience method to initialize camera id, decode formats and prompt message from an intent.
     *
     * @param intent the intent, as generated by IntentIntegrator
     */
public void initializeFromIntent(Intent intent) {
    // Scan the formats the intent requested, and return the result to the calling activity.
    Set<BarcodeFormat> decodeFormats = DecodeFormatManager.parseDecodeFormats(intent);
    Map<DecodeHintType, Object> decodeHints = DecodeHintManager.parseDecodeHints(intent);
    CameraSettings settings = new CameraSettings();
    if (intent.hasExtra(Intents.Scan.CAMERA_ID)) {
        int cameraId = intent.getIntExtra(Intents.Scan.CAMERA_ID, -1);
        if (cameraId >= 0) {
            settings.setRequestedCameraId(cameraId);
        }
    }
    String customPromptMessage = intent.getStringExtra(Intents.Scan.PROMPT_MESSAGE);
    if (customPromptMessage != null) {
        setStatusText(customPromptMessage);
    }
    // Check to see if the scan should be inverted.
    boolean inverted = intent.getBooleanExtra(Intents.Scan.INVERTED_SCAN, false);
    String characterSet = intent.getStringExtra(Intents.Scan.CHARACTER_SET);
    MultiFormatReader reader = new MultiFormatReader();
    reader.setHints(decodeHints);
    barcodeView.setCameraSettings(settings);
    barcodeView.setDecoderFactory(new DefaultDecoderFactory(decodeFormats, decodeHints, characterSet, inverted));
}
Also used : MultiFormatReader(com.google.zxing.MultiFormatReader) DecodeHintType(com.google.zxing.DecodeHintType) BarcodeFormat(com.google.zxing.BarcodeFormat) CameraSettings(com.journeyapps.barcodescanner.camera.CameraSettings) ResultPoint(com.google.zxing.ResultPoint)

Aggregations

MultiFormatReader (com.google.zxing.MultiFormatReader)16 BinaryBitmap (com.google.zxing.BinaryBitmap)10 Result (com.google.zxing.Result)10 HybridBinarizer (com.google.zxing.common.HybridBinarizer)10 ReaderException (com.google.zxing.ReaderException)5 DecodeHintType (com.google.zxing.DecodeHintType)4 LuminanceSource (com.google.zxing.LuminanceSource)4 BufferedImageLuminanceSource (com.google.zxing.client.j2se.BufferedImageLuminanceSource)3 BufferedImage (java.awt.image.BufferedImage)3 BarcodeFormat (com.google.zxing.BarcodeFormat)2 RGBLuminanceSource (com.google.zxing.RGBLuminanceSource)2 Reader (com.google.zxing.Reader)2 ResultPoint (com.google.zxing.ResultPoint)2 GlobalHistogramBinarizer (com.google.zxing.common.GlobalHistogramBinarizer)2 GenericMultipleBarcodeReader (com.google.zxing.multi.GenericMultipleBarcodeReader)2 MultipleBarcodeReader (com.google.zxing.multi.MultipleBarcodeReader)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2 EnumMap (java.util.EnumMap)2 Bitmap (android.graphics.Bitmap)1