LoginSignup
20
16

More than 5 years have passed since last update.

zbar で画像からバーコードを読み取る

Last updated at Posted at 2013-03-19

ZBar (http://zbar.sourceforge.net/) という、すばらしい OSS でバーコードを読み取るまで。
OSX 10.8.2 + Homebrew で。

brew install zbar でエラーでたので、formula 編集。

brew edit zbar

args に --without-xshm --without-xv 追加

  def install
    args = %W[
      --disable-dependency-tracking
      --prefix=#{prefix}
      --without-python
      --without-qt
      --disable-video
      --without-gtk
+     --without-xshm
+     --without-xv
    ]
brew install zbar

zbarimg 実行すると /usr/local/lib/libltdl.7.dylib がないといわれるので ln -s。

ln -s /usr/local/Cellar/libtool/2.4.2/lib/libltdl.7.dylib /usr/local/lib/libltdl.7.dylib

iPhone で撮った本の裏表紙↓を読んでみる。

barcode.jpg

zbarimg barcode.jpg
EAN-13:1920290007000
EAN-13:9784004314097
scanned 2 barcode symbols from 1 images in 3.5 seconds

おおー。

JPEG だけならこれでいいんだけど TIFF を読む必要があったためため imagemagick を --with-libtiff つきでビルドしなおした。

brew uninstall imagemagick
brew install imagemagick --with-libtiff

ちなみに zbar にはカメラから読み取る zbarcam コマンド、各言語用のバインディングもある。

また Windows 向けのバイナリはインストーラ付きで依存ライブラリも同梱してて、いたれりつくせり。TIFF 読めなかったけど。

20
16
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
20
16