Giter Club home page Giter Club logo

Comments (4)

willglynn avatar willglynn commented on July 17, 2024

Following these same steps, I get:

> r = z.process
 => [#<ZBar::Symbol:0x007fd63a869c60 @symbology="EAN-13", @data="9788679912077", @addon="", @quality=835, @location=[[819, 28], [463, 29], [130, 29], ...]>] 

Are you sure the zbar gem is loading the right libzbar.so? Try setting the ZBAR_LIB environment variable to its full path.

from ruby-zbar.

pzb avatar pzb commented on July 17, 2024

I'm sure it is loading the right libzbar:

irb(main):007:0> ZBar.ffi_libraries.map{|x|x.instance_variable_get(:@name)}
=> ["/usr/lib64/libzbar.so.0.2.0", "/usr/lib64/libzbar.so.0"]
[user@ip-10-0-0-119 ~]$ ldd `which zbarimg` | grep zbar
        libzbar.so.0 => /usr/lib64/libzbar.so.0 (0x00007f625b520000)

If I run convert bigstock-Barcode-18830351.jpg bigstock-Barcode-18830351.pgm and then use ZBar::Image.from_pgm, it processes the pgm image and decodes the barcode fine. So there is only a problem with jpegs.

from ruby-zbar.

ArthurN avatar ArthurN commented on July 17, 2024

Almost a year later, I have this same problem. In my case, I'm on CentOS, and rebuilt the rpm from source, applying the patch provided here.

However, running the image directly through the zbarimg binary DOES work.

@pzb Did you ever resolve this, or just end up converting to PGM?

from ruby-zbar.

arloan avatar arloan commented on July 17, 2024

It's may be a JPEG quality issue.

I got a .png QR Code image cropped from a scanner generated image, and zbarimg can read it. While when I use imagemagick convert it to .jpg, then zbar failed to read it. Convert it to .pgm, zbar reads it.

Finally, I convert it to .jpg via command: convert crop.png -quality 90 crop.jpg, then zbar can read the jpg file now.

bogon: ~/Downloads/VouchPic ]
stone$ zbarimg crop2.png
QR-Code:01,01,3400182130,00993210,1635.85,20180814,,4A08,
scanned 1 barcode symbols from 1 images in 0.01 seconds

bogon: ~/Downloads/VouchPic ]
stone$ convert crop2.png crop2.jpg
bogon: ~/Downloads/VouchPic ]
stone$ ruby -r zbar -e "p ZBar::Image.from_jpeg(File.binread('crop2.jpg')).process"
[]
bogon: ~/Downloads/VouchPic ]
stone$ convert crop2.png -quality 90 crop2.jpg
bogon: ~/Downloads/VouchPic ]
stone$ ruby -r zbar -e "p ZBar::Image.from_jpeg(File.binread('crop2.jpg')).process"
[#<ZBar::Symbol:0x00007ff6ce11cb10 @symbology="QR-Code", @data="01,01,3400182130,00993210,1635.85,20180814,,4A08,", @addon="", @quality=1, @location=[[20, 11], [17, 200], [211, 203], [212, 13]]>]
bogon: ~/Downloads/VouchPic ]
stone$ 

from ruby-zbar.

Related Issues (13)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.