1

I am creating an application that is using the ZBar SDK on Android to scan books and get their ISBN. I have gotten everything to work on the physical side. You press a button, the scanner window pops up and scans the bar code.

The problem comes when the application gets the ISBN from the scanner, it seems that the scanner is either reading the bar code incorrectly or that I am not pulling in the right data. Does anyone know how to fix this issue? Thanks. Below is relevant code, and a few screens

    @Override
public void onClick(View v) 
{
    //TODO add functionallity
    if(v.getId() == R.id.ScanButton)
    {
        Intent intent = new Intent(this, ZBarScannerActivity.class);
        intent.putExtra(ZBarConstants.SCAN_MODES, new int[]{Symbol.ISBN10, Symbol.ISBN13, Symbol.EAN8, Symbol.EAN13 });
        startActivityForResult(intent, ZBAR_SCANNER_REQUEST);

    }

}
@Override
protected void onActivityResult(int requestCode, int resultCode, Intent data)
{    
    if (resultCode == RESULT_OK) 
    {
        // Scan result is available by making a call to data.getStringExtra(ZBarConstants.SCAN_RESULT)
        // Type of the scan result is available by making a call to data.getStringExtra(ZBarConstants.SCAN_RESULT_TYPE)
        contentText.setText("ISBN: " + data.getStringExtra(ZBarConstants.SCAN_RESULT));
        Toast.makeText(this, "Scan Result = " + data.getStringExtra(ZBarConstants.SCAN_RESULT), Toast.LENGTH_SHORT).show();

        Toast.makeText(this, "Scan Result Type = " + data.getStringExtra(ZBarConstants.SCAN_RESULT_TYPE), Toast.LENGTH_SHORT).show();
        // The value of type indicates one of the symbols listed in Advanced Options below.
    } 
    else if(resultCode == RESULT_CANCELED) 
    {
        Toast.makeText(this, "Scanning Cancelled", Toast.LENGTH_SHORT).show();
    }
}

First Screen

Second Screen

Offending Bar Code

1 Answer 1

4
+50

We have been using Zbar in production in one of our desktop applications. In this we extract the barcode from the Image and use it. Though it is different from yours but the issue is the same where we extract the barcode from live stream.

The issue you are facing is very prevalent and error prone. And ultimately all depends on the picture. (In fact you will observe the same behavior with Zxing, Eymbarcode and other open source ones. The most stable one I found is this). Ultimately we had to resort to Image taking guidelines. The below are the quality factors we use to avoid it:

The following factors determine the detection ability of the application:

  1. Resolution
  2. Focus
  3. Lighting and Exposure
  4. Noise

Hence it is essential that all the above four are taken care of while the picture is taken.

  1. Resolution: It would be desired that the barcode occupy significant portion on the Image. For long linear barcodes or dense 2-D symbols, one will probably have to increase the resolution. If the resolution decreases below two pixels, it will be hard to scan the barcode.

  2. Focus: Blurred Images are highly undesired. Even a portion of barcode consisting of blurry part will lead to inability of detection.

  3. Lighting and Exposure: An image that is too bright or overexposed can completely wash out any barcodes. An image that is too dark or underexposed will not provide sufficient contrast for the scanner. Low light levels also tend to produce noisier images.

  4. Noise: Random variation of brightness/color can make it difficult to scan the barcode.

  5. Angle: It would be preferred to have the barcode placed either horizontally or vertically placed.

  6. Tilt: It would be preferred if the camera is placed perpendicular to the image.

The above does not solve your problems, but I hope it helps

1
  • This is a good answer. After doing a lot of testing I think that the most logical choice will be to basically enforce good use of the camera. Granted there are a few things I will check such as string length and consistency of certain numbers that will show up in all ISBNs but one scan with good rules seems to be the most user friendly option. Thank you.
    – Alioo
    Aug 29, 2013 at 15:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.