Blurry camera preview prevents scanning of long barcode?

  • Efren O'Neill-Carrillo

    I am trying to scan a VIN barcode, which is a long barcode.

    I notice that the barcode looks blurry in the camera preview. In the device camera, when focus is done, the barcode looks perfect.

    I suspect that this blurriness is preventing ImageScanner from understanding the barcode.

    Is there a way to fix preview's focus so that the image is as sharp as possible?

  • Efren O'Neill-Carrillo

    Got working! You changing the camera preview size also changes the preview resolution. Once I did this, my two test devices recognized the VIN barcode quite fast. Once of my devices do have some problem, but that's because its resolution is not the best.

    Awesome component!

    This is the code I used to increase the resolution to the best one available.

    Camera camera =;
    List<Size> cameraPreviewSizes = camera.getParameters().getSupportedPreviewSizes();

    cameraParams.setPreviewSize(cameraPreviewSizes.get(cameraPreviewSizes.size() - 1).width, cameraPreviewSizes.get(cameraPreviewSizes.size() - 1).height);



Log in to post a comment.