Search code examples
zxing

zxing returns wrong position of CODE_39-Barcode


I'm using zxing to find barcodes in webcam images:

http://s21.postimg.org/vxdrx07av/zxing.png

zxing finds the barcode reliable and extracts the information. It also returns the position of the barcode as two points (x1,y) (x2,y) (same value for both points since it uses scanlines (I think)).

If I plot these points, the y-value is ok, the first (left) x-value is a bit right in most images and the right end point is far off. (See example image).

I plan some post-processing, so I need the position of the barcode. Has anyone seen this behavior before? I don't see how a mistake during rendering could cause this and the points are extracted like in the command-line demo application.


I just tried to read an EAN_13 and got perfect barcode location. The code in the image is CODE_39 so there could be a problem with this detector.


Edit 2: Original Image and one with marker are in the comment

I use the Qt wrapper and extract the endpoints as (qzxing.cpp l. 140ff)

    res = ((MultiFormatReader*)decoder)->decode(ref, hints);

    if (pts){
        pts->clear();
        for (int j = 0; j < res->getResultPoints()->size(); j++) {
            cout << "  Point[" << j <<  "]: "
                 << res->getResultPoints()[j]->getX() << " "
                 << res->getResultPoints()[j]->getY() << endl;
            pts->push_back(QPointF(res->getResultPoints()[j]->getX(),res->getResultPoints()[j]->getY()));
        }
    }

If I extract an EAN14-Barcode, the endpoints are exactly within the end-markers (the two small bars) so I think that I read and visualize the points correctly.


Solution

  • Nice one, that's a bug. It's being fixed in HEAD now. Answer is that it's a bug: https://code.google.com/p/zxing/issues/detail?id=1776