QT + ZBar read barcode from jpg/pdf



  • Hi, I have a problem with ZBAR. Please help.
    I would like to read the code from a jpg / pdf file and assign it to a variable. Can someone show me a simple example?

    Today I downloaded and unzipped ZBAR. I added "zbar.h" and the ZBAR folder to the project.

    Please help.



  • Don't know if can help but some time ago I used QZxing.
    I suggest you to try. There are also a lot of example.

    You ca also read this: https://www.kdab.com/efficient-barcode-scanning-qzxing/



  • Thanks, I was successful with JPG / PNG

    https://github.com/ftylitak/qzxing

    Copy source code folder of QZXing to the root of your project. Add the following line to your .pro file. For more information see here.

    include(QZXing/QZXing.pri)
    
    #include <QZXing.h>
    
    int main() 
    {
    	QImage imageToDecode("file.png");
    	QZXing decoder;
    	decoder.setDecoder( QZXing::DecoderFormat_QR_CODE | QZXing::DecoderFormat_EAN_13 );
    	QString result = decoder.decodeImage(imageToDecode);
    }
    

    But I have a problem with PDF. Is there a simple method? Do I need to convert pdf pages to image.



  • @jacekkozik said in QT + ZBar read barcode from jpg/pdf:

    But I have a problem with PDF. Is there a simple method? Do I need to convert pdf pages to image.

    I think you should convert it to QImage and parse it.


Log in to reply