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());
}
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);
}
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);
}
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;
}
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));
}
Aggregations