Import Upstream version 0.23.92

This commit is contained in:
rtlhq 2022-11-30 19:31:45 +08:00
commit 1e5cfd95a3
424 changed files with 81909 additions and 0 deletions

239
.github/workflows/ci.yml vendored Normal file
View File

@ -0,0 +1,239 @@
name: CI
# Should run only on branches and PR, as "on_tag.yml" will handle tags
on:
push:
branches: master
pull_request:
branches: master
jobs:
#
# Linux
#
Ubuntu:
name: Ubuntu debuild
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: prepare
run: |
sudo apt-get update
sudo apt-get install -y autoconf automake autopoint autotools-dev \
gettext libdbus-1-dev pkg-config xmlto \
devscripts build-essential lintian \
debhelper-compat \
dh-exec libdbus-1-dev \
libmagick++-dev libv4l-dev python3-dev \
libgtk-3-dev lftp \
dh-sequence-python3 libgtk2.0-dev \
libqt5x11extras5-dev qtbase5-dev
- name: build
run: |
.github/workflows/debuilder.sh
Ubuntu_Gtk2:
name: Ubuntu with Gtk2
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: prepare
run: |
sudo apt update
sudo apt-get install -y autoconf automake autopoint autotools-dev \
gettext libdbus-1-dev libgtk2.0-dev libmagick++-dev \
libqt5x11extras5-dev libv4l-dev libx11-dev openjdk-8-jdk-headless \
perl pkg-config python-all-dev python-all-dbg python-gtk2-dev \
qt5-default xmlto
- name: configure
run: |
autoreconf -vfi
export QT_SELECT=5
./configure
- name: build
run:
make
- name: check
run:
make check-local
- name: install
run:
sudo make install
Ubuntu_Gtk3:
name: Ubuntu with Gtk3
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: prepare
run: |
sudo apt update
sudo apt-get install -y autoconf automake autopoint autotools-dev \
gettext libdbus-1-dev gir1.2-gtk-3.0 libgtk-3-dev \
libgirepository1.0-dev libmagick++-dev libqt5x11extras5-dev \
libv4l-dev libx11-dev openjdk-8-jdk-headless perl \
pkg-config python3-minimal python3-dev python3 python3-gi \
qt5-default xmlto
- name: configure
run: |
autoreconf -vfi
# Let configure get this
unset PYTHON_CFLAGS PYTHON
export QT_SELECT=5
./configure --with-gtk=gtk3 --with-python=python3
- name: build
run:
make
- name: check
run:
make check-local
- name: install
run:
sudo make install
Mingw_w64_VfW:
name: Mingw-w64 VfW
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: prepare
run: |
sudo apt update
sudo apt-get install -y autoconf automake autopoint autotools-dev \
gettext libdbus-1-dev pkg-config win-iconv-mingw-w64-dev \
binutils-mingw-w64-i686 gcc-mingw-w64 mingw-w64-i686-dev \
mingw-w64-common xmlto
- name: configure
run: |
export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig
autoreconf -vfi
CC=i686-w64-mingw32-gcc ./configure \
--host=i686-w64-mingw32 --prefix=/usr/local/win32 \
--without-gtk --without-python --without-qt --without-java \
--without-imagemagick --enable-pthread
- name: build
run:
make
- name: install
run:
sudo make install
Mingw_w64_DShow:
name: Mingw-w64 DShow
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: prepare
run: |
sudo apt update
sudo apt-get install -y autoconf automake autopoint autotools-dev \
gettext libdbus-1-dev pkg-config win-iconv-mingw-w64-dev \
binutils-mingw-w64-i686 gcc-mingw-w64 mingw-w64-i686-dev \
mingw-w64-common xmlto
- name: configure
run: |
export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig
autoreconf -vfi
CC=i686-w64-mingw32-gcc ./configure \
--host=i686-w64-mingw32 --prefix=/usr/local/win32 \
--without-gtk --without-python --without-qt --without-java \
--without-imagemagick --enable-pthread \
--with-directshow
- name: build
run:
make
- name: install
run:
sudo make install
#
# Mac OS
#
Mac_OS:
name: Mac OS
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: prepare
run: |
brew install gettext autoconf automake libiconv libtool \
gs graphicsmagick python xmlto pkg-config ccache
brew unlink libtool && brew link libtool
brew unlink gettext && brew link gettext
- name: configure
run:
autoreconf -vfi
./configure --disable-video --disable-nls --with-python=python3
- name: build
run: |
make
sudo make install
#
# Windows
#
Windows:
name: Windows
runs-on: windows-latest
strategy:
matrix:
arch: [x86_64, i686]
video: [VfW, DShow]
include:
- arch: x86_64
msystem: MINGW64
grep: x86-64
- arch: i686
msystem: MINGW32
grep: 386
- video: DShow
extra: --with-directshow
- video: VfW
extra:
defaults:
run:
shell: msys2 {0}
env:
CPPFLAGS: -D__USE_MINGW_ANSI_STDIO=1
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: false
install: >-
mingw-w64-${{ matrix.arch }}-gcc
mingw-w64-${{ matrix.arch }}-iconv
mingw-w64-${{ matrix.arch }}-imagemagick
mingw-w64-${{ matrix.arch }}-python
base-devel git xmlto
autoconf libtool automake gettext make autoconf-archive pkg-config
- uses: actions/checkout@v2
- name: configure
shell: msys2 {0}
run: |
autoreconf -vfi
./configure LDFLAGS="-static" \
--enable-pthread --disable-dependency-tracking \
${{ matrix.extra }}
- name: build
shell: msys2 {0}
run:
make
- name: install
shell: msys2 {0}
run:
make install

62
.github/workflows/debuilder.sh vendored Executable file
View File

@ -0,0 +1,62 @@
#!/bin/bash
set -e
# A debian ruleset file which runs on Github's distro
DEB_FNAME="zbar_0.23.90-*.debian.tar.xz"
DEB_URL="http://deb.debian.org/debian/pool/main/z/zbar/"
# Should be the same version as provided by the host OS
COMPAT=12
# Set directories used during the build
ZBARDIR=${PWD}
BUILDDIR=${ZBARDIR}/../build
echo "Generating an origin tarball"
cd ${ZBARDIR}
VER=$(cat ${ZBARDIR}/configure.ac|grep AC_INIT|perl -ne 'print $1 if /(\d+[.\d]+)/')
TAR=${ZBARDIR}/../zbar_${VER}.orig.tar.gz
git archive --format tgz -o ${TAR} HEAD
echo "Retrieving Debian ruleset"
lftp -e "mget -c ${DEB_FNAME}; exit" ${DEB_URL}
# Ensure to use just one version, in case multiple ones were downloaded
DEB_FNAME=$(ls -1 ${DEB_FNAME}|tail -1)
echo "Preparing build environment"
rm -rf ${BUILDDIR}/ | true
mkdir -p ${BUILDDIR}
cd ${BUILDDIR}
tar xf ${TAR}
tar xf ${ZBARDIR}/${DEB_FNAME}
# Ensure that debhelper-compat will use the one expected by the build distro
sed -E "s#debhelper-compat.*,#debhelper-compat (= $COMPAT),#" -i debian/control
# Ignore missing SONAME for libs, if any, as it is not a build robot's task
# to update ${DEB_FNAME} ruleset
echo -e "\noverride_dh_shlibdeps:" >> debian/rules
echo -e "\tdh_shlibdeps --dpkg-shlibdeps-params=--ignore-missing-info" >> debian/rules
# We want it to build cleanly - so drop all patches from it
rm -rf debian/patches
# Override the changelog to ensure that it will contain the current version
cat << EOF > debian/changelog
zbar (${VER}) unstable; urgency=medium
* Upstream version
-- LinuxTV bot <linuxtv-commits@linuxtv.org> $(date -R)
EOF
OS_VERSION=$(. /etc/os-release && echo $ID-$VERSION_ID)
echo "Building ZBar packages for ${OS_VERSION}"
debuild -us -uc

40
.github/workflows/gen_release.pl vendored Executable file
View File

@ -0,0 +1,40 @@
#!/usr/bin/perl
my $body_path = shift or die "Need a file name to store the release body";
my $ver;
open IN, "configure.ac" or die;
while (<IN>) {
if (m/^[^\#]*AC_INIT\s*\(\s*\[\s*zbar\s*\]\s*,\s*\[(\d+[\.\d]+)/) {
$ver=$1;
last;
}
}
close IN or die;
die if (!$ver);
sub gen_version() {
print "Generating release for version $ver\n";
open IN, "ChangeLog" or return "error opening ChangeLog";
open OUT, ">$body_path" or return "error creating $body_path";
my $start=1;
while (<IN>) {
if ($start) {
print OUT $_;
$start = 0;
next;
}
last if (m/^\S/);
print OUT $_ or return "error writing to $body_path";
}
close OUT or return "error closing $body_path";
return "";
}
my $ret = gen_version();
die($ret) if ($ret ne "");

149
.github/workflows/on_release.yml vendored Normal file
View File

@ -0,0 +1,149 @@
name: Upload binaries to release
on:
release:
types:
- created
- published
- edited
jobs:
Ubuntu:
name: Build for Ubuntu 20.04
runs-on: ubuntu-20.04
steps:
- uses: actions/checkout@v2
- name: prepare
run: |
sudo apt-get update
sudo apt-get install -y autoconf automake autopoint autotools-dev \
gettext libdbus-1-dev pkg-config xmlto \
devscripts build-essential lintian \
debhelper-compat \
dh-exec libdbus-1-dev \
libmagick++-dev libv4l-dev python3-dev \
libgtk-3-dev lftp \
dh-sequence-python3 libgtk2.0-dev \
libqt5x11extras5-dev qtbase5-dev
- name: build
run: |
.github/workflows/debuilder.sh
- name: generating tarball
run: |
OS_VERSION=$(. /etc/os-release && echo $ID-$VERSION_ID)
tar cvfz ${DIR}/zbar-${OS_VERSION}.tar.gz *.deb
echo "OS_VERSION=$OS_VERSION" >> $GITHUB_ENV
- name: upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./zbar-${OS_VERSION}.tar.gz
asset_name: zbar-${OS_VERSION}.tar.gz
asset_content_type: application/gzip
Mac_OS:
name: Build for Mac OS
runs-on: macos-latest
steps:
- uses: actions/checkout@v2
- name: prepare
run: |
brew install gettext autoconf automake libiconv libtool \
gs graphicsmagick python xmlto pkg-config ccache
brew unlink libtool && brew link libtool
brew unlink gettext && brew link gettext
- name: configure
run:
autoreconf -vfi
./configure --disable-video --disable-nls --with-python=python3
- name: build
run: |
make
DESTDIR=${PWD}/macos make install
- name: generating tarball
run: |
DIR="$PWD"
tar c -C ${PWD}/macos -f ${DIR}/zbar-macos.tar.gz -z .
- name: upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./zbar-macos.tar.gz
asset_name: zbar-macos.tar.gz
asset_content_type: application/gzip
Windows:
name: Build for Windows
runs-on: windows-latest
strategy:
matrix:
arch: [x86_64, i686]
video: [VfW, DShow]
include:
- arch: x86_64
msystem: MINGW64
grep: x86-64
- arch: i686
msystem: MINGW32
grep: 386
- video: DShow
extra: --with-directshow
- video: VfW
extra:
defaults:
run:
shell: msys2 {0}
env:
CPPFLAGS: -D__USE_MINGW_ANSI_STDIO=1
steps:
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: false
install: >-
mingw-w64-${{ matrix.arch }}-gcc
mingw-w64-${{ matrix.arch }}-iconv
mingw-w64-${{ matrix.arch }}-imagemagick
mingw-w64-${{ matrix.arch }}-python
base-devel git xmlto zip
autoconf libtool automake gettext make autoconf-archive pkg-config
- uses: actions/checkout@v2
- name: configure
shell: msys2 {0}
run: |
autoreconf -vfi
./configure LDFLAGS="-static" \
--enable-pthread --disable-dependency-tracking \
${{ matrix.extra }}
- name: build
shell: msys2 {0}
run:
make
- name: generating zip
shell: msys2 {0}
run: |
DESTDIR=${PWD}/win_${{ matrix.arch }}-${{ matrix.video }} make install
(cd ${PWD}/win_${{ matrix.arch }}-${{ matrix.video }}; zip -r ../zbar-win_${{ matrix.arch }}-${{ matrix.video }}.zip .)
- name: upload
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
uses: actions/upload-release-asset@v1
with:
upload_url: ${{ github.event.release.upload_url }}
asset_path: ./zbar-win_${{ matrix.arch }}-${{ matrix.video }}.zip
asset_name: zbar-win_${{ matrix.arch }}-${{ matrix.video }}.zip
asset_content_type: application/gzip

31
.github/workflows/on_tag.yml vendored Normal file
View File

@ -0,0 +1,31 @@
name: Create release on tag
on:
workflow_dispatch:
push:
# Sequence of patterns matched against refs/tags
tags:
- '[0-9]+*'
jobs:
release:
name: Create Release
runs-on: ubuntu-latest
outputs:
upload_url: ${{ steps.create_release.outputs.upload_url }}
steps:
- uses: actions/checkout@v2
- name: Release changelog
run: .github/workflows/gen_release.pl body_file.tmp
- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ github.ref }}
release_name: Release ${{ github.ref }}
body_path: body_file.tmp
draft: false
prerelease: true

64
.github/workflows/update_release.yml vendored Normal file
View File

@ -0,0 +1,64 @@
name: Trigger upload binaries
on:
workflow_dispatch:
jobs:
Windows:
name: Build for Windows
runs-on: windows-latest
strategy:
matrix:
arch: [x86_64]
video: [DShow]
include:
- arch: x86_64
msystem: MINGW64
grep: x86-64
- video: DShow
extra: --with-directshow
defaults:
run:
shell: msys2 {0}
env:
CPPFLAGS: -D__USE_MINGW_ANSI_STDIO=1
steps:
- name: install cli
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
choco install gh
gh release list
- uses: msys2/setup-msys2@v2
with:
msystem: ${{ matrix.msystem }}
update: false
install: >-
mingw-w64-${{ matrix.arch }}-gcc
mingw-w64-${{ matrix.arch }}-iconv
mingw-w64-${{ matrix.arch }}-imagemagick
mingw-w64-${{ matrix.arch }}-python
base-devel git xmlto zip
autoconf libtool automake gettext make autoconf-archive pkg-config
- uses: actions/checkout@v2
- name: configure
shell: msys2 {0}
run: |
autoreconf -vfi
./configure --enable-pthread --disable-dependency-tracking ${{ matrix.extra }}
- name: build
shell: msys2 {0}
run:
make
- name: generating zip
shell: msys2 {0}
run: |
DESTDIR=${PWD}/win_${{ matrix.arch }}-${{ matrix.video }} make install
(cd ${PWD}/win_${{ matrix.arch }}-${{ matrix.video }}; zip -r ../zbar-win_${{ matrix.arch }}-${{ matrix.video }}.zip .)

72
.gitignore vendored Normal file
View File

@ -0,0 +1,72 @@
*.la
*.lo
*.o
*~
.deps/
.dirstamp
.libs/
ABOUT-NLS
aclocal.m4
autom4te.cache/
config/
config.log
config.status
configure
doc/doxygen.conf
doc/man/
doc/reldate.xml
doc/version.xml
gtk/zbarmarshal.c
gtk/zbarmarshal.h
gtk/ZBar-1.0.gir
gtk/ZBar-1.0.typelib
include/config.h
include/config.h.in
include/stamp-h1
iphone/build
iphone/zbar.xcodeproj/project.xcworkspace
iphone/zbar.xcodeproj/xcuserdata
java/net/sourceforge/zbar/*.class
java/zbar.jar
java/zbarjni.h
libtool
Makefile
Makefile.in
po/*.gmo
po/*.mo
po/Makefile.in.in
po/Makevars.template
po/POTFILES
po/Rules-quot
po/boldquot.sed
po/en@boldquot.header
po/en@quot.header
po/insert-header.sin
po/quot.sed
po/remove-potcdate.sed
po/remove-potcdate.sin
po/stamp-po
po/zbar.pot
pygtk/zbarpygtk.c
pygtk/zbarpygtk.defs
qt/moc_*.cpp
test/check_dbus.sh
test/test_examples.sh
test/test_convert
test/test_cpp
test/test_cpp_img
test/test_dbus
test/test_decode
test/test_jpeg
test/test_proc
test/test_video
zbarcam/moc_*.h
zbarcam/zbarcam
zbarcam/zbarcam-gtk
zbarcam/zbarcam-qt
zbarimg/zbarimg
zbar*.pc
zbar-*.tar.bz2
zbar-*.tar.gz

36
.hgignore Normal file
View File

@ -0,0 +1,36 @@
syntax: glob
*~
Makefile
Makefile.in
aclocal.m4
configure
config
config.guess
config/config.h
config.h.in
config.log
config.status
config.sub
depcomp
compile
install-sh
libtool
ltmain.sh
autom4te.cache
missing
python/MANIFEST
build
*.xcodeproj/*.mode1v3
*.xcodeproj/*.pbxuser
xcuserdata
contents.xcworkspacedata
.DS_Store
android/obj
*.class
*.dex
android/libs
android/examples/*/libs
android/*.zip
android/local.properties
android/examples/*/local.properties

29
.hgtags Normal file
View File

@ -0,0 +1,29 @@
20d75a548cf6daee2e590683ee2166d6af24e94f 0.5
590b1d022f92b67f1bcd52b3c2810682285a5f6b 0.7
6cdb3f2ec455b6abb747adfe236c619c6c0ee1ef 0.2
c6178a9dde5527c0ff59e8e7e3e04f9057e0c3a2 0.3
c7ff4e3a6f6d8e9ccdebece0ff276db5cecf34fd 0.6
f68c5b088507f424840f8efa4077aac37c5390cd 0.4
fe6f4843de209522918690dc741fd7fff442ef6d 0.1
f0aa6bf0cab7fda8725ce0da35d3e69473269c71 0.8
38265c7b4ad4dfafe7b5e9eae4bb0d43d68b4143 0.9
2dc2d73c468a032edc68a127e9ddbbfe5f520777 0.9
f3670ba47f2e070f4c43e97f4de3200903720e73 0.10
f3670ba47f2e070f4c43e97f4de3200903720e73 0.10
563557a923d0e23e36c81878d660aefc1c0fe3e7 0.10
b21098d27ff88c4f1a529fe0762f1cb307e04399 iPhoneSDK-0.1
b0bda6247b2fe4ffb52db89a776f91244f25d897 iPhoneSDK-0.1.1
d1655a680c3df68b3466d3b2c714f30af7223ec6 iPhoneSDK-0.1.2
4556c996acaaa6fcd5e8e9879f410f8120746e2b iPhoneSDK-1.0
12de07e51dce0d1cfc3e9699bbf9d5c8774a5371 iPhoneSDK-1.0.1
12de07e51dce0d1cfc3e9699bbf9d5c8774a5371 iPhoneSDK-1.0.1
2541a66ae7d64fbd923168ae677abb156021e88d iPhoneSDK-1.0.1
5e5060b563a1878ea297af5a50261d14cf1cb449 iPhoneSDK-1.1
f9e46865dbcebd04683ca7592ab32aeda615e772 iPhoneSDK-1.1.1
801318a6195060c31259da1f076ecc9a609616cc iPhoneSDK-1.1.2
4bbb4e2bdba8c41a282df7e65a02797250f44daa iPhoneSDK-1.1.3
1ad84c3c03252c366a82552fa952674ec593c73f iPhoneSDK-1.2
9e7bad13ae6a4b65e0f0964512f96284d37f0dc8 iPhoneSDK-1.2.1
146b857ff41ae462cc52f8dddf46d867763433a1 iPhoneSDK-1.2.2
9b946a7ead73ac99e121de2e7f495213cda88e6f AndroidSDK-0.1
5eb3c8786845fe3ad2c74f6a660e70176b88347f iPhoneSDK-1.3.1

27
COPYING Normal file
View File

@ -0,0 +1,27 @@
The ZBar Bar Code Reader is Copyright (C) 2007-2011 Jeff Brown
<spadix@users.sourceforge.net>
The QR Code reader is Copyright (C) 1999-2009 Timothy B. Terriberry
<tterribe@xiph.org>
You can redistribute this library and/or modify it under the terms of the GNU
Lesser General Public License as published by the Free Software Foundation;
either version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE.
See the GNU Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public License along
with this library; if not, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
ISAAC is based on the public domain implementation by Robert J. Jenkins Jr.,
and is itself public domain.
Portions of the bit stream reader are copyright (C) The Xiph.Org Foundation
1994-2008, and are licensed under a BSD-style license.
The Reed-Solomon decoder is derived from an implementation (C) 1991-1995 Henry
Minsky (hqm@ua.com, hqm@ai.mit.edu), and is licensed under the LGPL with
permission.

758
ChangeLog Normal file
View File

@ -0,0 +1,758 @@
0.23.92:
* Added a --enable-static option to make easier to distribute
Windows binaries
0.23.90:
* Started using github actions for CI and binary releases
* Fixed several issues with configure.ac, making it auto-detect
most things, when possible
* README.md now shows the absolute minimum requirement for
building ZBar on Ubuntu
* Fixed some build issues
* Make it compatible with Python 3.9
* Fixed some Python 3.9 and Qt5 warnings
* Typo fixes
* Several fixes at zbarcam
* zbarimg: fix stderr output when symbols are found
0.23.1:
* Add i18n translation support and add a pt_BR translation
* Change default to autodetect python and gtk versions
* Improve tests and builds on travisCI
* Some documentation updates
* Add support for binary data extraction
* Add support for raw decoding without charset conversions
* Add one shot scanning mode
* Improved OSX and iphone support
* Fix help messages
* Fix some makefile issues
* Fix error detection in video4linux read
* Fix pkgconfig for zbar-qt5
* Fix a double-free condition
0.23:
* Windows: added support for DirectShow
* Text files at main dir converted to Markdown notation
* HACKING.md text now reflects the procedures we use since 0.20
* ZBar's URL locations updated on several places
* Added support for using Gtk3 with zbarcam-gtk
* Added support for using GObject Integration (GIR) with pygobject-3.0
* Added support for Python3 bindings
* Python scripts now runs with either python2 or python3
* added Travis checks for Gtk3 with Python3 and GIR
* added Travis builds for cross-compilation with winGW
* added Travis builds for Windows native build
* added a test script for checking python bindings
* Added a test script for Python with Gtk support via GIR
* Suppressed gcc warnings when building with Gtk3
* Got rid of gdk_threads for good at zbarcam-gtk, using an idle hook to
handle async messages
* The debian/ and travis/ directories were removed from distribution files
* Java sources added to the distribution tarball
0.22.2:
* Improve some pkg check logic, in order to solve some
./configure issues
* Fix logic that allows disabling Qt support
* Add support for Java 11 detection
* Fix Java detection logic
* Fix Travis CI breakages due to the usage of Java 11 on Debian Sid
* Fix some issues with MinGW Windows build
* Search for new ImageMagick 7 header location
0.22.1:
* Ensure that version.xml and reldate.xml will be placed at the source dir
* Make use of glib thread names
* Windows: Make zbargtk build
* Windows: Use -no-undefined for libzbargtk
* Windows: Disable zbarcam-gtk
* Windows: Check for clock_gettime on pthread library as well
* Windows: Specify correct path to barcode.png
* Windows: Include windows.h for vfw
* Makefile.am: Add missing extra-dist-file
* configure.ac: allow building libzbar-qt as a static library
0.22:
* zbarcam-qt: allow changing resolutions in real time
* zbarcam-qt: better support ZBar options
* zbarcam-qt: do several visual improvements
* zbarcam-qt: make it remember the geometry
* zbarcam-qt: allow show/hide control and options bars
* zbarcam-qt: remember lastly used settings and camera controls
* zbarcam-qt: allow changing ZBar decode options via GUI
* Add API to allow get/set resolutions
* img_scanner: add handler for color-inverted codes
* img_scanner: fix get_config parameter validation
* scan_video: improve logic to remove duplicated/invalid devnodes
* symbol.c: fix symbol hash logic (prevents crash with QR options)
* configure.ac: fix an error at libv4l2 package check
* fix some typos
* exit gracefully when decoding split QR codes
0.21:
* zbarcam-qt: allow selecting codes via GUI interface
* When both enabled, ISBN-13 has precedence over ISBN-10
* ZBar is now using Travis CI for continuous integration tests
* Convert INSTALL and README to markdown and update them
* Improve ZBar testing code and make easier to run the tests
* Fix build with Clang
* Add simple dbus IPC API to zbarcam.
* zbarimg: display only the compiled symbologies
* v4l2: make ZBar build and run on Kernels < 3.16
* configure.ac: The pdf417 code is incomplete. Warn about that
* Add Debian packaging and Travis CI configuration
* Add barcode examples for different supported symbologies
* Several improvements at the building system
* Add support for SQ code symbology
* v4l2: add fallback for systems without v4l2_ext_controls which field
* v4l2: use device_caps instead of capabilities
* v4l2: make v4l2_request_buffers() more generic
* release video buffers after probing and request them again when needed
* Ignore ENOTTY errors when calling VIDIOC_S_CROP
* doc/Makefile.am.inc: clean html generated files
* Add --disable-doc configure option to disable building docs
* Fix function prototype to be compatible with recent libjpeg
* Wrap logical not operations into parentheses
* INSTALL: warn that autoconf should be called before configure
* code128: fix error logic
* convert: ensure that it will not use a freed value
* zbar: use g_thread_new() instead of g_tread_create()
* zbargtk: add a missing break
* gtk/zbargtk: add a missing check if zbar->window is not null
0.20.1:
* Be sure to use python2, as /usr/bin/python is being removed
(or made non-functional) on some distributions
* Prefer using pygobject-codegen-2.0 instead of pygtk-codegen-2.0
* Make it work with modern versions of python 2
0.20:
* As upstream became abandoned, created a ZBar fork at linuxtv.org
* Use libv4l2 for V4L2 support, using emulated formats as last resort
* Add support for Qt5
* Add zbarcam-qt and zbarcam-gtk (from the example codes)
* Add support for v4l2 controls
* Add the needed GUI bits for zbarcam-qt to work with controls
* Fix compilation issues with newer automake versions
0.11:
* Codabar reliability enhancements
- fix missing check
- require minimum quality
- bump default uncertainty
* tweak Codabar bar/space ratio validation
* finish Codabar support for python, perl, java and iPhone interfaces
- reduce Codabar uncertainty to minimum
* add core support for Codabar symbology
- TBD: python, perl, java and iPhone interfaces
* fix v4l config and build variations (bug #3348888)
- thanks to jarekczek for reporting this!
- NB v4l1 removed from kernel as of 2.6.38
* fix missing python thread initialization (bug #3349199)
- thanks to jarekczek for reporting this problem!
* fix missing configure check for Python.h (bug #3092663)
- thanks to Zoltan Kovacs for reporting this problem!
* fix C++ wrapper missing Symbol.quality (bug #3076524)
- thanks to Rudy Melli for pointing this out!
* fix C++ wrapper bugs (bug #3396068)
- thanks to anotheruser1 for reporting this!
- add new C++ wrapper test
* fix avoid compositing ISBN10 data
* add support for GraphicsMagick as ImageMagick alternative
* mention xmlto in HACKING (patch #3297039)
- thanks to jarekczek for the patch!
* disable addons by default until synchronization with main symbol is working
* fix image scanner min quality filtering
* fix i25 buffer overrun corner case
* fix EAN addon enables
* fix zbarimg to accept autodetected stdin (lone dash)
* fix Qt 4.6.3 compilation error (patch #3178244)
- thanks to hrhristov for the patch!
* add Python Processor support for request_size interface
* fix Python Processor support for GIL, allowing asynchronous scanning
* fix jpeg decoder skip handling
- thanks to jarekczek for the patch!
* rename dprintf macro to avoid conflicts (patch #3128538)
- thanks to maurochehab for the patch!
* add support for EAN/UPC 2 and 5 digit add-on symbols
- deprecate original, unfinished add-on APIs
- add self-checking to test_decode
* fix support for GS1 AIs
- thanks to jockusch for a patch!
- add decoder/symbol "modifier" flags and config read access
- set flags or emit GS appropriately for Code 128 FNC1
- add iphone, java, perl, python bindings for modifiers and configs
* add support for Code 93 symbology
* add video size request to (Py)GTK widget (req #3034522)
- thanks to Jerome Charaoui for the patch!
* add support for GS1 DataBar Expanded (RSS Expanded) symbology
* add language bindings for DataBar
* add preliminary support for GS1 DataBar (RSS-14) symbology
* enhance decoder reliability (EAN, Code 39, Code 128)
- enhance decoder test
* fix documentation of command exit codes (bug #3017322)
* fix C++ video callback bug
- add C and C++ processor examples
* add per-symbology cache consistency
- reliable symbologies decode immediately by default
- no more need to disable cache with video
- also fix crop bugs w/video scanning
* add support for scanning partial images (cropping)
- update c++, python, perl, java bindings and tests
* fix couple of leaks
* remove doc hints about GFDL (bug #3004411)
- apply LGPL to API docs
* relax Code 39 width ratio checks
* core library portability improvements
- remove some unnecessary C99 syntax
- add configure checks for errno
- enhance C++ Symbol interface
* adjust Python module README (add examples and note DLL in path)
* fix QR Code missing from man pages (bug #2969857)
* cleanup decoder assertions and locking (bug #2966916)
* add Java interface to library via JNI
- add Java tools and JNI build tests to configure
- fix compiler warnings from binary output changes
* fix output of binary data in zbarimg and zbarcam
- thanks to fukuchi for a patch!
- add base64 format for binary xml output
* add coarse symbol orientation information (patch #2913094)
- thanks to Anssi for a patch!
- add decode direction feedback to decoder
- update C++, Python, Perl and ObjC wrappers
- add orientation to test suites
* fix inconsistent fourcc endian handling bugs (bug #2918994)
- thanks to jdccdevel for a patch!
- add fourcc conversion and parse interfaces to zbar.h
* report QR immediately for video (no inter-frame consistency check)
* add python distutils build infrastructure
version 0.10:
* hotfix add MinGW import lib to Windows installer
* attempt fix for Qt4 < 4.4
* release updates
- fix perl Processor init without video
* fix window closed notification during events
- add read_one example, fix xs compiler warnings, update perl docs
* add result query interfaces to image scanner and processor
- move result filtering into image scanner (from user)
- abort output blockers when window closed
* Windows updates
- update installer and README for distribution of dependency libraries
- fix applications to use binary output for xml and raw modes
* add regression tests to makefile
* cleanup warnings from newer gcc versions
* fix excessive i25 QZ checks
* add regression script
- add zbarimg xml output for every source (even empty)
- add edge detection to svg debug overlay
* image scanner cleanup and minor performance enhancements
* bug hunt and stability improvements
- fix broken processor locks
- fix X connection polling, revert previous separate thread workaround
- refuse to resize windows larger than screen size
- fix window output scaling - preserve image aspect ratio, adjust overlay
- fix window redraw
- fix crash on Xv image creation failure (still need XImage fallback)
- clean up zbarimg exit cases (last image window close, missing decodes)
* always use separate video thread when threads enabled (even v4l2)
* add configure check for features.h
* overlay enhancements
- add fps to overlay
- add overlay control to processor
- add windows overlay drawing
* tweak linear code position info
* trim deep qrcode hierarchy
* fix zero length symbol data
* fix QR structured append result handling
* cleanup SVG debug dump (partial)
- some QR integration API cleanup
* extract explicit result container, separate from image
- remove (broken/tmp) converted image result sharing
- add explicit symbol recycle API, update processor/widgets to use
- cleanup and update C++ API
- update Python/Perl APIs
- fix broken and add new Python/Perl tests
* cleanup QR result integration
- add hierarchy to symbol results
- extract symbols during text decode, preserving position and structure
- outline QR symbols in window overlay
- tmp fix converted image result propagation
* factor image scanner cache and apply to QR
- fix image scanner handler called once per-image (vs every decode)
* QZ and clustering fixes to QR integration
- remove qr_finder QZ checks
- decrease center clustering threshold from 1/3 to 1/5 of length
- add img_scanner svg debug output
- manually add config.rpath to workaround broken autofoo
* finish initial integration of QR Code reader from maemo-barcode project
* zbar-side updates for QR Code integration
- add linear scanner position interface
- add QR finder position feedback
- integrate QR Code reader with img_scanner
- refactor some symbol/image interaction
- change default scanner density to 1
- add iconv to build infrastructure
* initial hooks for QR Code, first pass at finder
* fix broken builds with --disable-pthread
version 0.9:
* hotfix configure check for Wand as well as MagickWand (bug #2848437)
* hotfix trim extraneous MagickWand calls (bug #2848445)
* release updates
* fix uninitialized member in Qt widget (bug #2844846)
* move image conversion out of image scanner up to higher levels
(preparation for library split)
* add symbol quality metric and image scanner position config
- update python, perl and docs
* compatibility fixes
- work around ImageMagick API breakages
- fix some OS X compile issues
* Qt widget cleanup
- handle video device set before window attached
- prevent exceptions from escaping event handlers
* more Qt window creation hook fixes
- NB may still cause problems if video is opened before window is visible
* finish fix for Qt init ordering (bug #2844846)
* potential fix for display init ordering (bug #2844846)
- new workaround for filtering bad EAN results in the image scanner
* more testing, fixes and cleanup
- fix v4l1
- fix/add null processor interface
* change default image scanner density to 1x1
- random cleanup, vfw hang, quit key
- fix scan_image example MSVC project
- windows installer tweaks
* add zbarcam to windows installer
* major restructuring to improve platform abstraction
- add lock, thread and timer abstractions
- migrate specific notification locks to platform independent layer
- fixes to vfw capture interface
- fix window format conversion issues
- fix some broken configure checks
- zbarcam working in windows!
* fix symbol leaks (bug #2820658)
- add symbol reference counting
* add support for binary symbol data
* initial VFW video support
- mostly working with uvc driver, broken for others
- factor out common video buffer handling
- fix processor to destroy window *before* video (ref TODO)
- use /dev/video* VFW pseudo-devices
- windows configure skip non-windows checks
- prep for platform refactoring
* fix zbarimg b&w format handling
* fix scan (image) boundary QZ handling (bug #2807538)
- add linear scanner manual flush API
- linear scanner always starts/ends w/a space of width 0
- remove artificial image scanner border
- decoders special case 0 width space for QZ checks
- add missing Code 128 leading QZ check
* fix Code39 max ICS checks (bug #2807447)
- add decoder lock owner tracking (debug)
- update dbg_scan to match img_scanner
* first pass installer
- add version and icon resources for libzbar, zbarimg
* zbarimg working in windows
- switch to StretchDIBits over DrawDib
- refactor some window drawing code to remove redundancies
- make refcounts thread safe
- clean up alloc/free bugs
* convert zbarimg to C (cross compiled C++ cannot run w/native libraries)
- fix DrawDib image width granularity
- fix window resize dimensions to include decorations
- images still inverted, otherwise zbarimg now "working" in windows
* refactor processor implementation to support cross-platform
- first pass windows processor (before debugging)
- make processor locks reentrant (call APIs from callback)
* initial Windows support for window interface
- currently supports VFW DrawDib interface for image display
(DirectDraw and others TBD)
- also basic processor window creation/manipulation
- Windows configure tests
version 0.8:
* release updates
* add "raw" output option (without symbology prefix) to apps (req #2671863)
* fix Code 39 min length and document min/max configs (bug #2787925)
* fix zbar_image_free_data windows recursion loop (bug #2796277)
* fix uninitialized decoder configs (bug #2800163)
* switchover from subversion to mercurial
version 0.7:
* fix perl MANIFEST
* release updates (version, NEWS, packaging)
* adjust [py]gtk distributed files
* draw new logo (rough, no Xrender yet)
* fix Makefile.am syntax error
* fixup some perl distribution details
* project name change: everything "zebra" becomes "zbar"
* remove old logo
* add first pass python bindings!
* fix perl mortality bug
* add new cfg constants to perl
* fix perl doc handler ref
* fix processor set_active error propagation
* add wiki examples (scan_image.*, processor.*)
* add missing trailing quiet zone checks for ean and code39
* add min/max code length cfg/check for i25,code128,code39,pdf417
* add image scan density API/option
* tweak option parser to be more strict/correct about abbreviations
* add API to force specific video io modes (req #2293955)
* apply patches for more broken driver workarounds (req #2293955)
* fix(?) C++ string to fourcc conversion
* add missing C++ wrappers
* add additional examples to man pages (symbology enable/disable)
* add missing options to man page synopsis
* add missing --xml option to man pages
version 0.6:
* hotfix broken perl install (name change)
* add missing files to distribution
* release updates (version, NEWS, pacakging)
* rename perl module to Barcode::Zebra (fit with existing cpan namespace)
* add perl documentation and example
* add v4l version debug/test override
* add docs for new zebracam prescale option
* add video pre-scaling API/option to video/processor/zebracam (req #2277340)
* add few missing APIs to perl xs wrapper
* fix missing libjpeg #ifdef in convert
* initial support for decoding jpeg images using libjpeg!
* workaround broken v4l2 drivers in USERPTR mode
* have configure double check Magick++ install (bug #2582232)
* update README dependency list
* fix C++ warnings in Processor
* fixes for building DLLs with libtool under MinGW
* automatically remove "processor" layer if poll.h is unavailable
* test_decode portability workarounds
* add config/compile time symbology enables
* add low-level PDF417 decode stage - converts widths to codewords
* add XML output option to zebracam and zebraimg
* add sequence number image attribute, set to frame number by video
* change v4l2 interlaced only drivers to warning instead of hard fail
* workaround broken drivers that return error for V4L2_FIELD_NONE request
* add some initial PDF417 hooks
* first pass perl bindings for Processor, Scanner and Decoder
* fix error propagation double free bug
* add missing APIs: processor userdata and image data length
* fix configure check for v4l2 - thanks to Simon Matter for the patch!
* finish support for UPC-E
* fix zebraimg to scan all pages/frames of a multi-frame input
* fix debian packaging dependencies (bug #2070164)
* *remove* debian directory from distribution (bug #2070164)
* fix inappropriately installed headers and man pages (bug #2055133)
* fix pygtk multiple definition link errors on darwin (bug #2052681)
* fixes to configure for detecting python settings (bug #2052663)
* remove zebrapygtk module link against libpython (bug #2052663)
* add drag and drop support for *images* to Qt widget...unfortunately not
very useful; every application i tried drops uri-refs rather than images
* minor reference documentation updates
version 0.5:
* release updates (version, NEWS, packaging)
* add pkg-config files
* update to latest libtool and new autoconf macros
* cleanup library symbol exports
* remove test programs using internal hooks
* improve portability of some format specifiers
* fix missing stub for --without-x - thanks to Simon Schmeisser for a patch!
* fix --disable-pthread compile errors and warnings
* fix XImage size mismatch background artifacts
* fix new generated file distribution errors
* switch Qt headers to old-style names (investigate possible Qt3 support?)
* add independent ABI versioning for GTK and Qt widget libraries
* reimplement widget internals to support image scanning and
improve locking efficiency
* add image scanning to widgets. including builtin conversions from
toolkit image types: GtkPixbuf and QImage
* add video opened hooks to widgets (improved use model)
* add logo, used when there is nothing better to draw
* add userdata to image object
* fix image reuse cleanup bug
* fix format specifiers in some error messages
* enhance widget tests to support enable/disable and scan from image
* fix broken deallocation assumptions in test_qt
* widget API documentation (still need to hookup gtkdoc, and PyGtk docs)
* API documentation toplevel overview
* update configure summary for new features
* replace all decoder assertions w/non-fatal debug spew (bug #1986478)
* fix glib-genmarshal check
* add first pass of Qt widget!
- test/example in test/test_qt.cpp
- factor video device scan to share among tests
* more C++ integration fixes
- additional Image ref tweaks
- add Video.close() and Window.clear() APIs
* fix missing image scanner handler call
* add dereference operator to C++ Symbol
* add count attribute to C++ Symbol
* fix broken C++ header definitions
* fix broken C++ Image references
* expose internal reference counting interface
* fix window locking bug
* cleanup some minor memory leaks
* convert Code 128 assertions to non-fatal warning spew
* fix single buffer video hang (bug #1984543)
* replace inferred video size assertion with warning message (bug #1984543)
* add first pass of GTK widget!
* add PyGTK widget wrapper
* API change: modify window draw/redraw interface to improve interoperability
with toolkits
- add window locking for thread safety
- zebra_window_draw() no longer actually "draws" anything
=> use window.draw to update the image from video thread
then schedule window.redraw from toolkit GUI thread
* fix missing C++ std lib dependencies
* fix uninitialized handler/userdata bug in decoder
* fix broken Code 128 checksum assertion
* fix video destructor segfault
* fix window destructor Xvideo errors (XID is unsigned...)
* switch configure to use pkg-config to find most dependencies
* API documentation updates
version 0.4:
* release updates (version, NEWS, packaging, examples)
* couple of portability tweaks
* finish format conversion resize cases
* add missing conversions
* fix some broken conversions
* fix some broken redraw and Xv checks
* add decoder configuration API
- only boolean configs currently implemented
- integrate config option parsing w/zebracam and zebraimg
- add config to enable/disable each symbology type
- add optional conversions from EAN-13 to UPC-A, ISBN-10 and ISBN-13
(disabled by default)
- add config to emit/suppress check digit
NB behavior change! check digit is now emitted by default
* related documentation updates
- split common options to a separate entity
* fallback to gettimeofday when POSIX timers are not available
* image format conversion fixes
- fix format size roundoff (NB now rounds *down*)
- add convert and resize API to pad/crop image to specific size
(eg, to handle Xv min/max image size)
NB this is still not implemented for many conversions
* fix window deletion visibility inconsistency
* add couple processor commands
- 'q' to delete window
- 'd' to dump displayed image for debug
* remove problematic includes used for v4l2 configure test
* address compiler portability concerns w/debug print vararg macro
* workaround v4l1_set_format() failed consistency check for broken drivers
- change from error to warning w/more useful message
- calc expected image size using expected value instead of driver value
* add missing example scripts to distribution
* add missing files for Interleaved 2 of 5
* add support for Interleaved 2 of 5 symbology!
- again no check digit option yet
* increase decode window from 8 to 16 bars
- remove Code 39 "extra bar" hack
- add Code 39 quiet zone check
- facilitate Interleaved 2 of 5
* optimize character width calculations for all symbologies
* fix image scanner bug w/lost symbols at end of scan passes
* fix EAN-8 buffer overrun case
* add API doc footer
* add API documentation generated by Doxygen
- markup, cleanup and finish writing header comments
- setup Doxygen config file
* add/fix window GC
* add base support for Code 39 (no check digit or full ASCII options yet)
* cleanup decoder locking
* add support for EAN-8!
version 0.3:
* add interface stub files
* fix wait timeouts
* fix XImage format filtering
* fix several error handling corner cases
* fix c++ error handling
* add missing Window.h
* add better hierarchy to library sources
* build configuration fixes
* portability fixes
* packaging updates
* fix zebracam beeps
* fix some RGB component ordering and XImage format problems
* fix window resize and redraw state problems
* fix EAN testcase in test_decode - thanks to Steffen Kube for the patch!
* add APIs and (hidden) zebracam options to force specific formats for debug
* add example scripts
* documentation updates
* remove implementation of deprecated img_walker
* add XImage formats
- basic support for 16-bit depths
* add some missing rgb format conversions
* add basic overlay
- currently only markers at detected scan locations (needs improved)
* fix memory leak for converted images w/new cleanup semantics
* migrate inter-frame consistency check from old zebracam into image_scanner
- add API to enable/disable/flush result cache
- add API to retrieve cache status from returned symbol
* cleanup user_wait blocking semantics for various state combinations
* fix bug w/v4l1 not unlinking dequeued image
* major restructuring for improved modularity
NB not all changes are are backward compatible!
- modular support for v4l2 falling back to v4l1
- flexible support for more varied image formats (incomplete)
- added reusable abstractions for: an "image" object and associated
metadata, a "video" input object and a "window" output object
- added new "processor" API to wrap everything together, simplifying
trivial application usage (including zebracam and zebraimg)
- removed deprecated "img_walker" interface, completely replaced by
more integrated "image_scanner" (moving toward more image processing)
- updated/added c++ APIs, including improved iterator interfaces
* removed SDL dependency due to various usage incompatibilities
(most notably the inability to embed video window into a widget)
* cleaned up zebracam and zebraimg command line processing (bug #1838535)
* many useful enhancements thanks to proposal by mhirsch45 (req #1759923)
including:
- v4l2 support
- support for UYVY image format
- zebracam cursor hiding
- zebracam audio mute
- command line video device specification,
* significant error handling and debug improvements
* some associated documentation updates
* various new test programs (slowly working toward more formal test suite)
* add missing xlink namespace to dbg_scan generated output (bug #1764188)
* qualify char types as [un]signed to avoid non-portable C ambiguity
- thanks to mhirsch45@users.sf.net and Colin Leroy for the patches!
(bug #1759914)
* add integrated 2D image scanning API
- automatically ties to internal scanner and decoder
- results reported via new symbol API
- deprecated previous, cumbersome img_walker interface
- uses new simpler/faster and denser grid pattern (FIXME add 45 and 135)
- first step toward more sophisticated image processing
* updated zebraimg to use new ImageScanner API
- add initial decode location tracking
* updated zebracam to use new img_scanner API
- extended cache to track multiple symbols per-image
- add initial decode location tracking
- removed scan grid overlay
* add configure check for ImageMagick version >= 6.3.0
* configure dumps ImageMagick, SDL and firefox versions for debug
* add NPAPI plugin stub and build infrastructure
* flush zebracam output after each scanned symbol
* integrate RPM packaging spec file - thanks to V<>t Hrachov<6F> for the draft!
(patch #1723536)
* finally add HACKING to distribution/install (bug #1698202)
* add extra documentation files to install (README NEWS INSTALL, etc)
* Debian package patch for 0.2 - thanks to V<>t Hrachov<6F>:
- add libsdl1.2-dev as a build dependency
- update automake (>= 1:1.10) as a build dependency
- new package
version 0.2:
* update distribution to include debian packaging
* add consistency checking to zebracam
* add redundant output suppression to zebraimg
* fix couple of Code 128 decode table bugs
* fix reversed Code 128 decode
* add outstanding scanner edge flush to new_scan()
- API change: scanner reset/new_scan() now return scan/decode status
- update zebracam and zebraimg to call this between each walker pass
(interface still needs improvement...)
=> improves in scan results for many cases
* fix dbg_scan filename generation so results go in local directory
* continue Code 128 refinement
- finish character set C decode/expansion
- add per-character validation
- resolve scan direction in separate postprocessing pass before handling
ASCII conversion
- add several img_walker passes parallel to major axis (for long symbols)
- add simple character set C example to test_decode
* promote zebraimg images to TrueColor so colored scan pattern always shows
* more dbg_scan tweaks
* significant scanner improvements
- changed "classic" [-1 0 1] first differential kernel to [-1 1]
to improve minimum edge resolution to single pixel elements
=> still need to do some more research and validate assumptions
- adaptive thresholding fixes
- adjusted filtering for better edge detection
- separate constants out to defines (FIXME add config API?)
* fix EAN-13 secondary determinant decoding
* dbg_scan tweaks to make annotations smaller/more usable
* add get_color() interface to decoder
* annotated zebraimg scan pattern for marginally useful high-level debug
* random include cleanup
* cleanup 64-bit compile warnings in zebraimg (bug #1712504)
* add first-pass partial support for Code 128
- separate out more EAN state from shared state
- internal interface changes
- finish dynamic buffer management
- add shared resource locking
- add Code 128 to test_decode program
=> still needs additional functionality and plenty of debug
=> reading both Code 128 *and* EAN still destabilized
* add diagnostic program test_video to dump more verbose video debug
* incorporate documentation into Debian package
- thanks to V<>t Hrachov<6F> for the patch!
* fix VPATH doc builds (requires automake-1.10 and autoconf-2.61)
* build and dist fixes
- suppress documentation rebuilds in distributed sources
* add Debian packaging sources - thanks to V<>t Hrachov<6F> for the patch!
* add DocBook template and build infrastructure
* add manpages for zebracam and zebraimg
* add GNU standard options to zebracam and zebraimg
* internal decoder restructuring to support additional symbologies
- separated out 1-D decoder infrastructure into generic internal API
- moved EAN/UPC specific decoding into it's own module
* fix confusing configure behavior which quietly avoided building
targets with missing dependencies(?!)
configure will now fail with a descriptive error message if you
do not have Magick++ and fail to specify --without-imagemagick or
do not have SDL and fail to specify --without-sdl
* add configure summary describing what will be built (req #1698196)
* fix parity encoding in test_decode and add decoded symbol output
* introduce Code 128 symbol type
* increase width of zebra_symbol_type_t to 16 bits
* add HACKING (bug #1698202)
version 0.1:
* add NEWS and ChangeLog
* fix some config/build issues found on other boxes
* add missing ImageWalker install
* fix scanner runaway threshold calculation bug
* fix zebracam/zebraimg bugs overwriting currently scanning image w/scan
pattern
* add c++ interface to img_walker
* apply ImageWalker to zebraimg
* add decoder soft reset on partial mismatch
* finish basic decoder symbol assembly/reporting
* add decoder symbol checksum verification
* add callback API option to decoder for "async" symbol processing
* add "image walker" library API to trace scan pattern over 2D images
* apply image walker to zebracam (C++/zebraimg scan pattern still TBD)
* add audio feedback to zebracam (still has long latency)
* add zebracam key cmd to dump frame to file (for debugging)
* fixes for decoder/scanner reset/new_scan
* fixes to scanner initialization and algorithm tweaks
* made decoder less sensitive to violated quiet-zone
* apply zebraimg workaround for imagemagick image display bug
* add string names for symbol types to library and API to access them
* add dbg_scan test program for visually debugging image scanner (and
decoder)
* add test_walk for basic image walker sanity/debug
* removed recursive makes in favor of monolithic build
* renamed some makefiles accordingly
* finished some final symbol data construction
* added result callbacks to decoder APIs for data reporting
* zebraimg hooks into callback
* zebracam still seems to "hang" in undecodeable state?
* populate svn with current sources.
* most of the basic functionality is included and working.
* still need to combine final decode data, finish addons, etc (see TODO).
* c++ wrappers are included and tested, but API may need tweaked.
* zebraimg and zebracam basically working but need cleanup/polish.
* need to create some basic documentation...
* initial repository layout

96
HACKING.md Normal file
View File

@ -0,0 +1,96 @@
Downloading ZBar source code
============================
When hacking at ZBar, PLEASE send patches against the latest Git tree!
There are currently 3 mirrors with ZBar:
LinuxTV:
Cgit GUI interface:
https://git.linuxtv.org/zbar.git/
Git tree:
git://linuxtv.org/zbar.git
https://git.linuxtv.org/cgit.cgi/zbar.git
http://git.linuxtv.org/cgit.cgi/zbar.git
Github:
https://github.com/mchehab/zbar.git
Gitlab:
https://github.com/mchehab/zbar
You can use git clone to get the latest version from any of the
above repositories.
if you haven't already, grab the ZBar git repository. For example, to
get it from Github, use:
git clone https://github.com/mchehab/zbar.git
cd zbar
autoreconf -vfi
This will generate ./configure and all that other foo you usually get with
a release. you will need to have recent versions of some basic "developer
tools" installed in order for this to work, particularly GNU autotools.
these versions of autotools are known to work (newer versions should also
be fine):
GNU autoconf 2.61
GNU automake 1.10.1
GNU libtool 2.2.6
GNU gettext 0.18.1.1
GNU pkg-config 0.25
xmlto 0.0.20-5 (for docs building)
all above mentioned tools (except xmlto) must be installed in the same
prefix. mixing prefixes (i.g. /usr/bin and /usr/local/bin) may lead to
errors in configuration stages
Writing descriptions for your patches
=====================================
Please add a good description to your patch adding why it is needed,
what the patch does and how. This helps us when reviewing your work
when you submit upstream.
We use a process similar to the Linux Kernel for patch submissions.
In particular, submitted patches should have a developer's certificate
of origin, as described at:
https://linuxtv.org/wiki/index.php/Development:_Submitting_Patches#Developer.27s_Certificate_of_Origin_1.1
In practice, please add:
Signed-off-by: your name <your@email>
on your pathes.
Submitting patches
==================
When you're done hacking, please submit your work back upstream.
If you use Github or Gitlab, you can fork ZBar from it, develop your
patches and then push again to your clone, asking the patch merge using
the GUI.
Although we prefer if you submit patches via either Github or
Gitlab, you can also submit them via e-mail to:
linux-media@vger.kernel.org
If you opt to do so, please place [PATCH ZBar] at the subject of
your e-mails for us to not mix them with patches for the Kernel
or for other media tools.
and want to make your patch, run:
git diff > hacked.patch
Other things for you to read, in order to know more about how
to submit your work for upstreaming processes in general, that
could be useful for you to prepare yourself on submitting patches
to ZBar:
- https://linuxtv.org/wiki/index.php/Development:_Submitting_Patches
- http://www.faqs.org/docs/artu/ch19s02.html
- http://www.catb.org/~esr/faqs/smart-questions.html

199
INSTALL.md Normal file
View File

@ -0,0 +1,199 @@
Basic Installation
==================
These are generic installation instructions.
The `configure` shell script attempts to guess correct values for
various system-dependent variables used during compilation. It uses
those values to create a `Makefile` in each directory of the package.
It may also create one or more `.h` files containing system-dependent
definitions. Finally, it creates a shell script `config.status` that
you can run in the future to recreate the current configuration, a file
`config.cache` that saves the results of its tests to speed up
reconfiguring, and a file `config.log` containing compiler output
(useful mainly for debugging `configure`).
If you need to do unusual things to compile the package, please try
to figure out how `configure` could check whether to do them, and mail
diffs or instructions to the address given in the `README` so they can
be considered for the next release. If at some point `config.cache`
contains results you don't want to keep, you may remove or edit it.
The file `configure.in` is used to create `configure` by a program
called `autoconf`. You only need `configure.in` if you want to change
it or regenerate `configure` using a newer version of `autoconf`.
The simplest way to compile this package is:
1. `cd` to the directory containing the package's source code and type
`autoreconf -vfi && ./configure` to configure the package for
your system. If you're using `csh` on an old version of System V,
you might need to type `sh ./configure` instead to prevent `csh`
from trying to execute `configure` itself.
Running `configure` takes awhile. While running, it prints some
messages telling which features it is checking for.
2. Type `make` to compile the package.
3. Optionally, type `make check` to run any self-tests that come with
the package.
4. Type `make install` to install the programs and any data files and
documentation.
5. You can remove the program binaries and object files from the
source code directory by typing `make clean`. To also remove the
files that `configure` created (so you can compile the package for
a different kind of computer), type `make distclean`. There is
also a `make maintainer-clean` target, but that is intended mainly
for the package's developers. If you use it, you may have to get
all sorts of other programs in order to regenerate files that came
with the distribution.
Compilers and Options
=====================
Some systems require unusual options for compilation or linking that
the `configure` script does not know about. You can give `configure`
initial values for variables by setting them in the environment. Using
a Bourne-compatible shell, you can do that on the command line like
this:
CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure
Or on systems that have the `env` program, you can do it like this:
env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure
Compiling For Multiple Architectures
====================================
You can compile the package for more than one kind of computer at the
same time, by placing the object files for each architecture in their
own directory. To do this, you must use a version of `make` that
supports the `VPATH` variable, such as GNU `make`. `cd` to the
directory where you want the object files and executables to go and run
the `configure` script. `configure` automatically checks for the
source code in the directory that `configure` is in and in `../`.
If you have to use a `make` that does not supports the `VPATH`
variable, you have to compile the package for one architecture at a time
in the source code directory. After you have installed the package for
one architecture, use `make distclean` before reconfiguring for another
architecture.
Installation Names
==================
By default, `make install` will install the package's files in
`/usr/local/bin`, `/usr/local/man`, etc. You can specify an
installation prefix other than `/usr/local` by giving `configure` the
option `--prefix=PATH`.
You can specify separate installation prefixes for
architecture-specific files and architecture-independent files. If you
give `configure` the option `--exec-prefix=PATH`, the package will use
PATH as the prefix for installing programs and libraries.
Documentation and other data files will still use the regular prefix.
In addition, if you use an unusual directory layout you can give
options like `--bindir=PATH` to specify different values for particular
kinds of files. Run `configure --help` for a list of the directories
you can set and what kinds of files go in them.
If the package supports it, you can cause programs to be installed
with an extra prefix or suffix on their names by giving `configure` the
option `--program-prefix=PREFIX` or `--program-suffix=SUFFIX`.
Optional Features
=================
Some packages pay attention to `--enable-FEATURE` options to
`configure`, where FEATURE indicates an optional part of the package.
They may also pay attention to `--with-PACKAGE` options, where PACKAGE
is something like `gnu-as` or `x` (for the X Window System). The
`README` should mention any `--enable-` and `--with-` options that the
package recognizes.
For packages that use the X Window System, `configure` can usually
find the X include and library files automatically, but if it doesn't,
you can use the `configure` options `--x-includes=DIR` and
`--x-libraries=DIR` to specify their locations.
Specifying the System Type
==========================
There may be some features `configure` can not figure out
automatically, but needs to determine by the type of host the package
will run on. Usually `configure` can figure that out, but if it prints
a message saying it can not guess the host type, give it the
`--host=TYPE` option. TYPE can either be a short name for the system
type, such as `sun4`, or a canonical name with three fields:
CPU-COMPANY-SYSTEM
See the file `config.sub` for the possible values of each field. If
`config.sub` isn't included in this package, then this package doesn't
need to know the host type.
If you are building compiler tools for cross-compiling, you can also
use the `--target=TYPE` option to select the type of system they will
produce code for and the `--build=TYPE` option to select the type of
system on which you are compiling the package.
Sharing Defaults
================
If you want to set default values for `configure` scripts to share,
you can create a site shell script called `config.site` that gives
default values for variables like `CC`, `cache_file`, and `prefix`.
`configure` looks for `PREFIX/share/config.site` if it exists, then
`PREFIX/etc/config.site` if it exists. Or, you can set the
`CONFIG_SITE` environment variable to the location of the site script.
A warning: not all `configure` scripts look for a site script.
Operation Controls
==================
`configure` recognizes the following options to control how it
operates.
`--cache-file=FILE`
Use and save the results of the tests in FILE instead of
`./config.cache`. Set FILE to `/dev/null` to disable caching, for
debugging `configure`.
`--help`
Print a summary of the options to `configure`, and exit.
`--quiet`
`--silent`
`-q`
Do not print messages saying which checks are being made. To
suppress all normal output, redirect it to `/dev/null` (any error
messages will still be shown).
`--srcdir=DIR`
Look for the package's source code in directory DIR. Usually
`configure` can determine that directory automatically.
`--version`
Print the version of Autoconf used to generate the `configure`
script, and exit.
`configure` also accepts some other, not widely useful, options.
Debian/Ubuntu package build
===========================
For Debian/Ubuntu, one alternative way to build ZBar is by using
pbuilder. In order to install pbuilder, see, for example:
https://wiki.ubuntu.com/PbuilderHowto
Once you have pbuilder installed and configured, you
can build a ZBar package, running the following commands as
root:
# pbuilder create --basetgz /var/cache/pbuilder/base-test.tgz
# pbuilder build --basetgz /var/cache/pbuilder/base-test.tgz ../zbar_0.20.2.dsc

503
LICENSE.md Normal file
View File

@ -0,0 +1,503 @@
### GNU LESSER GENERAL PUBLIC LICENSE
Version 2.1, February 1999
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Everyone is permitted to copy and distribute verbatim copies
of this license document, but changing it is not allowed.
[This is the first released version of the Lesser GPL. It also counts
as the successor of the GNU Library Public License, version 2, hence
the version number 2.1.]
### Preamble
The licenses for most software are designed to take away your freedom
to share and change it. By contrast, the GNU General Public Licenses
are intended to guarantee your freedom to share and change free
software--to make sure the software is free for all its users.
This license, the Lesser General Public License, applies to some
specially designated software packages--typically libraries--of the
Free Software Foundation and other authors who decide to use it. You
can use it too, but we suggest you first think carefully about whether
this license or the ordinary General Public License is the better
strategy to use in any particular case, based on the explanations
below.
When we speak of free software, we are referring to freedom of use,
not price. Our General Public Licenses are designed to make sure that
you have the freedom to distribute copies of free software (and charge
for this service if you wish); that you receive source code or can get
it if you want it; that you can change the software and use pieces of
it in new free programs; and that you are informed that you can do
these things.
To protect your rights, we need to make restrictions that forbid
distributors to deny you these rights or to ask you to surrender these
rights. These restrictions translate to certain responsibilities for
you if you distribute copies of the library or if you modify it.
For example, if you distribute copies of the library, whether gratis
or for a fee, you must give the recipients all the rights that we gave
you. You must make sure that they, too, receive or can get the source
code. If you link other code with the library, you must provide
complete object files to the recipients, so that they can relink them
with the library after making changes to the library and recompiling
it. And you must show them these terms so they know their rights.
We protect your rights with a two-step method: (1) we copyright the
library, and (2) we offer you this license, which gives you legal
permission to copy, distribute and/or modify the library.
To protect each distributor, we want to make it very clear that there
is no warranty for the free library. Also, if the library is modified
by someone else and passed on, the recipients should know that what
they have is not the original version, so that the original author's
reputation will not be affected by problems that might be introduced
by others.
Finally, software patents pose a constant threat to the existence of
any free program. We wish to make sure that a company cannot
effectively restrict the users of a free program by obtaining a
restrictive license from a patent holder. Therefore, we insist that
any patent license obtained for a version of the library must be
consistent with the full freedom of use specified in this license.
Most GNU software, including some libraries, is covered by the
ordinary GNU General Public License. This license, the GNU Lesser
General Public License, applies to certain designated libraries, and
is quite different from the ordinary General Public License. We use
this license for certain libraries in order to permit linking those
libraries into non-free programs.
When a program is linked with a library, whether statically or using a
shared library, the combination of the two is legally speaking a
combined work, a derivative of the original library. The ordinary
General Public License therefore permits such linking only if the
entire combination fits its criteria of freedom. The Lesser General
Public License permits more lax criteria for linking other code with
the library.
We call this license the "Lesser" General Public License because it
does Less to protect the user's freedom than the ordinary General
Public License. It also provides other free software developers Less
of an advantage over competing non-free programs. These disadvantages
are the reason we use the ordinary General Public License for many
libraries. However, the Lesser license provides advantages in certain
special circumstances.
For example, on rare occasions, there may be a special need to
encourage the widest possible use of a certain library, so that it
becomes a de-facto standard. To achieve this, non-free programs must
be allowed to use the library. A more frequent case is that a free
library does the same job as widely used non-free libraries. In this
case, there is little to gain by limiting the free library to free
software only, so we use the Lesser General Public License.
In other cases, permission to use a particular library in non-free
programs enables a greater number of people to use a large body of
free software. For example, permission to use the GNU C Library in
non-free programs enables many more people to use the whole GNU
operating system, as well as its variant, the GNU/Linux operating
system.
Although the Lesser General Public License is Less protective of the
users' freedom, it does ensure that the user of a program that is
linked with the Library has the freedom and the wherewithal to run
that program using a modified version of the Library.
The precise terms and conditions for copying, distribution and
modification follow. Pay close attention to the difference between a
"work based on the library" and a "work that uses the library". The
former contains code derived from the library, whereas the latter must
be combined with the library in order to run.
### TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
**0.** This License Agreement applies to any software library or other
program which contains a notice placed by the copyright holder or
other authorized party saying it may be distributed under the terms of
this Lesser General Public License (also called "this License"). Each
licensee is addressed as "you".
A "library" means a collection of software functions and/or data
prepared so as to be conveniently linked with application programs
(which use some of those functions and data) to form executables.
The "Library", below, refers to any such software library or work
which has been distributed under these terms. A "work based on the
Library" means either the Library or any derivative work under
copyright law: that is to say, a work containing the Library or a
portion of it, either verbatim or with modifications and/or translated
straightforwardly into another language. (Hereinafter, translation is
included without limitation in the term "modification".)
"Source code" for a work means the preferred form of the work for
making modifications to it. For a library, complete source code means
all the source code for all modules it contains, plus any associated
interface definition files, plus the scripts used to control
compilation and installation of the library.
Activities other than copying, distribution and modification are not
covered by this License; they are outside its scope. The act of
running a program using the Library is not restricted, and output from
such a program is covered only if its contents constitute a work based
on the Library (independent of the use of the Library in a tool for
writing it). Whether that is true depends on what the Library does and
what the program that uses the Library does.
**1.** You may copy and distribute verbatim copies of the Library's
complete source code as you receive it, in any medium, provided that
you conspicuously and appropriately publish on each copy an
appropriate copyright notice and disclaimer of warranty; keep intact
all the notices that refer to this License and to the absence of any
warranty; and distribute a copy of this License along with the
Library.
You may charge a fee for the physical act of transferring a copy, and
you may at your option offer warranty protection in exchange for a
fee.
**2.** You may modify your copy or copies of the Library or any
portion of it, thus forming a work based on the Library, and copy and
distribute such modifications or work under the terms of Section 1
above, provided that you also meet all of these conditions:
- **a)** The modified work must itself be a software library.
- **b)** You must cause the files modified to carry prominent
notices stating that you changed the files and the date of
any change.
- **c)** You must cause the whole of the work to be licensed at no
charge to all third parties under the terms of this License.
- **d)** If a facility in the modified Library refers to a function
or a table of data to be supplied by an application program that
uses the facility, other than as an argument passed when the
facility is invoked, then you must make a good faith effort to
ensure that, in the event an application does not supply such
function or table, the facility still operates, and performs
whatever part of its purpose remains meaningful.
(For example, a function in a library to compute square roots has
a purpose that is entirely well-defined independent of
the application. Therefore, Subsection 2d requires that any
application-supplied function or table used by this function must
be optional: if the application does not supply it, the square
root function must still compute square roots.)
These requirements apply to the modified work as a whole. If
identifiable sections of that work are not derived from the Library,
and can be reasonably considered independent and separate works in
themselves, then this License, and its terms, do not apply to those
sections when you distribute them as separate works. But when you
distribute the same sections as part of a whole which is a work based
on the Library, the distribution of the whole must be on the terms of
this License, whose permissions for other licensees extend to the
entire whole, and thus to each and every part regardless of who wrote
it.
Thus, it is not the intent of this section to claim rights or contest
your rights to work written entirely by you; rather, the intent is to
exercise the right to control the distribution of derivative or
collective works based on the Library.
In addition, mere aggregation of another work not based on the Library
with the Library (or with a work based on the Library) on a volume of
a storage or distribution medium does not bring the other work under
the scope of this License.
**3.** You may opt to apply the terms of the ordinary GNU General
Public License instead of this License to a given copy of the Library.
To do this, you must alter all the notices that refer to this License,
so that they refer to the ordinary GNU General Public License, version
2, instead of to this License. (If a newer version than version 2 of
the ordinary GNU General Public License has appeared, then you can
specify that version instead if you wish.) Do not make any other
change in these notices.
Once this change is made in a given copy, it is irreversible for that
copy, so the ordinary GNU General Public License applies to all
subsequent copies and derivative works made from that copy.
This option is useful when you wish to copy part of the code of the
Library into a program that is not a library.
**4.** You may copy and distribute the Library (or a portion or
derivative of it, under Section 2) in object code or executable form
under the terms of Sections 1 and 2 above provided that you accompany
it with the complete corresponding machine-readable source code, which
must be distributed under the terms of Sections 1 and 2 above on a
medium customarily used for software interchange.
If distribution of object code is made by offering access to copy from
a designated place, then offering equivalent access to copy the source
code from the same place satisfies the requirement to distribute the
source code, even though third parties are not compelled to copy the
source along with the object code.
**5.** A program that contains no derivative of any portion of the
Library, but is designed to work with the Library by being compiled or
linked with it, is called a "work that uses the Library". Such a work,
in isolation, is not a derivative work of the Library, and therefore
falls outside the scope of this License.
However, linking a "work that uses the Library" with the Library
creates an executable that is a derivative of the Library (because it
contains portions of the Library), rather than a "work that uses the
library". The executable is therefore covered by this License. Section
6 states terms for distribution of such executables.
When a "work that uses the Library" uses material from a header file
that is part of the Library, the object code for the work may be a
derivative work of the Library even though the source code is not.
Whether this is true is especially significant if the work can be
linked without the Library, or if the work is itself a library. The
threshold for this to be true is not precisely defined by law.
If such an object file uses only numerical parameters, data structure
layouts and accessors, and small macros and small inline functions
(ten lines or less in length), then the use of the object file is
unrestricted, regardless of whether it is legally a derivative work.
(Executables containing this object code plus portions of the Library
will still fall under Section 6.)
Otherwise, if the work is a derivative of the Library, you may
distribute the object code for the work under the terms of Section 6.
Any executables containing that work also fall under Section 6,
whether or not they are linked directly with the Library itself.
**6.** As an exception to the Sections above, you may also combine or
link a "work that uses the Library" with the Library to produce a work
containing portions of the Library, and distribute that work under
terms of your choice, provided that the terms permit modification of
the work for the customer's own use and reverse engineering for
debugging such modifications.
You must give prominent notice with each copy of the work that the
Library is used in it and that the Library and its use are covered by
this License. You must supply a copy of this License. If the work
during execution displays copyright notices, you must include the
copyright notice for the Library among them, as well as a reference
directing the user to the copy of this License. Also, you must do one
of these things:
- **a)** Accompany the work with the complete corresponding
machine-readable source code for the Library including whatever
changes were used in the work (which must be distributed under
Sections 1 and 2 above); and, if the work is an executable linked
with the Library, with the complete machine-readable "work that
uses the Library", as object code and/or source code, so that the
user can modify the Library and then relink to produce a modified
executable containing the modified Library. (It is understood that
the user who changes the contents of definitions files in the
Library will not necessarily be able to recompile the application
to use the modified definitions.)
- **b)** Use a suitable shared library mechanism for linking with
the Library. A suitable mechanism is one that (1) uses at run time
a copy of the library already present on the user's computer
system, rather than copying library functions into the executable,
and (2) will operate properly with a modified version of the
library, if the user installs one, as long as the modified version
is interface-compatible with the version that the work was
made with.
- **c)** Accompany the work with a written offer, valid for at least
three years, to give the same user the materials specified in
Subsection 6a, above, for a charge no more than the cost of
performing this distribution.
- **d)** If distribution of the work is made by offering access to
copy from a designated place, offer equivalent access to copy the
above specified materials from the same place.
- **e)** Verify that the user has already received a copy of these
materials or that you have already sent this user a copy.
For an executable, the required form of the "work that uses the
Library" must include any data and utility programs needed for
reproducing the executable from it. However, as a special exception,
the materials to be distributed need not include anything that is
normally distributed (in either source or binary form) with the major
components (compiler, kernel, and so on) of the operating system on
which the executable runs, unless that component itself accompanies
the executable.
It may happen that this requirement contradicts the license
restrictions of other proprietary libraries that do not normally
accompany the operating system. Such a contradiction means you cannot
use both them and the Library together in an executable that you
distribute.
**7.** You may place library facilities that are a work based on the
Library side-by-side in a single library together with other library
facilities not covered by this License, and distribute such a combined
library, provided that the separate distribution of the work based on
the Library and of the other library facilities is otherwise
permitted, and provided that you do these two things:
- **a)** Accompany the combined library with a copy of the same work
based on the Library, uncombined with any other
library facilities. This must be distributed under the terms of
the Sections above.
- **b)** Give prominent notice with the combined library of the fact
that part of it is a work based on the Library, and explaining
where to find the accompanying uncombined form of the same work.
**8.** You may not copy, modify, sublicense, link with, or distribute
the Library except as expressly provided under this License. Any
attempt otherwise to copy, modify, sublicense, link with, or
distribute the Library is void, and will automatically terminate your
rights under this License. However, parties who have received copies,
or rights, from you under this License will not have their licenses
terminated so long as such parties remain in full compliance.
**9.** You are not required to accept this License, since you have not
signed it. However, nothing else grants you permission to modify or
distribute the Library or its derivative works. These actions are
prohibited by law if you do not accept this License. Therefore, by
modifying or distributing the Library (or any work based on the
Library), you indicate your acceptance of this License to do so, and
all its terms and conditions for copying, distributing or modifying
the Library or works based on it.
**10.** Each time you redistribute the Library (or any work based on
the Library), the recipient automatically receives a license from the
original licensor to copy, distribute, link with or modify the Library
subject to these terms and conditions. You may not impose any further
restrictions on the recipients' exercise of the rights granted herein.
You are not responsible for enforcing compliance by third parties with
this License.
**11.** If, as a consequence of a court judgment or allegation of
patent infringement or for any other reason (not limited to patent
issues), conditions are imposed on you (whether by court order,
agreement or otherwise) that contradict the conditions of this
License, they do not excuse you from the conditions of this License.
If you cannot distribute so as to satisfy simultaneously your
obligations under this License and any other pertinent obligations,
then as a consequence you may not distribute the Library at all. For
example, if a patent license would not permit royalty-free
redistribution of the Library by all those who receive copies directly
or indirectly through you, then the only way you could satisfy both it
and this License would be to refrain entirely from distribution of the
Library.
If any portion of this section is held invalid or unenforceable under
any particular circumstance, the balance of the section is intended to
apply, and the section as a whole is intended to apply in other
circumstances.
It is not the purpose of this section to induce you to infringe any
patents or other property right claims or to contest validity of any
such claims; this section has the sole purpose of protecting the
integrity of the free software distribution system which is
implemented by public license practices. Many people have made
generous contributions to the wide range of software distributed
through that system in reliance on consistent application of that
system; it is up to the author/donor to decide if he or she is willing
to distribute software through any other system and a licensee cannot
impose that choice.
This section is intended to make thoroughly clear what is believed to
be a consequence of the rest of this License.
**12.** If the distribution and/or use of the Library is restricted in
certain countries either by patents or by copyrighted interfaces, the
original copyright holder who places the Library under this License
may add an explicit geographical distribution limitation excluding
those countries, so that distribution is permitted only in or among
countries not thus excluded. In such case, this License incorporates
the limitation as if written in the body of this License.
**13.** The Free Software Foundation may publish revised and/or new
versions of the Lesser General Public License from time to time. Such
new versions will be similar in spirit to the present version, but may
differ in detail to address new problems or concerns.
Each version is given a distinguishing version number. If the Library
specifies a version number of this License which applies to it and
"any later version", you have the option of following the terms and
conditions either of that version or of any later version published by
the Free Software Foundation. If the Library does not specify a
license version number, you may choose any version ever published by
the Free Software Foundation.
**14.** If you wish to incorporate parts of the Library into other
free programs whose distribution conditions are incompatible with
these, write to the author to ask for permission. For software which
is copyrighted by the Free Software Foundation, write to the Free
Software Foundation; we sometimes make exceptions for this. Our
decision will be guided by the two goals of preserving the free status
of all derivatives of our free software and of promoting the sharing
and reuse of software generally.
**NO WARRANTY**
**15.** BECAUSE THE LIBRARY IS LICENSED FREE OF CHARGE, THERE IS NO
WARRANTY FOR THE LIBRARY, TO THE EXTENT PERMITTED BY APPLICABLE LAW.
EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR
OTHER PARTIES PROVIDE THE LIBRARY "AS IS" WITHOUT WARRANTY OF ANY
KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE
IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE
LIBRARY IS WITH YOU. SHOULD THE LIBRARY PROVE DEFECTIVE, YOU ASSUME
THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
**16.** IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN
WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY
AND/OR REDISTRIBUTE THE LIBRARY AS PERMITTED ABOVE, BE LIABLE TO YOU
FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR
CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE
LIBRARY (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING
RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A
FAILURE OF THE LIBRARY TO OPERATE WITH ANY OTHER SOFTWARE), EVEN IF
SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
DAMAGES.
### END OF TERMS AND CONDITIONS
### How to Apply These Terms to Your New Libraries
If you develop a new library, and you want it to be of the greatest
possible use to the public, we recommend making it free software that
everyone can redistribute and change. You can do so by permitting
redistribution under these terms (or, alternatively, under the terms
of the ordinary General Public License).
To apply these terms, attach the following notices to the library. It
is safest to attach them to the start of each source file to most
effectively convey the exclusion of warranty; and each file should
have at least the "copyright" line and a pointer to where the full
notice is found.
one line to give the library's name and an idea of what it does.
Copyright (C) year name of author
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
Also add information on how to contact you by electronic and paper
mail.
You should also get your employer (if you work as a programmer) or
your school, if any, to sign a "copyright disclaimer" for the library,
if necessary. Here is a sample; alter the names:
Yoyodyne, Inc., hereby disclaims all copyright interest in
the library `Frob' (a library for tweaking knobs) written
by James Random Hacker.
signature of Ty Coon, 1 April 1990
Ty Coon, President of Vice
That's all there is to it!

149
Makefile.am Normal file
View File

@ -0,0 +1,149 @@
ACLOCAL_AMFLAGS = -I config
AM_CFLAGS += -DLOCALEDIR=\"$(localedir)\"
AM_CXXFLAGS += -DLOCALEDIR=\"$(localedir)\"
bin_PROGRAMS =
check_PROGRAMS =
EXTRA_PROGRAMS =
lib_LTLIBRARIES =
pyexec_LTLIBRARIES =
CLEANFILES =
DISTCLEANFILES = \
ABOUT-NLS \
po/*.gmo \
po/*.mo \
po/Makefile.in.in \
po/Makevars.template \
po/POTFILES \
po/Rules-quot \
po/boldquot.sed \
po/en@boldquot.header \
po/en@quot.header \
po/insert-header.sin \
po/quot.sed \
po/remove-potcdate.sed \
po/remove-potcdate.sin \
po/stamp-po \
po/zbar.pot
MAINTAINERCLEANFILES =
BUILT_SOURCES =
EXTRA_DIST =
PHONY = $(SUBDIRS)
pkgconfigdir = $(libdir)/pkgconfig
pkgconfig_DATA = zbar.pc
dist_doc_DATA = COPYING HACKING.md INSTALL.md LICENSE.md NEWS.md README.md TODO.md
include $(srcdir)/include/Makefile.am.inc
SUBDIRS = zbar
if USE_NLS
SUBDIRS += po
dist_doc_DATA += ABOUT-NLS
endif
zbar/libzbar.la:
$(MAKE) -C @builddir@/zbar libzbar.la
if HAVE_MAGICK
include $(srcdir)/zbarimg/Makefile.am.inc
endif
if HAVE_VIDEO
include $(srcdir)/zbarcam/Makefile.am.inc
endif
if HAVE_PYTHON
include $(srcdir)/python/Makefile.am.inc
endif
if HAVE_GTK
SUBDIRS += gtk
pkgconfig_DATA += zbar-gtk.pc
gtk/libzbargtk.la:
$(MAKE) -C @builddir@/gtk libzbargtk.la
gtk/zbarmarshal.h:
$(MAKE) -C @builddir@/gtk zbarmarshal.h
gtk/ZBar-1.0.typelib:
$(MAKE) -C $(srcdir)/gtk ZBar-1.0.typelib
if HAVE_PYGTK2
include $(srcdir)/pygtk/Makefile.am.inc
endif
endif
if HAVE_QT
include $(srcdir)/qt/Makefile.am.inc
pkgconfig_DATA += zbar-qt.pc
endif
if HAVE_JAVA
SUBDIRS += java
endif
if HAVE_NPAPI
include $(srcdir)/plugin/Makefile.am.inc
endif
include $(srcdir)/test/Makefile.am.inc
if HAVE_DOC
include $(srcdir)/doc/Makefile.am.inc
endif
if HAVE_DBUS
dbusconfdir = @DBUS_CONFDIR@
dbusconf_DATA = $(srcdir)/dbus/org.linuxtv.Zbar.conf
endif
EXTRA_DIST += zbar.ico zbar.nsi zbar-qt5.pc.in zbar-qt.pc.in \
dbus/org.linuxtv.Zbar.conf
EXTRA_DIST += examples/*.png examples/sha1sum \
examples/upcrpc.py examples/upcrpc.pl \
examples/scan_image.c examples/scan_image.cpp examples/scan_image.vcproj
EXTRA_DIST += perl/MANIFEST perl/README perl/Changes perl/COPYING.LIB \
perl/Makefile.PL perl/typemap perl/ZBar.xs perl/ppport.h \
perl/ZBar.pm perl/inc/Devel/CheckLib.pm perl/ZBar/Image.pod \
perl/ZBar/ImageScanner.pod perl/ZBar/Processor.pod perl/ZBar/Symbol.pod \
perl/examples/paginate.pl perl/examples/processor.pl \
perl/examples/read_one.pl perl/examples/scan_image.pl \
perl/t/barcode.png perl/t/ZBar.t perl/t/Decoder.t perl/t/Image.t \
perl/t/Processor.t perl/t/Scanner.t perl/t/pod.t perl/t/pod-coverage.t
if WIN32
dist_doc_DATA += README-windows.md
pkgdata_DATA = $(srcdir)/python/test/barcode.png \
$(srcdir)/examples/scan_image.cpp $(srcdir)/examples/scan_image.vcproj
%-rc.o: %.rc
$(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) -o $@ $<
%-rc.lo: %.rc
$(LIBTOOL) --tag=RC $(AM_LIBTOOLFLAGS) $(LIBTOOLFLAGS) \
--mode=compile $(RC) $(DEFS) $(DEFAULT_INCLUDES) $(INCLUDES) \
$(AM_CPPFLAGS) $(CPPFLAGS) -o $@ $<
# install to tmp dest and run NSIS to generate installer
dist-nsis: html-local
test ! -e _nsis || test -d _nsis && rm -rf _nsis
mkdir _nsis
tmpinst=`cd _nsis && pwd | sed -e 's,^[^:\\/]:[\\/],/,'` \
&& $(MAKE) $(AM_MAKEFLAGS) DESTDIR=$$tmpinst prefix=/ install
cp zbar/.libs/libzbar-0.dll.def _nsis/lib/libzbar-0.def
cp -r doc/html _nsis/share/doc/zbar/
$(WINEXEC) lib.exe /machine:x86 /def:_nsis/lib/libzbar-0.def /out:_nsis/lib/libzbar-0.lib
cd _nsis && \
makensis -NOCD -V2 -DVERSION=$(VERSION) $(builddir)/zbar.nsi
@ls -l _nsis/zbar-$(VERSION)-setup.exe
PHONY += dist-nsis
endif
SUBDIRS += .
archive:
git archive --format=tar --prefix=zbar-$(VERSION)/ -o zbar-$(VERSION).tar $(VERSION)
bzip2 zbar-$(VERSION).tar
.PHONY : $(PHONY) archive
dist-hook:
rm -f $(distdir)/debian $(distdir)/travis

157
NEWS.md Normal file
View File

@ -0,0 +1,157 @@
ZBar Barcode Reader News
========================
Version 0.23
============
Update ZBar for it to work with updated library versions, making it
compatible with either Gtk2 or Gtk3 and either Python2 or Python3.
As part of the new port, it is now possible to use ZBar Gtk bindings
not only with python2/python3, but also on other languages, as it now
uses GObject Introspection- GIR, with is a method to allow using libraries
developed on one language on others. Several languages support it.
On Windows side, support for DirectShow was added.
Version 0.22.2 (2019-04-29)
===========================
Some fixes to another set of Windows issues and to support Java 11.
Version 0.22.1 (2019-04-25)
===========================
Some fixes to allow building ZBar on Windows with MinGw.
Version 0.22 (2019-02-20)
=========================
Lots of improvements at zbarcam-qt, allowing it to fully configure the
decoders that will be used, and the options that will be used at the
decoders. Some improvements at the image scanner logic and plugin
selection.
Version 0.21 (2019-02-12)
=========================
Added support for SQ code, and the ability of compiling ZBar with the
LLVM/Clang compiler. Several bugs fixes and enhancements are also found
in this release; qexisting users are encouraged to upgrade.
Version 0.20.1 (2018-08-08)
===========================
Minor changes at ZBar, in order to adapt to modern distributions
with are removing /usr/bin/python in favor of just using python2.
Also, updated some python2 scripts to work with modern distros,
where the Image module is now inside PIL.
Version 0.20 (2017-04-11)
=========================
As upstream didn't have any version since 2009, created a ZBar fork at
linuxtv.org. This release improves a lot V4L2 support, by using libv4l2
to handle formats that are alien to ZBar, making it compatible with a lot
more webcam models. Qt support was also updated, making it compatible
with Qt5. ZBar now have two other GUI applications (zbarcam-qt and
zbarcam-gtk). With zbarcam-qt, it is now possible to adjust the camera
controls, making easier to read barcodes using a camera.
Version 0.10 (2009-10-23)
=========================
ZBar goes 2D! This release introduces support for QR Code, developed
by our new project member, Timothy Terriberry. Timothy is an image
processing master, providing this sophisticated functionality using
only integer arithmetic and maintaining an extremely small image
size. Feel free to drop in on #zbar over at freenode to welcome
Timothy (aka derf) to the project and congratulate him on his awesome
work.
Several bugs fixes and enhancements are also found in this release;
existing users are encouraged to upgrade.
Version 0.9 (2009-08-31)
========================
Introducing ZBar for Windows! So far we only have straight ports of
the command line applications, but work on a cross-platform GUI has
already begun. This release also has a few scanner/decoder
enhancements and fixes several bugs. Many internal changes are
represented, so please open a support request if you experience any
problems.
Version 0.8 (2009-06-05)
========================
This is a bugfix release just to clean up a few issues found in the
last release. Existing users are encouraged to upgrade to pick up
these fixes.
Version 0.7 (2009-04-21)
========================
Welcome to ZBar! In addition to finalizing the project name change,
this release adds new bindings for Python and fixes a few bugs with
the Perl interface. The decoder also has several new features and
addresses missing checks that will improve reliability with
excessively noisy images.
Version 0.6 (2009-02-28)
========================
This release fixes many bugs and adds several improvements suggested
by users: support for decoding UPC-E is finished. zebraimg is
now able to scan all pages of a document (such as PDF or TIFF) and
the new XML output includes the page where each barcode is found.
Camera support has been significantly improved, including the
addition of JPEG image formats. Perl bindings make it even easier
to write a document or video scanning application. Finally, we are
now able to offer initial support for building the base library for
Windows!
Version 0.5 (2008-07-25)
========================
Introducing zebra widgets! Prioritized by popular demand, this
release includes fully functional barcode scanning widgets for GTK,
PyGTK, and Qt. Application developers may now seamlessly integrate
barcode reader support with their user interface.
This release also fixes many bugs; existing users are encouraged to
upgrade.
Version 0.4 (2008-05-31)
========================
new support for EAN-8, Code 39 and Interleaved 2 of 5!
this release also introduces the long awaited decoder configuration
options and fixes several bugs
Version 0.3 (2008-02-25)
========================
this is a beta release of the enhanced internal architecture.
support has been added for version 2 of the video4linux API and many
more image formats. several other feature enhancements and bug
fixes are also included. image scanning is slightly improved for
some images, but the base scan/decode function is relatively
untouched. significant new code is represented in this release
- all bug reports are welcome and will be addressed promptly!
Version 0.2 (2007-05-16)
========================
this release introduces significant enhancements, bug fixes and new
features! basic EAN-13/UPC-A reading has been improved and should
now be much more reliable. by popular request, new support has been
added for decoding Code 128. additionally, the build process was
improved and there is even basic documentation for the application
commands
Version 0.1 (2007-03-24)
========================
first official Zebra release!
supports basic scanning and decoding of EAN-13 and UPC-A symbols
using a webcam (zebracam) or from stored image files (zebraimg).
still need to add support for addons and EAN-8/UPC-E

225
README-windows.md Normal file
View File

@ -0,0 +1,225 @@
ZBAR BAR CODE READER
====================
ZBar Bar Code Reader is an open source software suite for reading bar codes
from various sources, such as video streams, image files and raw intensity
sensors. It supports EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 93, Code 39,
Codabar, Interleaved 2 of 5 and QR Code. Included with the library are basic
applications for decoding captured bar code images and using a video device
(eg, webcam) as a bar code scanner. For application developers, language
bindings are included for C, C++, Python and Perl as well as GUI widgets for
Qt, GTK and PyGTK.
Check the ZBar home page for the latest release, mailing lists, etc.
* <https://github.com/mchehab/zbar>
License information can be found in 'COPYING'.
Once built, the Windows binaries will use binaries of several supporting
libraries, each one with its own copyright, license and source code locations.
It follows a non-exhaustive list of those components:
* The GNU libiconv character set conversion library
Copyright (C) since 1999 Free Software Foundation, Inc.
Licensed under LGPL. The source code is available from
* <http://www.gnu.org/software/libiconv>
* The ImageMagick software imaging library
Copyright since 1999 ImageMagick Studio LLC
Licensed under a derived Apache 2.0 license:
* https://imagemagick.org/script/license.php
The source code is available from
* <http://imagemagick.org>
* The libxml2 XML C parser and toolkit
Copyright (C) since 1998 Daniel Veillard.
Licensed under the MIT license.
The source code is available from:
* <http://xmlsoft.org>
* JPEG library
The Independent JPEG Group's software's version is:
Copyright (C) since 1991 Thomas G. Lane, Guido Vollbeding.
Libjpeg-turbo has additional copyrights:
Copyright (C) since 2009 D. R. Commander.
Copyright (C) since 2015 Google, Inc.
Licensed under BSD-style licenses with their own terms:
* https://www.ijg.org/files/README
* https://github.com/libjpeg-turbo/libjpeg-turbo/blob/master/LICENSE.md
The source code is available from:
* <http://www.ijg.org>
* libtiff, a library for reading and writing TIFF
Copyright (c) since 1988 Sam Leffler
Copyright (c) since 1991 Silicon Graphics, Inc.
Licensed under a BSD-style license.
The source code is available from
* <http://www.libtiff.org>
* libpng, the official PNG reference library
Copyright (c) since 1998 Glenn Randers-Pehrson
Licensed under a BSD-style license.
The source code is available from
* <http://www.libpng.org/pub/png/libpng.html>
* The zlib general purpose compression library
Copyright (C) since 1995 Jean-loup Gailly and Mark Adler.
Licensed under a BSD-style license.
The source code is available from
* <http://zlib.net>
* The bzip2 compression library
Copyright (C) since 1996 Julian Seward.
Licensed under a BSD-style license.
The source code is available from
* <http://bzip.org>
* Depending on how this is packaged, other licenses may apply
BUILDING
========
NOTE: this is a simplified version of what it was done in order to do the
Travis CI builds. You may use this as a guide, but the instructions here
may be incomplete. If you find inconsistencies, feel free to submit patches
improving the building steps.
Also, please notice that the instructions here is for a minimal version,
without any bindings nor ImageMagick.
Building on Ubuntu Bionic
-------------------------
You need to install the following packages:
sudo apt-get install -y \
autoconf automake autotools-dev libdbus-1-dev \
pkg-config binutils-mingw-w64-i686 gcc-mingw-w64 \
mingw-w64-i686-dev mingw-w64-common win-iconv-mingw-w64-dev \
xmlto
Then, build Zbar with:
export PKG_CONFIG_PATH=/usr/x86_64-w64-mingw32/lib/pkgconfig
autoreconf -vfi
CC=i686-w64-mingw32-gcc ./configure --host=i686-w64-mingw32 \
--prefix=/usr/local/win32 --with-directshow \
--without-gtk --without-python --without-qt --without-java \
--without-imagemagick --enable-pthread
make
Building natively on Windows
----------------------------
It is possible to build it natively on Windows too.
You need first to setup a building environment with minGw. One way would
be to use Chocolatey to download what's needed:
* https://chocolatey.org/
With Cocolatey installed, ensure that you have minGw and needed deps with:
choco install -r --no-progress -y msys2 make
Then use pacman to install the needed packages:
pacman -Syu --noconfirm autoconf libtool automake make \
autoconf-archive pkg-config
Once you have everything needed and set the PATH to the places where the
building environment is, you can build ZBar with:
autoreconf -vfi
./configure \
--host=i686-w64-mingw32 --prefix=/usr/local/win32 \
--without-gtk --without-python --without-qt --without-java \
--without-imagemagick --enable-pthread \
--with-directshow --disable-dependency-tracking
make
RUNNING
=======
This version of the package includes *only command line programs*.
(The graphical interface is scheduled for a future release)
Invoke Start -> Programs -> ZBar Bar Code Reader -> Start ZBar Command Prompt
to open a shell that has the zbarimg and zbarcam commands available
(in the PATH).
To start the webcam reader using the default camera, type:
zbarcam
To decode an image file, type eg:
zbarimg -d examples\barcode.png
For basic command instructions, type:
zbarimg --help
zbarcam --help
Check the manual for more details.
REPORTING BUGS
==============
Bugs can be reported at the GitHub project page
* <https://github.com/mchehab/zbar>
Please include the ZBar version number and a detailed description of
the problem. You'll probably have better luck if you're also familiar
with the concepts from:
* <http://www.catb.org/~esr/faqs/smart-questions.html>

244
README.md Normal file
View File

@ -0,0 +1,244 @@
ZBAR BAR CODE READER
====================
ZBar Bar Code Reader is an open source software suite for reading bar
codes from various sources, such as video streams, image files and raw
intensity sensors. It supports EAN-13/UPC-A, UPC-E, EAN-8, Code 128,
Code 93, Code 39, Codabar, Interleaved 2 of 5, QR Code and SQ Code.
Included with the library are basic applications for decoding captured bar
code images and using a video device (eg, webcam) as a bar code scanner.
For application developers, language bindings are included for C, C++,
Python 2 and Perl as well as GUI widgets for Qt, GTK and PyGTK 2.0.
Zbar also supports sending the scanned codes via dbus, allowing its
integration with other applications.
Check the ZBar home page for the latest release, mailing lists, etc.:
- <https://github.com/mchehab/zbar>
Tarballs with ZBar can be obtained from:
- <https://linuxtv.org/downloads/zbar/>
Since ZBar version 0.23.90, binaries auto-generated from Github's
Actions workflows are auto-generated for each release:
- <https://linuxtv.org/downloads/zbar/binaries/>
They contain binaries for:
- Ubuntu SID, generated via pbuilder;
- Mac OS;
- Windows, for 4 different configurations:
- 32 bits/64 bits;
- Video for Windows (VfW) or DirectShow (DShow).
License information can be found in `COPYING`.
You may find some outdated documentation at the original ZBar's
site at Sourceforge, but please notice that the content there is not
updated for ages:
http://zbar.sourceforge.net/
BUILDING
========
See `INSTALL.md` for generic configuration and build instructions.
Please notice that at least autotools related packages and a
C compiler are needed, in order to generate the configure script.
So, on Debian, at least those packages are needed:
autoconf autopoint pkg-config libtool gcc make
If you have installed all needed dependencies, all you need to do is to run:
```
autoreconf -vfi
./configure
make
```
* NOTES
1) Currently, we maintain a Continuous Integration build test at
TravisCI:
<https://travis-ci.org/github/mchehab/zbar/>
Due to that, there are scripts meant to test ZBar build on
Linux, Windows and MacOS, that could be helpful. Please see
the `.travis.yml` file, and the corresponding scripts under `travis/`.
2) On version 0.23, since the support for gtk3 and python3 are new,
the default is to use gtk2 and python2.
If you want to use gtk3 and python3, you should have the development
packages for them, and run:
```
autoreconf -vfi
./configure --with-gtk=auto --with-python=auto
make
```
This will make the building system to seek for the latest versions
for gtk and python.
The scanner/decoder library itself only requires a few standard
library functions which should be available almost anywhere.
The zbarcam program uses the video4linux API (v4l1 or v4l2) to access
the video device. This interface is part of the linux kernel, a 3.16
kernel or upper is recommended for full support. More information is
available at:
- <http://www.linuxtv.org/wiki/>
`pkg-config` is used to locate installed libraries. You should have
installed `pkg-config` if you need any of the remaining components.
pkg-config may be obtained from:
- <http://pkg-config.freedesktop.org/>
The `zbarimg` program uses `ImageMagick` to read image files in many
different formats. You will need at least `ImageMagick` version 6.2.6
if you want to scan image files. You may also use `GraphicsMagick`
package instead.
`ImageMagick` may be obtained from:
- <http://www.imagemagick.org/>
Qt Widget
---------
The Qt widget requires Qt4 or Qt5. You will need Qt if you would like to
use or develop a Qt GUI application with an integrated bar code
scanning widget. Qt4 may be obtained from:
- <https://www.qt.io/>
Gtk Widget
----------
The GTK+ widget requires GTK+-2.x or GTK+3.x. You will need GTK+ if you
would like to use or develop a GTK+ GUI application with an integrated bar
code scanning widget. GTK+ may be obtained from:
- <http://www.gtk.org/>
Python widgets
--------------
**Python 2 legacy Gtk widget**
The PyGTK 2.0/pygobject 2.0 wrapper for the GTK+ 2.x widget requires Python 2,
PyGTK. You will need to enable both pygtk2 and gtk2 if you would like to use
or develop a Python 2 GUI application with an integrated bar code scanning
widget. PyGTK may be obtained from:
- <http://www.pygtk.org/>
**Python 2 or 3 GIR Gtk widget**
The GObject Introspection (GIR) wrapper for GTK+ widget is compatible with
PyGObject, with works with either Python version 2 or 3. You will need to
enable both Gtk and Python in order to use or develop a Python application
with an integrated bar code scanning and webcam support. In order to build
it, you need the required dependencies for GIR development. The actual
package depends on the distribution. On Fedora, it is `pygobject3-devel`.
On Debian/Ubuntu, it is `libgirepository1.0-dev` and `gir1.2-gtk-3.0`.
While GIR builds with Gtk2, It is strongly recommended to use GTK+
version 3.x, as there are known issues with version 2.x and GIR, with
will likely make it to fail. A test script can be built and run with:
`make check-gi`. Instructions about how to use are GIR on Python are
available at:
- <https://pygobject.readthedocs.io/en/latest/>
**Python bindings**
The Python bindings require Python 2 or 3 and provide only non-GUI functions.
You will need Python and PIL or Pillow if you would like to scan images or
video directly using Python. Python is available from:
- <http://python.org/>
Perl Widget
-----------
The Perl bindings require Perl (version 5). You will need Perl if you
would like to scan images or video directly using Perl. Perl is
available from:
- <http://www.perl.org/>
If required libraries are not available you may disable building for
the corresponding component using configure (see configure --help).
The Perl bindings must be built separately after installing the
library. see:
- `perl/README`
Java Widget
-----------
The Java ZBar widget uses Java Native Interface (JNI), meaning that the
widget will contain machine-dependent code. It works with Java version
7 and above. Java open JDK is available from:
- <https://openjdk.java.net/>
RUNNING
=======
`make install` will install the library and application programs. Run
`zbarcam-qt` or `zbarcam` to start the video scanner. Use `zbarimg <file>`
to decode a saved image file.
Check the manual to find specific options for each program.
DBUS TESTING
============
In order to test if dbus is working, you could use:
$ dbus-monitor --system interface=org.linuxtv.Zbar1.Code
or build the test programs with:
$ make test_progs
And run:
$ ./test/test_dbus
With that, running this command on a separate shell:
$ ./zbarimg/zbarimg examples/code-128.png
CODE-128:https://github.com/mchehab/zbar
scanned 1 barcode symbols from 1 images in 0.01 seconds
Will produce this output at test_dbus shell window:
Waiting for Zbar events
Type = CODE-128
Value = https://github.com/mchehab/zbar
REPORTING BUGS
==============
Bugs can be reported on the project page:
- <https://github.com/mchehab/zbar>
Please include the ZBar version number and a detailed description of
the problem. You'll probably have better luck if you're also familiar
with the concepts from:
- <http://www.catb.org/~esr/faqs/smart-questions.html>

84
TODO.md Normal file
View File

@ -0,0 +1,84 @@
general
=======
* finish error handling
* handle video destroyed w/images outstanding
* dbg_scan background image stretched (still...)
* profile and weed out obvious oversights
* example using SANE to scan symbol(s)
windows port
============
* libzbar-0.dll should be zbar-0.dll
wrappers
========
* build API docs for zbargtk, zbarpygtk
* is zbargtk/QZBar BGR4 alpha swapped?
* widget config APIs
* drag-and-drop for widgets (configurable...)
* Perl build support integration?
* GTK and Qt perl bindings
* C++ global wrappers
symbologies
===========
* PDF417
* extract/resolve symbol matrix parameters (NB multiple symbols)
* error detection/correction
* high-level decode
* Code 39, i25 optional features (check digit and ASCII escapes)
* handle Code 128 function characters (FNC1-4)
* Code 128 trailing quiet zone checks
decoder
=======
* start/stop/abort and location detail APIs (PDF417, OMR)
* more configuration options
* disable for at least UPC-E (maybe UPC-A?)
* Code-39/i25 check digit (after implementation)
* Code-39 full ASCII (after implementation)
* standard symbology identifiers (which standard?)
* set consistency requirements
* set scanner filter params
* fix max length check during decode
* revisit noise and resolution independence
image scanner
=============
* extract and track symbol polygons
* dynamic scan density (PDF417, OMR)
* add multi-sample array interface to linear scanner
image formats
=============
* fix image data inheritance
* de-interlacing
* add color support to conversions (also jpeg)
* add support for scanline pad throughout
* factor conversion redundancy
window
======
* add XShm support
* X protocol error handling
* Direct2D
* API to query used interface (video, window?) (/format?)
* simple image manipulations scale(xv?)/mirror
* maintain aspect ratio
* more overlay details
* decoded result(?)
* stats
zbarcam/zbarimg
===============
* zbarimg multi-frame duplicate suppression
* stats/fps at zbarcam exit
* decode hook (program/script)? (also zbarimg?)

View File

@ -0,0 +1,15 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.sourceforge.zbar.android"
android:versionCode="1"
android:versionName="1.0">
<application android:label="@string/app_name" >
<activity android:name="ACTIVITY_ENTRY_NAME"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

2
android/ChangeLog Normal file
View File

@ -0,0 +1,2 @@
version 0.1:
* Add initial support for Android platform

112
android/README Normal file
View File

@ -0,0 +1,112 @@
ZBar Android SDK
================
ZBar Bar Code Reader is an open source software suite for reading bar
codes from various sources, such as video streams, image files and raw
intensity sensors. It supports EAN-13/UPC-A, UPC-E, EAN-8, Code 128,
Code 93, Code 39, Codabar, Interleaved 2 of 5, QR Code and
DataBar. These are the JNI wrappers for developing the library on
Android platform.
Check the ZBar home page for the latest release, mailing lists, etc.
https://github.com/mchehab/zbar
Copyright and License
---------------------
Licensed under the GNU Lesser General Public License, version 2.1.
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
Copyright 2008-2012 © Jeff Brown <spadix@users.sourceforge.net> et al
The Android distribution also includes pre-compiled binaries of
supporting libaries, for which copyright, license and source code
locations are as follows:
* The GNU libiconv character set conversion library
Copyright (C) 1999-2011 Free Software Foundation, Inc.
This distribution includes GNU libiconv version 1.14, licensed under
the LGPL version 2. The source code is available from
http://www.gnu.org/software/libiconv
See included files COPYING and LICENSE.md for details.
Installation
------------
After downloading the ZBar-Android-Lib-<version>.zip file, you need to
unzip the file and add it to your Android project. Unzip the file
using your favorite method (ie: command-line, finder, windows
explorer...)
Follow one of the two options.
Option 1 - via command line
cd <android project>
cp -r ZBar-Android-SDK-<version>/libs .
Option 2 - via Eclipse
Right click on Android Project
Select "Import" -> "File System"
Select "Browse" (next to "From directory File" and select the
ZBar-Android-SDK-<verion>/libs directory and click "Open".
Click the check box next to "libs" and the "Options" "Create top-level folder"
check box (below).
Then click "Finish".
You should then see a "libs" folder under your project.
Building
--------
Via Eclipse
You have to add the zbar.jar file to your build path
1) select zbar.jar under libs
2) right-click, select "Build Path" -> "Add to Build Path"
Via command-line
You are all set; ant will automatcially find jar files under the "libs"
subdirectory.
Documentation
-------------
TDB
Examples
--------
You should be able to open and build the examples directly from the
unzipped directory. You will need to run the android tools to setup
the local.properties file which sets sdk.dir.
1) cd <unzip dir>/examples/CameraTest
2) android update project --path .
3) ant debug install
If you have problems with this, please create a new Android project
and copy the necessary files from the examples.
examples/CameraTest is a simple demonstration of how to integrate the
ZBar image scanner with the camera.
Manually building ZBar JNI library
----------------------------------
First download and unzip the iconv library source from
http://www.gnu.org/software/libiconv/
Then kick off the build from the ZBar android directory. You will
need to run the android tools to setup the local.properties file which
setups sdk.dir.
1) cd <zbar project>/android
2) android update project --path .
3) ant -Dndk.dir=<NDK path> -Diconv.src=<iconv library src> zbar-all
This will rebuild all source files, create zbar.jar and
ZBarAndroidSDK.zip file (which bundles the jar and shared
libraries). From here, you can follow the steps for "Integrating ZBar
JNI library in Android project".
To clean run:
ant -Dndk.dir=<NDK path> zbar-clean
See build-ndk.xml for additional target options.

17
android/ant.properties Normal file
View File

@ -0,0 +1,17 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

66
android/build-ndk.xml Normal file
View File

@ -0,0 +1,66 @@
<!--
Ant build file to compile the ZBar JNI files using Android NDK tool
targets:
zbar-clean - removes build generated files, build dir, jar and zip files
zbar-ndk-build - builds the zbarjni and iconv shared libraries
zbar-compile - builds the zbar java files
zbar-jar - builds and jars the zbar java files
zbar-zip - Creates ZBarAndroidSDK-x.y.zip of jar, .so, etc
zbar-all - performs all the above :)
-->
<project name="zbar">
<property name="project.name" value="zbar" />
<property name="project.sdk.name" value="ZBarAndroidSDK" />
<target name="zbar-clean">
<delete dir="../java/build"/>
<delete file="libs/${project.name}.jar"/>
<delete file="${ant.project.name}.zip"/>
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="clean"/>
</exec>
</target>
<target name="zbar-ndk-build">
<exec executable="${ndk.dir}/ndk-build" failonerror="true">
<arg value="ICONV_SRC=${iconv.src}" />
</exec>
</target>
<target name="zbar-compile" depends="zbar-ndk-build">
<mkdir dir="../java/build" />
<javac srcdir="../java/net" destdir="../java/build" />
</target>
<target name="zbar-jar" depends="zbar-compile">
<jar destfile="libs/${project.name}.jar" basedir="../java/build">
</jar>
</target>
<target name="zbar-zip">
<if><condition><not><isset property="version"/></not></condition><then>
<property name="version" value="0.2" />
</then></if>
<zip destfile="${project.sdk.name}-${version}.zip" >
<zipfileset dir="../" prefix="${project.sdk.name}-${version}" includes="COPYING, LICENSE.md"/>
<zipfileset dir="." prefix="${project.sdk.name}-${version}" includes="README"/>
<zipfileset dir="libs" prefix="${project.sdk.name}-${version}/libs"/>
<zipfileset dir="examples" prefix="${project.sdk.name}-${version}/examples"/>
<zipfileset dir="libs" prefix="${project.sdk.name}-${version}/examples/CameraTest/libs"/>
</zip>
</target>
<target name="zbar-all" depends="zbar-jar">
<if><condition><not><isset property="version"/></not></condition><then>
<property name="version" value="0.2" />
</then></if>
<zip destfile="${project.sdk.name}-${version}.zip" >
<zipfileset dir="../" prefix="${project.sdk.name}-${version}" includes="COPYING, LICENSE.md"/>
<zipfileset dir="." prefix="${project.sdk.name}-${version}" includes="README"/>
<zipfileset dir="libs" prefix="${project.sdk.name}-${version}/libs"/>
<zipfileset dir="examples" prefix="${project.sdk.name}-${version}/examples"/>
<zipfileset dir="libs" prefix="${project.sdk.name}-${version}/examples/CameraTest/libs"/>
</zip>
</target>
</project>

86
android/build.xml Normal file
View File

@ -0,0 +1,86 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="ZBarAndroidSDK" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
<copy file="${out.absolute.dir}/classes.jar" tofile="${jar.libs.dir}/zbar_android.jar" />
</target>
-->
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="build-ndk.xml" />
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="net.sourceforge.zbar.android.CameraTest"
android:versionCode="1"
android:versionName="1.0">
<uses-sdk android:minSdkVersion="8" />
<uses-permission android:name="android.permission.CAMERA" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature android:name="android.hardware.camera.autofocus" />
<application android:label="@string/app_name" >
<activity android:name="CameraTestActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>

View File

@ -0,0 +1,17 @@
# This file is used to override default values used by the Ant build system.
#
# This file must be checked in Version Control Systems, as it is
# integral to the build system of your project.
# This file is only used by the Ant script.
# You can use this to override default values such as
# 'source.dir' for the location of your java source folder and
# 'out.dir' for the location of your output folder.
# You can also use it define how the release builds are signed by declaring
# the following properties:
# 'key.store' for the location of your keystore and
# 'key.alias' for the name of the key to use.
# The password will be asked during the build when you use the 'release' target.

View File

@ -0,0 +1,85 @@
<?xml version="1.0" encoding="UTF-8"?>
<project name="CameraTest" default="help">
<!-- The local.properties file is created and updated by the 'android' tool.
It contains the path to the SDK. It should *NOT* be checked into
Version Control Systems. -->
<property file="local.properties" />
<!-- The ant.properties file can be created by you. It is only edited by the
'android' tool to add properties to it.
This is the place to change some Ant specific build properties.
Here are some properties you may want to change/update:
source.dir
The name of the source directory. Default is 'src'.
out.dir
The name of the output directory. Default is 'bin'.
For other overridable properties, look at the beginning of the rules
files in the SDK, at tools/ant/build.xml
Properties related to the SDK location or the project target should
be updated using the 'android' tool with the 'update' action.
This file is an integral part of the build system for your
application and should be checked into Version Control Systems.
-->
<property file="ant.properties" />
<!-- The project.properties file is created and updated by the 'android'
tool, as well as ADT.
This contains project specific properties such as project target, and library
dependencies. Lower level build properties are stored in ant.properties
(or in .classpath for Eclipse projects).
This file is an integral part of the build system for your
application and should be checked into Version Control Systems. -->
<loadproperties srcFile="project.properties" />
<!-- quick check on sdk.dir -->
<fail
message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through an env var"
unless="sdk.dir"
/>
<!-- extension targets. Uncomment the ones where you want to do custom work
in between standard targets -->
<!--
<target name="-pre-build">
</target>
<target name="-pre-compile">
</target>
/* This is typically used for code obfuscation.
Compiled code location: ${out.classes.absolute.dir}
If this is not done in place, override ${out.dex.input.absolute.dir} */
<target name="-post-compile">
</target>
-->
<!-- Import the actual build file.
To customize existing targets, there are two options:
- Customize only one target:
- copy/paste the target into this file, *before* the
<import> task.
- customize it to your needs.
- Customize the whole content of build.xml
- copy/paste the content of the rules files (minus the top node)
into this file, replacing the <import> task.
- customize to your needs.
***********************
****** IMPORTANT ******
***********************
In all cases you must update the value of version-tag below to read 'custom' instead of an integer,
in order to avoid having your file be overridden by tools such as "android update project"
-->
<!-- version-tag: 1 -->
<import file="${sdk.dir}/tools/ant/build.xml" />
</project>

View File

@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

View File

@ -0,0 +1,11 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
# Project target.
target=android-15

View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<FrameLayout
android:id="@+id/cameraPreview"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="1"
/>
<TextView
android:id="@+id/scanText"
android:text="Scanning..."
android:layout_height="wrap_content"
android:layout_width="match_parent">
</TextView>
<Button
android:id="@+id/ScanButton"
android:text="Scan"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
/>
</LinearLayout>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ZBar CameraTest</string>
</resources>

View File

@ -0,0 +1,108 @@
/*
* Barebones implementation of displaying camera preview.
*
* Created by lisah0 on 2012-02-24
*/
package net.sourceforge.zbar.android.CameraTest;
import java.io.IOException;
import android.app.Activity;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.view.Surface;
import android.view.SurfaceView;
import android.view.SurfaceHolder;
import android.content.Context;
import android.hardware.Camera;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.Parameters;
/** A basic Camera preview class */
public class CameraPreview extends SurfaceView implements SurfaceHolder.Callback {
private SurfaceHolder mHolder;
private Camera mCamera;
private PreviewCallback previewCallback;
private AutoFocusCallback autoFocusCallback;
public CameraPreview(Context context, Camera camera,
PreviewCallback previewCb,
AutoFocusCallback autoFocusCb) {
super(context);
mCamera = camera;
previewCallback = previewCb;
autoFocusCallback = autoFocusCb;
/*
* Set camera to continuous focus if supported, otherwise use
* software auto-focus. Only works for API level >=9.
*/
/*
Camera.Parameters parameters = camera.getParameters();
for (String f : parameters.getSupportedFocusModes()) {
if (f == Parameters.FOCUS_MODE_CONTINUOUS_PICTURE) {
mCamera.setFocusMode(Parameters.FOCUS_MODE_CONTINUOUS_PICTURE);
autoFocusCallback = null;
break;
}
}
*/
// Install a SurfaceHolder.Callback so we get notified when the
// underlying surface is created and destroyed.
mHolder = getHolder();
mHolder.addCallback(this);
// deprecated setting, but required on Android versions prior to 3.0
mHolder.setType(SurfaceHolder.SURFACE_TYPE_PUSH_BUFFERS);
}
public void surfaceCreated(SurfaceHolder holder) {
// The Surface has been created, now tell the camera where to draw the preview.
try {
mCamera.setPreviewDisplay(holder);
} catch (IOException e) {
Log.d("DBG", "Error setting camera preview: " + e.getMessage());
}
}
public void surfaceDestroyed(SurfaceHolder holder) {
// Camera preview released in activity
}
public void surfaceChanged(SurfaceHolder holder, int format, int width, int height) {
/*
* If your preview can change or rotate, take care of those events here.
* Make sure to stop the preview before resizing or reformatting it.
*/
if (mHolder.getSurface() == null){
// preview surface does not exist
return;
}
// stop preview before making changes
try {
mCamera.stopPreview();
} catch (Exception e){
// ignore: tried to stop a non-existent preview
}
try {
// Hard code camera surface rotation 90 degs to match Activity view in portrait
mCamera.setDisplayOrientation(90);
mCamera.setPreviewDisplay(mHolder);
mCamera.setPreviewCallback(previewCallback);
mCamera.startPreview();
mCamera.autoFocus(autoFocusCallback);
} catch (Exception e){
Log.d("DBG", "Error starting camera preview: " + e.getMessage());
}
}
}

View File

@ -0,0 +1,155 @@
/*
* Basic no frills app which integrates the ZBar barcode scanner with
* the camera.
*
* Created by lisah0 on 2012-02-24
*/
package net.sourceforge.zbar.android.CameraTest;
import net.sourceforge.zbar.android.CameraTest.CameraPreview;
import android.app.Activity;
import android.content.pm.ActivityInfo;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.Window;
import android.widget.FrameLayout;
import android.widget.Button;
import android.hardware.Camera;
import android.hardware.Camera.PreviewCallback;
import android.hardware.Camera.AutoFocusCallback;
import android.hardware.Camera.Parameters;
import android.hardware.Camera.Size;
import android.widget.TextView;
import android.graphics.ImageFormat;
/* Import ZBar Class files */
import net.sourceforge.zbar.ImageScanner;
import net.sourceforge.zbar.Image;
import net.sourceforge.zbar.Symbol;
import net.sourceforge.zbar.SymbolSet;
import net.sourceforge.zbar.Config;
public class CameraTestActivity extends Activity
{
private Camera mCamera;
private CameraPreview mPreview;
private Handler autoFocusHandler;
TextView scanText;
Button scanButton;
ImageScanner scanner;
private boolean barcodeScanned = false;
private boolean previewing = true;
static {
System.loadLibrary("iconv");
}
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
autoFocusHandler = new Handler();
mCamera = getCameraInstance();
/* Instance barcode scanner */
scanner = new ImageScanner();
scanner.setConfig(0, Config.X_DENSITY, 3);
scanner.setConfig(0, Config.Y_DENSITY, 3);
mPreview = new CameraPreview(this, mCamera, previewCb, autoFocusCB);
FrameLayout preview = (FrameLayout)findViewById(R.id.cameraPreview);
preview.addView(mPreview);
scanText = (TextView)findViewById(R.id.scanText);
scanButton = (Button)findViewById(R.id.ScanButton);
scanButton.setOnClickListener(new OnClickListener() {
public void onClick(View v) {
if (barcodeScanned) {
barcodeScanned = false;
scanText.setText("Scanning...");
mCamera.setPreviewCallback(previewCb);
mCamera.startPreview();
previewing = true;
mCamera.autoFocus(autoFocusCB);
}
}
});
}
public void onPause() {
super.onPause();
releaseCamera();
}
/** A safe way to get an instance of the Camera object. */
public static Camera getCameraInstance(){
Camera c = null;
try {
c = Camera.open();
} catch (Exception e){
}
return c;
}
private void releaseCamera() {
if (mCamera != null) {
previewing = false;
mCamera.setPreviewCallback(null);
mCamera.release();
mCamera = null;
}
}
private Runnable doAutoFocus = new Runnable() {
public void run() {
if (previewing)
mCamera.autoFocus(autoFocusCB);
}
};
PreviewCallback previewCb = new PreviewCallback() {
public void onPreviewFrame(byte[] data, Camera camera) {
Camera.Parameters parameters = camera.getParameters();
Size size = parameters.getPreviewSize();
Image barcode = new Image(size.width, size.height, "Y800");
barcode.setData(data);
int result = scanner.scanImage(barcode);
if (result != 0) {
previewing = false;
mCamera.setPreviewCallback(null);
mCamera.stopPreview();
SymbolSet syms = scanner.getResults();
for (Symbol sym : syms) {
scanText.setText("barcode result " + sym.getData());
barcodeScanned = true;
}
}
}
};
// Mimic continuous auto-focusing
AutoFocusCallback autoFocusCB = new AutoFocusCallback() {
public void onAutoFocus(boolean success, Camera camera) {
autoFocusHandler.postDelayed(doAutoFocus, 1000);
}
};
}

76
android/jni/Android.mk Normal file
View File

@ -0,0 +1,76 @@
#
# Android NDK makefile
#
# build - <ndk path>/ndk-build ICONV_SRC=<iconv library src>
# clean - <ndk path>/ndk-build clean
#
MY_LOCAL_PATH := $(call my-dir)
# libiconv
include $(CLEAR_VARS)
LOCAL_PATH := $(ICONV_SRC)
LOCAL_MODULE := libiconv
LOCAL_CFLAGS := \
-Wno-multichar \
-D_ANDROID \
-DLIBDIR="c" \
-DBUILDING_LIBICONV \
-DBUILDING_LIBCHARSET \
-DIN_LIBRARY
LOCAL_SRC_FILES := \
lib/iconv.c \
libcharset/lib/localcharset.c \
lib/relocatable.c
LOCAL_C_INCLUDES := \
$(ICONV_SRC)/include \
$(ICONV_SRC)/libcharset \
$(ICONV_SRC)/libcharset/include
include $(BUILD_SHARED_LIBRARY)
LOCAL_LDLIBS := -llog -lcharset
# libzbarjni
include $(CLEAR_VARS)
LOCAL_PATH := $(MY_LOCAL_PATH)
LOCAL_MODULE := zbarjni
LOCAL_SRC_FILES := ../../java/zbarjni.c \
../../zbar/img_scanner.c \
../../zbar/decoder.c \
../../zbar/image.c \
../../zbar/symbol.c \
../../zbar/convert.c \
../../zbar/config.c \
../../zbar/scanner.c \
../../zbar/error.c \
../../zbar/refcnt.c \
../../zbar/video.c \
../../zbar/video/null.c \
../../zbar/decoder/code128.c \
../../zbar/decoder/code39.c \
../../zbar/decoder/code93.c \
../../zbar/decoder/codabar.c \
../../zbar/decoder/databar.c \
../../zbar/decoder/ean.c \
../../zbar/decoder/i25.c \
../../zbar/decoder/qr_finder.c \
../../zbar/qrcode/bch15_5.c \
../../zbar/qrcode/binarize.c \
../../zbar/qrcode/isaac.c \
../../zbar/qrcode/qrdec.c \
../../zbar/qrcode/qrdectxt.c \
../../zbar/qrcode/rs.c \
../../zbar/qrcode/util.c
LOCAL_C_INCLUDES := ../include \
../zbar \
$(ICONV_SRC)/include
LOCAL_SHARED_LIBRARIES := libiconv
include $(BUILD_SHARED_LIBRARY)

View File

@ -0,0 +1 @@
APP_ABI := armeabi armeabi-v7a x86

239
android/jni/config.h Normal file
View File

@ -0,0 +1,239 @@
/* manually customized for iPhone platform */
#define HAVE_LANGINFO_CODESET 0
/* whether to build support for Code 128 symbology */
#define ENABLE_CODE128 1
/* whether to build support for Code 93 symbology */
#define ENABLE_CODE93 1
/* whether to build support for Code 39 symbology */
#define ENABLE_CODE39 1
/* whether to build support for Codabar symbology */
#define ENABLE_CODABAR 1
/* whether to build support for DataBar symbology */
#define ENABLE_DATABAR 1
/* whether to build support for EAN symbologies */
#define ENABLE_EAN 1
/* whether to build support for Interleaved 2 of 5 symbology */
#define ENABLE_I25 1
/* whether to build support for PDF417 symbology */
#undef ENABLE_PDF417
/* whether to build support for QR Code */
#define ENABLE_QRCODE 1
/* Define to 1 if you have the `atexit' function. */
#undef HAVE_ATEXIT
/* Define to 1 if you have the <dlfcn.h> header file. */
#undef HAVE_DLFCN_H
/* Define to 1 if you have the <fcntl.h> header file. */
#undef HAVE_FCNTL_H
/* Define to 1 if you have the <features.h> header file. */
#undef HAVE_FEATURES_H
/* Define to 1 if you have the `getpagesize' function. */
#undef HAVE_GETPAGESIZE
/* Define if you have the iconv() function and it works. */
#undef HAVE_ICONV
/* Define to 1 if you have the <inttypes.h> header file. */
#define HAVE_INTTYPES_H 1
/* Define to 1 if you have the <jpeglib.h> header file. */
#undef HAVE_JPEGLIB_H
/* Define to 1 if you have the `jpeg' library (-ljpeg). */
#undef HAVE_LIBJPEG
/* Define to 1 if you have the `pthread' library (-lpthread). */
#undef HAVE_LIBPTHREAD
/* Define to 1 if you have the <linux/videodev2.h> header file. */
#undef HAVE_LINUX_VIDEODEV2_H
/* Define to 1 if you have the <linux/videodev.h> header file. */
#undef HAVE_LINUX_VIDEODEV_H
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H
/* Define to 1 if you have the `memset' function. */
#define HAVE_MEMSET 1
/* Define to 1 if you have a working `mmap' system call. */
#undef HAVE_MMAP
/* Define to 1 if you have the <poll.h> header file. */
#undef HAVE_POLL_H
/* Define to 1 if you have the <pthread.h> header file. */
#undef HAVE_PTHREAD_H
/* Define to 1 if you have the `setenv' function. */
#undef HAVE_SETENV
/* Define to 1 if you have the <stdint.h> header file. */
#define HAVE_STDINT_H 1
/* Define to 1 if you have the <stdlib.h> header file. */
#define HAVE_STDLIB_H 1
/* Define to 1 if you have the <strings.h> header file. */
#define HAVE_STRINGS_H 1
/* Define to 1 if you have the <string.h> header file. */
#define HAVE_STRING_H 1
/* Define to 1 if you have the <sys/ioctl.h> header file. */
#undef HAVE_SYS_IOCTL_H
/* Define to 1 if you have the <sys/ipc.h> header file. */
#undef HAVE_SYS_IPC_H
/* Define to 1 if you have the <sys/mman.h> header file. */
#undef HAVE_SYS_MMAN_H
/* Define to 1 if you have the <sys/shm.h> header file. */
#undef HAVE_SYS_SHM_H
/* Define to 1 if you have the <sys/stat.h> header file. */
#define HAVE_SYS_STAT_H 1
/* Define to 1 if you have the <sys/times.h> header file. */
#define HAVE_SYS_TIMES_H 1
/* Define to 1 if you have the <sys/time.h> header file. */
#define HAVE_SYS_TIME_H 1
/* Define to 1 if you have the <sys/types.h> header file. */
#define HAVE_SYS_TYPES_H 1
/* Define to 1 if the system has the type `uintptr_t'. */
#define HAVE_UINTPTR_T 1
/* Define to 1 if you have the <unistd.h> header file. */
#define HAVE_UNISTD_H 1
/* Define to 1 if you have the <vfw.h> header file. */
#undef HAVE_VFW_H
/* Define to 1 if you have the <X11/extensions/XShm.h> header file. */
#undef HAVE_X11_EXTENSIONS_XSHM_H
/* Define to 1 if you have the <X11/extensions/Xvlib.h> header file. */
#undef HAVE_X11_EXTENSIONS_XVLIB_H
/* Define as const if the declaration of iconv() needs const. */
#undef ICONV_CONST
/* Library major version */
#define LIB_VERSION_MAJOR 0
/* Library minor version */
#define LIB_VERSION_MINOR 2
/* Library revision */
#define LIB_VERSION_REVISION 0
/* Define to the sub-directory in which libtool stores uninstalled libraries.
*/
#undef LT_OBJDIR
/* Define to 1 if assertions should be disabled. */
//#undef NDEBUG
/* Define to 1 if your C compiler doesn't accept -c and -o together. */
#undef NO_MINUS_C_MINUS_O
/* Name of package */
#define PACKAGE "zbar"
/* Define to the address where bug reports for this package should be sent. */
#define PACKAGE_BUGREPORT "spadix@users.sourceforge.net"
/* Define to the full name of this package. */
#define PACKAGE_NAME "zbar"
/* Define to the full name and version of this package. */
#define PACKAGE_STRING "zbar 0.10"
/* Define to the one symbol short name of this package. */
#define PACKAGE_TARNAME "zbar"
/* Define to the version of this package. */
#define PACKAGE_VERSION "0.10"
/* Define to 1 if you have the ANSI C header files. */
#define STDC_HEADERS 1
/* Version number of package */
#define VERSION "0.10"
/* Define to 1 if the X Window System is missing or not being used. */
#define X_DISPLAY_MISSING 1
/* Program major version (before the '.') as a number */
#define ZBAR_VERSION_MAJOR 0
/* Program minor version (after '.') as a number */
#define ZBAR_VERSION_MINOR 10
/* Program minor version (after the second '.') as a number */
#define ZBAR_VERSION_PATCH 0
/* Define for Solaris 2.5.1 so the uint32_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT32_T
/* Define for Solaris 2.5.1 so the uint8_t typedef from <sys/synch.h>,
<pthread.h>, or <semaphore.h> is not used. If the typedef were allowed, the
#define below would cause a syntax error. */
#undef _UINT8_T
/* Minimum Windows API version */
#undef _WIN32_WINNT
/* used only for pthread debug attributes */
#undef __USE_UNIX98
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
/* Define to `__inline__' or `__inline' if that's what the C compiler
calls it, or to nothing if 'inline' is not supported under any name. */
#ifndef __cplusplus
#undef inline
#endif
/* Define to the type of a signed integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef int32_t
/* Define to the type of an unsigned integer type of width exactly 32 bits if
such a type exists and the standard includes do not define it. */
#undef uint32_t
/* Define to the type of an unsigned integer type of width exactly 8 bits if
such a type exists and the standard includes do not define it. */
#undef uint8_t
/* Define to the type of an unsigned integer type wide enough to hold a
pointer, if such a type exists, and if the system does not define it. */
#undef uintptr_t
#ifndef X_DISPLAY_MISSING
# define HAVE_X
#endif

40
android/proguard.cfg Normal file
View File

@ -0,0 +1,40 @@
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
native <methods>;
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.app.Activity {
public void *(android.view.View);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}

View File

@ -0,0 +1,12 @@
# This file is automatically generated by Android Tools.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must be checked in Version Control Systems.
#
# To customize properties used by the Ant build system use,
# "ant.properties", and override values to adapt the script to your
# project structure.
android.library=true
# Project target.
target=android-8

View File

@ -0,0 +1,13 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
>
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Hello World, ACTIVITY_ENTRY_NAME"
/>
</LinearLayout>

View File

@ -0,0 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<resources>
<string name="app_name">ACTIVITY_ENTRY_NAME</string>
</resources>

0
config/.keep Normal file
View File

684
config/config.rpath Executable file
View File

@ -0,0 +1,684 @@
#! /bin/sh
# Output a system dependent set of variables, describing how to set the
# run time search path of shared libraries in an executable.
#
# Copyright 1996-2020 Free Software Foundation, Inc.
# Taken from GNU libtool, 2001
# Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
#
# This file is free software; the Free Software Foundation gives
# unlimited permission to copy and/or distribute it, with or without
# modifications, as long as this notice is preserved.
#
# The first argument passed to this file is the canonical host specification,
# CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM
# or
# CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM
# The environment variables CC, GCC, LDFLAGS, LD, with_gnu_ld
# should be set by the caller.
#
# The set of defined variables is at the end of this script.
# Known limitations:
# - On IRIX 6.5 with CC="cc", the run time search patch must not be longer
# than 256 bytes, otherwise the compiler driver will dump core. The only
# known workaround is to choose shorter directory names for the build
# directory and/or the installation directory.
# All known linkers require a '.a' archive for static linking (except MSVC,
# which needs '.lib').
libext=a
shrext=.so
host="$1"
host_cpu=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'`
host_vendor=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'`
host_os=`echo "$host" | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'`
# Code taken from libtool.m4's _LT_CC_BASENAME.
for cc_temp in $CC""; do
case $cc_temp in
compile | *[\\/]compile | ccache | *[\\/]ccache ) ;;
distcc | *[\\/]distcc | purify | *[\\/]purify ) ;;
\-*) ;;
*) break;;
esac
done
cc_basename=`echo "$cc_temp" | sed -e 's%^.*/%%'`
# Code taken from libtool.m4's _LT_COMPILER_PIC.
wl=
if test "$GCC" = yes; then
wl='-Wl,'
else
case "$host_os" in
aix*)
wl='-Wl,'
;;
mingw* | cygwin* | pw32* | os2* | cegcc*)
;;
hpux9* | hpux10* | hpux11*)
wl='-Wl,'
;;
irix5* | irix6* | nonstopux*)
wl='-Wl,'
;;
linux* | k*bsd*-gnu | kopensolaris*-gnu)
case $cc_basename in
ecc*)
wl='-Wl,'
;;
icc* | ifort*)
wl='-Wl,'
;;
lf95*)
wl='-Wl,'
;;
nagfor*)
wl='-Wl,-Wl,,'
;;
pgcc* | pgf77* | pgf90* | pgf95* | pgfortran*)
wl='-Wl,'
;;
ccc*)
wl='-Wl,'
;;
xl* | bgxl* | bgf* | mpixl*)
wl='-Wl,'
;;
como)
wl='-lopt='
;;
*)
case `$CC -V 2>&1 | sed 5q` in
*Sun\ F* | *Sun*Fortran*)
wl=
;;
*Sun\ C*)
wl='-Wl,'
;;
esac
;;
esac
;;
newsos6)
;;
*nto* | *qnx*)
;;
osf3* | osf4* | osf5*)
wl='-Wl,'
;;
rdos*)
;;
solaris*)
case $cc_basename in
f77* | f90* | f95* | sunf77* | sunf90* | sunf95*)
wl='-Qoption ld '
;;
*)
wl='-Wl,'
;;
esac
;;
sunos4*)
wl='-Qoption ld '
;;
sysv4 | sysv4.2uw2* | sysv4.3*)
wl='-Wl,'
;;
sysv4*MP*)
;;
sysv5* | unixware* | sco3.2v5* | sco5v6* | OpenUNIX*)
wl='-Wl,'
;;
unicos*)
wl='-Wl,'
;;
uts4*)
;;
esac
fi
# Code taken from libtool.m4's _LT_LINKER_SHLIBS.
hardcode_libdir_flag_spec=
hardcode_libdir_separator=
hardcode_direct=no
hardcode_minus_L=no
case "$host_os" in
cygwin* | mingw* | pw32* | cegcc*)
# FIXME: the MSVC++ port hasn't been tested in a loooong time
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
if test "$GCC" != yes; then
with_gnu_ld=no
fi
;;
interix*)
# we just hope/assume this is gcc and not c89 (= MSVC++)
with_gnu_ld=yes
;;
openbsd*)
with_gnu_ld=no
;;
esac
ld_shlibs=yes
if test "$with_gnu_ld" = yes; then
# Set some defaults for GNU ld with shared library support. These
# are reset later if shared libraries are not supported. Putting them
# here allows them to be overridden if necessary.
# Unlike libtool, we use -rpath here, not --rpath, since the documented
# option of GNU ld is called -rpath, not --rpath.
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
case "$host_os" in
aix[3-9]*)
# On AIX/PPC, the GNU linker is very broken
if test "$host_cpu" != ia64; then
ld_shlibs=no
fi
;;
amigaos*)
case "$host_cpu" in
powerpc)
;;
m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;;
beos*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
cygwin* | mingw* | pw32* | cegcc*)
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec='-L$libdir'
if $LD --help 2>&1 | grep 'auto-import' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
haiku*)
;;
interix[3-9]*)
hardcode_direct=no
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
gnu* | linux* | tpf* | k*bsd*-gnu | kopensolaris*-gnu)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
netbsd*)
;;
solaris*)
if $LD -v 2>&1 | grep 'BFD 2\.8' > /dev/null; then
ld_shlibs=no
elif $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX*)
case `$LD -v 2>&1` in
*\ [01].* | *\ 2.[0-9].* | *\ 2.1[0-5].*)
ld_shlibs=no
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-rpath,$libdir`'
else
ld_shlibs=no
fi
;;
esac
;;
sunos4*)
hardcode_direct=yes
;;
*)
if $LD --help 2>&1 | grep ': supported targets:.* elf' > /dev/null; then
:
else
ld_shlibs=no
fi
;;
esac
if test "$ld_shlibs" = no; then
hardcode_libdir_flag_spec=
fi
else
case "$host_os" in
aix3*)
# Note: this linker hardcodes the directories in LIBPATH if there
# are no directories specified by -L.
hardcode_minus_L=yes
if test "$GCC" = yes; then
# Neither direct hardcoding nor static linking is supported with a
# broken collect2.
hardcode_direct=unsupported
fi
;;
aix[4-9]*)
if test "$host_cpu" = ia64; then
# On IA64, the linker does run time linking by default, so we don't
# have to do anything special.
aix_use_runtimelinking=no
else
aix_use_runtimelinking=no
# Test if we are trying to use run time linking or normal
# AIX style linking. If -brtl is somewhere in LDFLAGS, we
# need to do runtime linking.
case $host_os in aix4.[23]|aix4.[23].*|aix[5-9]*)
for ld_flag in $LDFLAGS; do
if (test $ld_flag = "-brtl" || test $ld_flag = "-Wl,-brtl"); then
aix_use_runtimelinking=yes
break
fi
done
;;
esac
fi
hardcode_direct=yes
hardcode_libdir_separator=':'
if test "$GCC" = yes; then
case $host_os in aix4.[012]|aix4.[012].*)
collect2name=`${CC} -print-prog-name=collect2`
if test -f "$collect2name" && \
strings "$collect2name" | grep resolve_lib_name >/dev/null
then
# We have reworked collect2
:
else
# We have old collect2
hardcode_direct=unsupported
hardcode_minus_L=yes
hardcode_libdir_flag_spec='-L$libdir'
hardcode_libdir_separator=
fi
;;
esac
fi
# Begin _LT_AC_SYS_LIBPATH_AIX.
echo 'int main () { return 0; }' > conftest.c
${CC} ${LDFLAGS} conftest.c -o conftest
aix_libpath=`dump -H conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
if test -z "$aix_libpath"; then
aix_libpath=`dump -HX64 conftest 2>/dev/null | sed -n -e '/Import File Strings/,/^$/ { /^0/ { s/^0 *\(.*\)$/\1/; p; }
}'`
fi
if test -z "$aix_libpath"; then
aix_libpath="/usr/lib:/lib"
fi
rm -f conftest.c conftest
# End _LT_AC_SYS_LIBPATH_AIX.
if test "$aix_use_runtimelinking" = yes; then
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
else
if test "$host_cpu" = ia64; then
hardcode_libdir_flag_spec='${wl}-R $libdir:/usr/lib:/lib'
else
hardcode_libdir_flag_spec='${wl}-blibpath:$libdir:'"$aix_libpath"
fi
fi
;;
amigaos*)
case "$host_cpu" in
powerpc)
;;
m68k)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
esac
;;
bsdi[45]*)
;;
cygwin* | mingw* | pw32* | cegcc*)
# When not using gcc, we currently assume that we are using
# Microsoft Visual C++.
# hardcode_libdir_flag_spec is actually meaningless, as there is
# no search path for DLLs.
hardcode_libdir_flag_spec=' '
libext=lib
;;
darwin* | rhapsody*)
hardcode_direct=no
if { case $cc_basename in ifort*) true;; *) test "$GCC" = yes;; esac; }; then
:
else
ld_shlibs=no
fi
;;
dgux*)
hardcode_libdir_flag_spec='-L$libdir'
;;
freebsd2.[01]*)
hardcode_direct=yes
hardcode_minus_L=yes
;;
freebsd* | dragonfly*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
hpux9*)
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
hpux10*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
fi
;;
hpux11*)
if test "$with_gnu_ld" = no; then
hardcode_libdir_flag_spec='${wl}+b ${wl}$libdir'
hardcode_libdir_separator=:
case $host_cpu in
hppa*64*|ia64*)
hardcode_direct=no
;;
*)
hardcode_direct=yes
# hardcode_minus_L: Not really in the search PATH,
# but as the default location of the library.
hardcode_minus_L=yes
;;
esac
fi
;;
irix5* | irix6* | nonstopux*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
netbsd*)
hardcode_libdir_flag_spec='-R$libdir'
hardcode_direct=yes
;;
newsos6)
hardcode_direct=yes
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
*nto* | *qnx*)
;;
openbsd*)
if test -f /usr/libexec/ld.so; then
hardcode_direct=yes
if test -z "`echo __ELF__ | $CC -E - | grep __ELF__`" || test "$host_os-$host_cpu" = "openbsd2.8-powerpc"; then
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
else
case "$host_os" in
openbsd[01].* | openbsd2.[0-7] | openbsd2.[0-7].*)
hardcode_libdir_flag_spec='-R$libdir'
;;
*)
hardcode_libdir_flag_spec='${wl}-rpath,$libdir'
;;
esac
fi
else
ld_shlibs=no
fi
;;
os2*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_minus_L=yes
;;
osf3*)
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
hardcode_libdir_separator=:
;;
osf4* | osf5*)
if test "$GCC" = yes; then
hardcode_libdir_flag_spec='${wl}-rpath ${wl}$libdir'
else
# Both cc and cxx compiler support -rpath directly
hardcode_libdir_flag_spec='-rpath $libdir'
fi
hardcode_libdir_separator=:
;;
solaris*)
hardcode_libdir_flag_spec='-R$libdir'
;;
sunos4*)
hardcode_libdir_flag_spec='-L$libdir'
hardcode_direct=yes
hardcode_minus_L=yes
;;
sysv4)
case $host_vendor in
sni)
hardcode_direct=yes # is this really true???
;;
siemens)
hardcode_direct=no
;;
motorola)
hardcode_direct=no #Motorola manual says yes, but my tests say they lie
;;
esac
;;
sysv4.3*)
;;
sysv4*MP*)
if test -d /usr/nec; then
ld_shlibs=yes
fi
;;
sysv4*uw2* | sysv5OpenUNIX* | sysv5UnixWare7.[01].[10]* | unixware7* | sco3.2v5.0.[024]*)
;;
sysv5* | sco3.2v5* | sco5v6*)
hardcode_libdir_flag_spec='`test -z "$SCOABSPATH" && echo ${wl}-R,$libdir`'
hardcode_libdir_separator=':'
;;
uts4*)
hardcode_libdir_flag_spec='-L$libdir'
;;
*)
ld_shlibs=no
;;
esac
fi
# Check dynamic linker characteristics
# Code taken from libtool.m4's _LT_SYS_DYNAMIC_LINKER.
# Unlike libtool.m4, here we don't care about _all_ names of the library, but
# only about the one the linker finds when passed -lNAME. This is the last
# element of library_names_spec in libtool.m4, or possibly two of them if the
# linker has special search rules.
library_names_spec= # the last element of library_names_spec in libtool.m4
libname_spec='lib$name'
case "$host_os" in
aix3*)
library_names_spec='$libname.a'
;;
aix[4-9]*)
library_names_spec='$libname$shrext'
;;
amigaos*)
case "$host_cpu" in
powerpc*)
library_names_spec='$libname$shrext' ;;
m68k)
library_names_spec='$libname.a' ;;
esac
;;
beos*)
library_names_spec='$libname$shrext'
;;
bsdi[45]*)
library_names_spec='$libname$shrext'
;;
cygwin* | mingw* | pw32* | cegcc*)
shrext=.dll
library_names_spec='$libname.dll.a $libname.lib'
;;
darwin* | rhapsody*)
shrext=.dylib
library_names_spec='$libname$shrext'
;;
dgux*)
library_names_spec='$libname$shrext'
;;
freebsd[23].*)
library_names_spec='$libname$shrext$versuffix'
;;
freebsd* | dragonfly*)
library_names_spec='$libname$shrext'
;;
gnu*)
library_names_spec='$libname$shrext'
;;
haiku*)
library_names_spec='$libname$shrext'
;;
hpux9* | hpux10* | hpux11*)
case $host_cpu in
ia64*)
shrext=.so
;;
hppa*64*)
shrext=.sl
;;
*)
shrext=.sl
;;
esac
library_names_spec='$libname$shrext'
;;
interix[3-9]*)
library_names_spec='$libname$shrext'
;;
irix5* | irix6* | nonstopux*)
library_names_spec='$libname$shrext'
case "$host_os" in
irix5* | nonstopux*)
libsuff= shlibsuff=
;;
*)
case $LD in
*-32|*"-32 "|*-melf32bsmip|*"-melf32bsmip ") libsuff= shlibsuff= ;;
*-n32|*"-n32 "|*-melf32bmipn32|*"-melf32bmipn32 ") libsuff=32 shlibsuff=N32 ;;
*-64|*"-64 "|*-melf64bmip|*"-melf64bmip ") libsuff=64 shlibsuff=64 ;;
*) libsuff= shlibsuff= ;;
esac
;;
esac
;;
linux*oldld* | linux*aout* | linux*coff*)
;;
linux* | k*bsd*-gnu | kopensolaris*-gnu)
library_names_spec='$libname$shrext'
;;
knetbsd*-gnu)
library_names_spec='$libname$shrext'
;;
netbsd*)
library_names_spec='$libname$shrext'
;;
newsos6)
library_names_spec='$libname$shrext'
;;
*nto* | *qnx*)
library_names_spec='$libname$shrext'
;;
openbsd*)
library_names_spec='$libname$shrext$versuffix'
;;
os2*)
libname_spec='$name'
shrext=.dll
library_names_spec='$libname.a'
;;
osf3* | osf4* | osf5*)
library_names_spec='$libname$shrext'
;;
rdos*)
;;
solaris*)
library_names_spec='$libname$shrext'
;;
sunos4*)
library_names_spec='$libname$shrext$versuffix'
;;
sysv4 | sysv4.3*)
library_names_spec='$libname$shrext'
;;
sysv4*MP*)
library_names_spec='$libname$shrext'
;;
sysv5* | sco3.2v5* | sco5v6* | unixware* | OpenUNIX* | sysv4*uw2*)
library_names_spec='$libname$shrext'
;;
tpf*)
library_names_spec='$libname$shrext'
;;
uts4*)
library_names_spec='$libname$shrext'
;;
esac
sed_quote_subst='s/\(["`$\\]\)/\\\1/g'
escaped_wl=`echo "X$wl" | sed -e 's/^X//' -e "$sed_quote_subst"`
shlibext=`echo "$shrext" | sed -e 's,^\.,,'`
escaped_libname_spec=`echo "X$libname_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_library_names_spec=`echo "X$library_names_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
escaped_hardcode_libdir_flag_spec=`echo "X$hardcode_libdir_flag_spec" | sed -e 's/^X//' -e "$sed_quote_subst"`
LC_ALL=C sed -e 's/^\([a-zA-Z0-9_]*\)=/acl_cv_\1=/' <<EOF
# How to pass a linker flag through the compiler.
wl="$escaped_wl"
# Static library suffix (normally "a").
libext="$libext"
# Shared library suffix (normally "so").
shlibext="$shlibext"
# Format of library name prefix.
libname_spec="$escaped_libname_spec"
# Library names that the linker finds when passed -lNAME.
library_names_spec="$escaped_library_names_spec"
# Flag to hardcode \$libdir into a binary during linking.
# This must work even if \$libdir does not exist.
hardcode_libdir_flag_spec="$escaped_hardcode_libdir_flag_spec"
# Whether we need a single -rpath flag with a separated argument.
hardcode_libdir_separator="$hardcode_libdir_separator"
# Set to yes if using DIR/libNAME.so during linking hardcodes DIR into the
# resulting binary.
hardcode_direct="$hardcode_direct"
# Set to yes if using the -LDIR flag during linking hardcodes DIR into the
# resulting binary.
hardcode_minus_L="$hardcode_minus_L"
EOF

934
configure.ac Normal file
View File

@ -0,0 +1,934 @@
changecom()dnl
dnl Process this file with autoconf to produce a configure script.
AC_PREREQ([2.68])
AC_INIT([zbar], [0.23.92], [mchehab+huawei@kernel.org])
m4_ifndef([AC_LANG_DEFINES_PROVIDED],
[m4_define([AC_LANG_DEFINES_PROVIDED])])
AC_CONFIG_AUX_DIR(config)
AC_CONFIG_MACRO_DIR(config)
AM_INIT_AUTOMAKE([1.13 -Werror foreign subdir-objects std-options dist-bzip2])
m4_pattern_allow([AM_PROG_AR])
AC_CONFIG_HEADERS([include/config.h])
AC_CONFIG_SRCDIR(zbar/scanner.c)
LT_PREREQ([2.2])
LT_INIT([dlopen win32-dll])
LT_LANG([Windows Resource])
AM_SILENT_RULES([yes])
dnl update these just before each release (along w/package version above)
dnl LIB_VERSION update instructions copied from libtool docs:
dnl library version follows the form current:revision:age
dnl - If the library source code has changed at all since the last update,
dnl then increment revision (c:r:a becomes c:r+1:a).
dnl - If any interfaces have been added, removed, or changed,
dnl increment current, and set revision to 0.
dnl - If any interfaces have been added since the last public release,
dnl then increment age.
dnl - If any interfaces have been removed since the last public release,
dnl then set age to 0.
AC_SUBST([LIB_VERSION], [3:0:3])
AC_SUBST([RELDATE], [2017-04-11])
dnl widget libraries use their own versioning.
dnl NB pygtk wrapper is *unversioned*
AC_SUBST([ZGTK_LIB_VERSION], [0:2:0])
AC_SUBST([ZQT_LIB_VERSION], [1:2:1])
AC_DEFINE_UNQUOTED([ZBAR_VERSION_MAJOR],
[[`echo "$PACKAGE_VERSION" | sed -e 's/\..*$//'`]],
[Program major version (before the '.') as a number])
AC_DEFINE_UNQUOTED([ZBAR_VERSION_MINOR],
[[`echo "$PACKAGE_VERSION" | sed -e 's/^[^\.]*\.\([^\.]*\).*/\1/'`]],
[Program minor version (after '.') as a number])
AC_DEFINE_UNQUOTED([ZBAR_VERSION_PATCH],
[[`echo "$PACKAGE_VERSION" | sed -e 's/^[^\.]*\.[^\.]*\.*//' | sed s,^$,0,`]],
[Program patch version (after the second '.') as a number])
cur=`echo "$LIB_VERSION" | sed -e 's/:.*$//'`
age=`echo "$LIB_VERSION" | sed -e 's/^.*://'`
AC_DEFINE_UNQUOTED([LIB_VERSION_MAJOR], [[$(( $cur - $age ))]],
[Library major version])
AC_DEFINE_UNQUOTED([LIB_VERSION_MINOR], [[$age]],
[Library minor version])
AC_DEFINE_UNQUOTED([LIB_VERSION_REVISION],
[[`echo "$LIB_VERSION" | sed -e 's/^[^:]*:\([^:]*\):.*$/\1/'`]],
[Library revision])
AM_CPPFLAGS="-I\$(top_srcdir)/include"
AM_CFLAGS="-Wall -Wno-parentheses"
AM_CXXFLAGS="$AM_CFLAGS"
AC_SUBST([AM_CPPFLAGS])
AC_SUBST([AM_CFLAGS])
AC_SUBST([AM_CXXFLAGS])
dnl windows build
AC_CANONICAL_HOST
case $host_os in
*cygwin* | *mingw* | *uwin* | *djgpp* | *ems* )
win32="yes"
with_dbus="no"
AC_DEFINE([_WIN32_WINNT], [0x0500], [Minimum Windows API version])
AC_FUNC_ALLOCA
AC_FUNC_ERROR_AT_LINE
AC_FUNC_FSEEKO
AC_CHECK_HEADERS([arpa/inet.h malloc.h mntent.h netdb.h netinet/in.h shadow.h sys/file.h sys/mount.h sys/param.h sys/socket.h sys/statfs.h sys/statvfs.h sys/vfs.h unistd.h values.h])
;;
* )
win32="no"
;;
esac
AM_CONDITIONAL([WIN32], [test "x$win32" = "xyes"])
dnl programs
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CXX
AC_PROG_CC_STDC
PKG_PROG_PKG_CONFIG
dnl symbologies
AC_ARG_ENABLE([codes],
[AS_HELP_STRING([--enable-codes=SYMS],
[select symbologies to compile [default=ean,databar,code128,code93,code39,codabar,i25,qrcode,sqcode]])],
[],
[enable_codes="ean,databar,code128,code93,code39,codabar,i25,qrcode,sqcode"])
AC_DEFUN([AC_DEFINE_SUBST],
[AC_DEFINE($1,$2,$3)
AC_SUBST($1,$2)])
AC_DEFUN([ZBAR_CHK_CODE], [
AC_MSG_CHECKING([whether to build $2])
enable_$1="no"
AH_TEMPLATE([ENABLE_]translit($1, a-z, A-Z),
[whether to build support for $2])
AS_CASE([$enable_codes],
[*$1* | *all*],
[enable_$1="yes"
enabled_codes="$enabled_codes $1"
AC_DEFINE_SUBST([ENABLE_]translit($1, a-z, A-Z), [1])
], [
disabled_codes="$disabled_codes $1"
AC_DEFINE_SUBST([ENABLE_]translit($1, a-z, A-Z), [0])
])
AM_CONDITIONAL([ENABLE_]translit($1, a-z, A-Z),
[test "x$enable_$1" = "xyes"])
AC_MSG_RESULT([$enable_$1])
])dnl
ZBAR_CHK_CODE([ean], [EAN symbologies])
ZBAR_CHK_CODE([databar], [DataBar symbology])
ZBAR_CHK_CODE([code128], [Code 128 symbology])
ZBAR_CHK_CODE([code93], [Code 93 symbology])
ZBAR_CHK_CODE([code39], [Code 39 symbology])
ZBAR_CHK_CODE([codabar], [Codabar symbology])
ZBAR_CHK_CODE([i25], [Interleaved 2 of 5 symbology])
ZBAR_CHK_CODE([qrcode], [QR Code])
ZBAR_CHK_CODE([sqcode], [SQ Code])
ZBAR_CHK_CODE([pdf417], [PDF417 symbology (incomplete)])
dnl libraries
AC_SEARCH_LIBS([clock_gettime], [rt pthread])
AM_ICONV()
AM_GNU_GETTEXT([external])
AM_GNU_GETTEXT_VERSION(0.20)
AM_GNU_GETTEXT_REQUIRE_VERSION(0.18)
AM_CONDITIONAL([USE_NLS], [test "x${USE_NLS}" = "xyes"])
dnl libraries linkage
AC_ARG_ENABLE([static_qt],
[AS_HELP_STRING([--enable-static-qt],
[Produce a static library for libzbarcam-qt])])
AS_IF([test x$enable_static_qt = xyes], [AC_SUBST([LIBQT_EXTRA_LDFLAGS], ["-static"])])
dnl poll support
AC_CHECK_HEADERS([poll.h], [have_poll="yes"], [have_poll="no"])
AM_CONDITIONAL([HAVE_POLL], [test "x$have_poll" = "xyes"])
dnl pthreads
dnl FIXME this doesn't port well, integrate something like this:
dnl http://autoconf-archive.cryp.to/acx_pthread.html
AC_ARG_ENABLE([pthread],
[AS_HELP_STRING([--disable-pthread],
[omit support for threaded applications])],
[],
[AS_IF([test "x$win32" = "xno"],
[enable_pthread="yes"],
[enable_pthread="no"
])])
AS_IF([test "x$enable_pthread" != "xno"],
[AC_CHECK_HEADERS([pthread.h], [],
[AC_MSG_FAILURE([test for pthread support failed!
configure --disable-pthread to skip threaded support.])])
AC_CHECK_LIB([pthread], [pthread_create], [],
[AC_MSG_FAILURE([unable to link against -lpthread, although you
appear to have pthread.h? set LDFLAGS and/or LIBS to help the linker,
or configure --disable-pthread to skip threaded support.])])
AC_DEFINE([__USE_UNIX98], [1], [used only for pthread debug attributes])
])
dnl doc
AC_ARG_ENABLE([doc],
[AS_HELP_STRING([--disable-doc],
[disable building docs])],
[],
[enable_doc="yes"])
AS_IF([test "x$enable_doc" != "xno"],
[AC_ARG_VAR([XMLTO], [location of xmlto, used for optional documentation generation])
AC_ARG_VAR([XMLTOFLAGS], [additional arguments for xmlto])
AC_CHECK_PROGS([XMLTO], [xmlto])])
AS_IF([test "x$XMLTO" = "x"], enable_doc="no")
AM_CONDITIONAL([HAVE_DOC], [test "x$enable_doc" != "xno"])
dnl video
AC_ARG_ENABLE([video],
[AS_HELP_STRING([--disable-video],
[exclude video scanner features])],
[],
[enable_video="yes"])
dnl video, directshow
AC_ARG_WITH([directshow],
[AS_HELP_STRING([--with-directshow],
[compile directshow driver on windows instead of vfw,
available only when video support is enabled])],
[],
[with_directshow="no"])
have_v4l1="no"
have_v4l2="no"
have_libv4l="no"
AS_IF([test "x$enable_video" = "xno"],
[],
[test "x$win32" = "xno"],
[AC_CHECK_HEADERS([linux/videodev.h], [have_v4l1="yes"])
AC_CHECK_HEADERS([linux/videodev2.h], [have_v4l2="yes"])
AC_CHECK_HEADERS([libv4l2.h], [have_libv4l="yes"])
AS_IF([test "x$have_v4l2" = "xno" && test "x$have_v4l1" = "xno"],
[AC_MSG_FAILURE([test for video support failed!
rebuild your kernel to include video4linux support or
configure --disable-video to skip building video support.])],
[AS_IF([test "x$have_v4l2" = "xno"],
[AC_MSG_WARN([v4l2 API not detected, upgrade your kernel!])])]
)],
[AS_IF([test "x$with_directshow" != "xno"],
[with_video="directshow"],
[AC_CHECK_HEADERS([vfw.h], [with_video="vfw"],
[AC_MSG_FAILURE([test for VfW video support failed!
configure --disable-video to skip building video support.])],[#include <windows.h>])])])
AS_IF([test "x$have_libv4l" = "xyes"],
[PKG_CHECK_MODULES([V4L2], [libv4l2], [],
[AC_MSG_FAILURE([unable to find libv4l2.so])])],
[AC_MSG_WARN([libv4l not detected. Install it to support more cameras!])])
AM_CONDITIONAL([HAVE_VIDEO], [test "x$enable_video" != "xno"])
AM_CONDITIONAL([HAVE_V4L1], [test "x$have_v4l1" != "xno"])
AM_CONDITIONAL([HAVE_V4L2], [test "x$have_v4l2" != "xno"])
AM_CONDITIONAL([HAVE_LIBV4L], [test "x$have_libv4l" != "xno"])
AM_CONDITIONAL([WITH_DIRECTSHOW], [test "x$with_directshow" != "xno"])
dnl X
AC_ARG_VAR([XSHM_LIBS], [linker flags for X shared memory extension])
AS_IF([test "x$win32" != "xno"],
[have_x="no"],
[AC_PATH_XTRA
AH_BOTTOM([#ifndef X_DISPLAY_MISSING
# define HAVE_X
#endif
])])
AM_CONDITIONAL([HAVE_X], [test "x$have_x" = "xyes"])
AS_IF([test "x$XSHM_LIBS" = "x"], [XSHM_LIBS="-lXext"])
AC_ARG_WITH([xshm],
[AS_HELP_STRING([--without-xshm],
[disable support for X shared memory extension])],
[],
[with_xshm="check"])
AS_IF([test "x$with_xshm" != "xno"],
[AC_CHECK_HEADERS([X11/extensions/XShm.h],
[with_xshm="yes"],
[AS_IF([test "x$with_xshm" = "xcheck"],
[with_xshm="no"],
[AC_MSG_FAILURE([test for X shared memory extension failed!
install the X shared memory extension, specify --x-includes or
configure --without-xshm to disable the extension])])],
[[#include <X11/Xlib.h>
#include <sys/ipc.h>
#include <sys/shm.h>
]])
AS_IF([test "x$with_xshm" != "xno"],
[AC_CHECK_LIB([Xext], [XShmQueryVersion],
[with_xshm="yes"],
[AC_MSG_FAILURE([unable to find XShmQueryVersion in $XSHM_LIBS!
specify XSHM_LIBS or configure --without-xshm to disable the extension])],
["$X_LIBS" "$X_PRE_LIBS" -lX11 "$X_EXTRA_LIBS" "$XSHM_LIBS"])
])
])
AM_CONDITIONAL([HAVE_XSHM], [test "x$with_xshm" = "xyes"])
AC_ARG_VAR([XV_LIBS], [linker flags for XVideo extension])
AS_IF([test "x$XV_LIBS" = "x"], [XV_LIBS="-lXv"])
AC_ARG_WITH([xv],
[AS_HELP_STRING([--without-xv],
[disable support for XVideo extension])],
[],
[with_xv="check"])
AS_IF([test "x$with_xv" != "xno"],
[AC_CHECK_HEADERS([X11/extensions/Xvlib.h],
[with_xv="yes"],
[AS_IF([test "x$with_xv" = "xcheck"],
[with_xv="no"],
[AC_MSG_FAILURE([test for XVideo extension failed!
install the XVideo extension, specify --x-includes or
configure --without-xv to disable the extension])])],
[[#include <X11/Xlib.h>
]])
AS_IF([test "x$with_xv" != "xno"],
[AC_CHECK_LIB([Xv], [XvQueryExtension],
[with_xv="yes"],
[AC_MSG_FAILURE([unable to find XvQueryExtension in $XV_LIBS!
specify XV_LIBS or configure --without-xv to disable the extension])],
["$X_LIBS" "$X_PRE_LIBS" -lX11 "$X_EXTRA_LIBS" "$XV_LIBS"])
])
])
AM_CONDITIONAL([HAVE_XV], [test "x$with_xv" = "xyes"])
dnl dbus
AC_ARG_WITH([dbus],
[AS_HELP_STRING([--without-dbus],
[disable support for dbus])],
[],
[with_dbus="check"])
AS_IF([test "x$with_dbus" != "xno"],
[PKG_CHECK_MODULES(DBUS, dbus-1 >= 1.0, have_dbus="yes", have_dbus="no")
AS_IF([test "x$have_dbus$with_dbus" = "xnoyes"],
[AC_MSG_FAILURE([DBus development libraries not found])],
[with_dbus="$have_dbus"])
])
AM_CONDITIONAL([HAVE_DBUS], [test "x$with_dbus" = "xyes"])
AS_IF([test "x$with_dbus" = "xyes"],
[CPPFLAGS="$CPPFLAGS $DBUS_CFLAGS"
AC_ARG_VAR([DBUS_LIBS], [linker flags for building dbus])
AC_DEFINE([HAVE_DBUS], [1], [Define to 1 to use dbus])
AC_ARG_WITH(dbusconfdir, AC_HELP_STRING([--with-dbusconfdir=PATH],
[path to D-Bus config directory]),
[path_dbusconf=$withval],
[path_dbusconf="`$PKG_CONFIG --variable=sysconfdir dbus-1`"])
AS_IF([test -z "$path_dbusconf"],
DBUS_CONFDIR="$sysconfdir/dbus-1/system.d",
DBUS_CONFDIR="$path_dbusconf/dbus-1/system.d")
AC_SUBST(DBUS_CONFDIR)
])
dnl libjpeg
AC_ARG_WITH([jpeg],
[AS_HELP_STRING([--without-jpeg],
[disable support for JPEG image conversions])],
[],
[with_jpeg="check"])
have_jpeg="maybe"
AS_IF([test "x$with_jpeg" != "xno"],
[AC_CHECK_HEADERS([jpeglib.h jerror.h], [], [have_jpeg="no"])
AC_CHECK_LIB([jpeg], [jpeg_read_header], [], [have_jpeg="no"])
AS_IF([test "x$have_jpeg" != "xno"],
[with_jpeg="yes"],
[test "x$with_jpeg" = "xyes"],
[AC_MSG_FAILURE([unable to find libjpeg! ensure CFLAGS/LDFLAGS are
set appropriately or configure --without-jpeg])],
[with_jpeg="no"])
])
AM_CONDITIONAL([HAVE_JPEG], [test "x$with_jpeg" = "xyes"])
dnl ImageMagick or GraphicsMagick
dnl disable both if IM is explicitly disabled to preserve old behavior
AC_ARG_WITH([imagemagick],
[AS_HELP_STRING([--without-imagemagick],
[disable support for scanning images with ImageMagick])],
[],
[with_imagemagick="check"])
AC_ARG_WITH([graphicsmagick],
[AS_HELP_STRING([--with-graphicsmagick],
[use GraphicsMagick alternative to ImageMagick])],
[],
[with_graphicsmagick="check"])
magick="UnknownMagick"
have_IM="maybe"
AS_IF([test "x$with_imagemagick" = "xno"], [],
[test "x$with_imagemagick" = "xyes" || \
test "x$with_graphicsmagick" != "xyes"],
[looked_for="ImageMagick >= 6.2.6"
PKG_CHECK_MODULES([MAGICK], [MagickWand >= 6.2.6],
[MAGICK_VERSION=`$PKG_CONFIG MagickWand --modversion`],
[dnl
dnl Wand is deprecated in favor of MagickWand,
dnl but the latter doesn't exist in older versions (bug #2848437)
saved_error=$MAGICK_PKG_ERRORS
PKG_CHECK_MODULES([MAGICK], [Wand >= 6.2.6],
[MAGICK_VERSION=`$PKG_CONFIG Wand --modversion`],
[have_IM="no"])])
AS_IF([test "x$have_IM" != "xno"],
[magick="ImageMagick"
AC_MSG_NOTICE([trying ImageMagick version $MAGICK_VERSION])
dnl double check ImageMagick install (bug #2582232)
CPPFLAGS_save="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $MAGICK_CFLAGS"
AC_CHECK_HEADERS([wand/MagickWand.h],
[
have_IM="yes"
with_imagemagick="yes"
],
[have_IM="broken"])
dnl check for ImageMagick 7, see https://imagemagick.org/script/porting.php#headers
AS_IF([test "x$have_IM" = "xbroken"], [
AC_CHECK_HEADERS([MagickWand/MagickWand.h],
[
have_IM="yes"
have_IM7="yes"
with_imagemagick="yes"
],
[have_IM="broken"])
])
CPPFLAGS="$CPPFLAGS_save"])])
have_GM="maybe"
AS_IF([test "x$have_IM" = "xyes"], [],
[test "x$with_graphicsmagick" = "xno"], [],
[test "x$with_graphicsmagick" = "xyes" || \
test "x$with_imagemagick" = "xcheck"],
[AS_IF([test "x$looked_for" = "x"],
[looked_for="GraphicsMagick"],
[looked_for="$looked_for or GraphicsMagick"])
PKG_CHECK_MODULES([GM], [GraphicsMagickWand],
[have_GM="yes"
with_imagemagick="no"
magick="GraphicsMagick"
MAGICK_CFLAGS="$MAGICK_CFLAGS $GM_CFLAGS"
MAGICK_LIBS="$MAGICK_LIBS $GM_LIBS"
MAGICK_VERSION=`$PKG_CONFIG GraphicsMagickWand --modversion`],
[have_GM="no"
AS_IF([test "x$saved_error" = "x"],
[saved_error=$MAGICK_PKG_ERRORS])])])
dnl now that we have collected all the info abt what Magick is available
dnl let the user know what we will or can't do
AS_IF([test "x$have_IM" = "xbroken" && test "x$have_GM" = "xyes"],
[
with_imagemagick="no"
AC_MSG_WARN([Your ImageMagick install is broken, using GraphicsMagick instead])
])
AS_IF([test "x$have_IM" = "xyes" || test "x$have_GM" = "xyes"],
[AC_MSG_NOTICE([using $magick version $MAGICK_VERSION])],
[test "x$with_imagemagick" = "xno" && \
test "x$with_graphicsmagick" != "xyes"],
[AC_MSG_NOTICE([image scanning disabled -- zbarimg will *not* be built])],
[test "x$have_IM" = "xbroken"],
[AC_MSG_FAILURE([$magick package found but wand/MagickWand.h not installed?!
this is a problem with your $magick install, please try again after
resolving the inconsistency or installing GraphicsMagick alternative...])],
[test "x$with_graphicsmagick" = "xcheck"],
[AC_MSG_NOTICE([ImageMagick/GraphicsMagick not detected. Several features will be disabled])
with_imagemagick="no"],
[AC_MSG_FAILURE([dnl
Unable to find $looked_for:
$saved_error
* Ensure that you installed any "development" packages for ImageMagick or
GraphicsMagick.
* Consider adjusting the PKG_CONFIG_PATH environment variable if you
installed software in a non-standard prefix.
* You may set the environment variables MAGICK_CFLAGS and MAGICK_LIBS
to avoid the need to call pkg-config.
See the pkg-config man page for more details.
* To avoid using ImageMagick or GraphicsMagick altogether you may add the
--without-imagemagick flag to the configure command; the zbarimg program
will *not* be built.
])])
AS_IF([test "x$have_IM" = "xyes"],
[AC_DEFINE([HAVE_IMAGEMAGICK], [1], [Define to 1 to use ImageMagick])],
[test "x$have_GM" = "xyes"],
[AC_DEFINE([HAVE_GRAPHICSMAGICK], [1], [Define to 1 to use GraphicsMagick])])
AS_IF([test "x$have_IM7" = "xyes"],
[AC_DEFINE([HAVE_IMAGEMAGICK7], [1], [Define to 1 to use ImageMagick 7])])
AM_CONDITIONAL([HAVE_MAGICK],
[test "x$have_IM" = "xyes" || test "x$have_GM" = "xyes"])
dnl Mozilla NPAPI
AC_ARG_WITH([npapi],
[AS_HELP_STRING([--with-npapi],
[enable support for Firefox/Mozilla/OpenOffice plugin])],
[],
[with_npapi="no"])
AS_IF([test "x$with_npapi" != "xno"],
[PKG_CHECK_MODULES([NPAPI], [firefox-plugin])
NPAPI_VERSION=`$PKG_CONFIG firefox-plugin --modversion`
AC_MSG_NOTICE([using firefox-plugin version $NPAPI_VERSION])])
AM_CONDITIONAL([HAVE_NPAPI], [test "x$with_npapi" = "xyes"])
dnl GTK
dnl For now, defaults to GTK version 2
AC_ARG_WITH([gtk],
[AS_HELP_STRING([--with-gtk],
[Specify support for GTK. Valid values are: no, auto, gtk2, gtk3 (default is auto)])],
[AS_IF([test "x$with_gtk" != "xno" && test "x$with_gtk" != "xauto" &&
test "x$with_gtk" != "xgtk2" && test "x$with_gtk" != "xgtk3"],
[echo "Invalid value for --with-gtk. Falling back to 'no'"
with_gtk="xno"])],
[with_gtk="auto"])
AC_ARG_VAR([GLIB_GENMARSHAL], [full path to glib-genmarshal])
AC_ARG_VAR([GTK_VERSION_MAJOR])
AS_IF([test "x$with_gtk" = "xgtk3" || test "x$with_gtk" = "xauto"],
[PKG_CHECK_MODULES([GTK3], [gtk+-3.0],
[GLIB_GENMARSHAL=`$PKG_CONFIG glib-2.0 --variable=glib_genmarshal`
GTK_VERSION=`$PKG_CONFIG gtk+-3.0 --modversion`
AC_MSG_NOTICE([using GTK+ version $GTK_VERSION])
GTK_VERSION_MAJOR=3.0
with_gtk="gtk3"
GTK_CFLAGS=$GTK3_CFLAGS
GTK_LIBS=$GTK3_LIBS
],[libgtk3=false])
])
AS_IF([test "x$with_gtk" = "xgtk2" || test "x$with_gtk" = "xauto"],
[PKG_CHECK_MODULES([GTK2], [gtk+-2.0],
[GLIB_GENMARSHAL=`$PKG_CONFIG glib-2.0 --variable=glib_genmarshal`
GTK_VERSION=`$PKG_CONFIG gtk+-2.0 --modversion`
AC_MSG_NOTICE([using GTK+ version $GTK_VERSION])
GTK_VERSION_MAJOR=2.0
with_gtk="gtk2"
GTK_CFLAGS=$GTK2_CFLAGS
GTK_LIBS=$GTK2_LIBS
],[libgtk2=false])
])
dnl GTK not found
AS_IF([test "x$with_gtk" = "xauto"], [with_gtk="no"])
AC_SUBST(GTK_LIBS)
AC_SUBST(GTK_CFLAGS)
AM_CONDITIONAL([HAVE_GTK], [test "x$with_gtk" != "xno"])
AC_ARG_WITH([gir],
[AS_HELP_STRING([--with-gir], [enable support for GObject Introspection])],
[],
[with_gir="yes"])
dnl Python
dnl For now, keep python2 as default
dnl If both PYTHON and --with-python=foo are defined, PYTHON takes precedence
AC_ARG_WITH([python],
[AS_HELP_STRING([--with-python],
[Specify support for Python. Valid values are: no, auto, python2, python3
(default is auto).
Please notice that PYTHON var, if especified, takes precedence.])],
[AS_IF([test "x$with_python" != "xno" && test "x$with_python" != "xauto" &&
test "x$with_python" != "xpython2" && test "x$with_python" != "xpython3"],
[echo "Invalid value for --with-python. Falling back to 'no'"
with_python="xno"])],
[with_python="auto"])
AC_ARG_VAR([PYTHON_CONFIG], [full path to python-config program])
AC_ARG_VAR([PYTHON_CFLAGS], [compiler flags for building python extensions])
AC_ARG_VAR([PYTHON_LDFLAGS], [linker flags for building python extensions])
AC_ARG_VAR([PYGTK_H2DEF], [full path to PyGTK h2def.py module (python2 only)])
AC_ARG_VAR([PYGTK_CODEGEN], [full path to pygtk-codegen program (python2 only)])
AC_ARG_VAR([PYGTK_DEFS], [directory where PyGTK definitions may be found (python2 only)])
AS_IF([test -z "$PYTHON"],
[AS_IF([test "x$with_python" = "xauto"],
[AC_PATH_PROGS([PYTHON], [python3 python2 python], [:], [$PATH])],
[AS_IF([test "x$with_python" = "xpython3"],
[AC_PATH_PROGS([PYTHON], [python3 python], [:], [$PATH])],
[AS_IF([test "x$with_python" = "xpython2"],
[AC_PATH_PROGS([PYTHON], [python2 python], [:], [$PATH])],
[with_python="no"])
])
]
)],
[with_python="auto"]
)
AS_IF([test "x$with_python" != "xno"],
[AM_PATH_PYTHON([2.7.0])])
AS_IF([test "x$PYTHON_VERSION" != "x" && test "x$with_python" != "xno"],
[PYTHON_VERSION_MAJOR="`echo $PYTHON_VERSION | cut -d'.' -f 1`"
AS_IF([test "x$PYTHON_CFLAGS" != "x"],
[],
[test "x$PYTHON_CONFIG" != "x" && test -x "$PYTHON_CONFIG"],
[PYTHON_CFLAGS=`$PYTHON_CONFIG --cflags`],
[test -x "$PYTHON-config"],
[PYTHON_CFLAGS=`$PYTHON-config --cflags`],
[PYTHON_CFLAGS=`$PYTHON -c 'import distutils.sysconfig as s, sys; sys.stdout.write(" ".join(s.get_config_vars("CFLAGS")) + " -I"+s.get_python_inc() + " -I"+s.get_python_inc(plat_specific=True))'`])
AS_IF([test "x$PYTHON_LDFLAGS" != "x"],
[],
[test "x$PYTHON_CONFIG" != "x" && test -x "$PYTHON_CONFIG"],
[PYTHON_LDFLAGS=`$PYTHON_CONFIG --ldflags`],
[test -x "$PYTHON-config"],
[PYTHON_LDFLAGS=`$PYTHON-config --ldflags`],
[PYTHON_LDFLAGS=`$PYTHON -c 'import distutils.sysconfig as s, sys; sys.stdout.write(" ".join(s.get_config_vars("LDFLAGS")) + " -I"+s.get_python_inc() + " -I"+s.get_python_inc(plat_specific=True))'`])
dnl check that #include <Python.h> compiles (bug #3092663)
CPPFLAGS_save="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $PYTHON_CFLAGS"
AS_IF([test "x$win32" = "xyes"], PYTHON_LDFLAGS="$PYTHON_LDFLAGS -no-undefined")
AC_CHECK_HEADERS([Python.h], [],
[AS_IF([test "x$with_python" = "xauto"],with_python="no",
[AC_MSG_ERROR([dnl
Python module enabled, but unable to compile Python.h.
Install the development package for python-$am_cv_python_version, or configure
--without-python to disable the python bindings.dnl
])])])
CPPFLAGS="$CPPFLAGS_save"
dnl PyGTK
dnl disable pygtk when we're on Python 3
AS_IF([test "x$with_gtk" != "xno"],
[AS_IF([test "x$PYTHON_VERSION_MAJOR" = "x2"],
[PKG_CHECK_MODULES([PYGTK], [pygtk-2.0], [with_pygtk2="yes"], [with_pygtk2="no"])
AC_CHECK_PROGS([PYGTK_CODEGEN], [pygobject-codegen-2.0 pygtk-codegen-2.0 pygtk-codegen], [:])
AS_IF([test "x$PYGTK_H2DEF" = "x"],
[PYGTK_H2DEF=`$PKG_CONFIG pygtk-2.0 --variable=codegendir`/h2def.py
AS_IF([test -f "$PYGTK_H2DEF"], [], [PYGTK_H2DEF=":"])])
AS_IF([test "x$PYGTK_DEFS" = "x"],
[PYGTK_DEFS=`$PKG_CONFIG pygtk-2.0 --variable=defsdir`])
])
])
], [with_python="no"])
AS_IF([test "x$PYTHON_VERSION_MAJOR" != "x2"], [with_pygtk2="no"])
AM_CONDITIONAL([HAVE_PYTHON], [test "x$with_python" != "xno"])
AM_CONDITIONAL([HAVE_PYGTK2], [test "x$with_pygtk2" != "xno"])
dnl GObject Introspection (GIR)
AS_IF([test "x$with_gir" = "xyes" && test "x$with_gtk" != "xno"],
[m4_ifdef([GOBJECT_INTROSPECTION_CHECK],
[GOBJECT_INTROSPECTION_CHECK([0.6.7])
AS_IF([test "x$found_introspection" = "xyes"],
[INTROSPECTION_TYPELIBDIR=`$PKG_CONFIG --variable=typelibdir --define-variable="libdir=${libdir}" gobject-introspection-1.0`
INTROSPECTION_GIRDIR=`$PKG_CONFIG --variable=girdir --define-variable="datadir=${datadir}" gobject-introspection-1.0`
AC_SUBST(INTROSPECTION_TYPELIBDIR)
AC_SUBST(INTROSPECTION_GIRDIR)])])
])
AS_IF([test "x$found_introspection" != "xyes"], [with_gir="no"])
AM_CONDITIONAL([HAVE_INTROSPECTION], [test "x$with_gir" = "xyes"])
dnl Qt
AC_ARG_WITH([qt],
[AS_HELP_STRING([--without-qt],
[disable support for Qt widget])],
[],
[with_qt="yes"])
dnl Qt5
AC_ARG_WITH([qt5],
[AS_HELP_STRING([--without-qt5],
[disable support for Qt5 widget. if --with-qt, it will seek only for Qt4])],
[],
[with_qt5="yes"])
AC_ARG_VAR([MOC], [full path to Qt moc program])
AS_IF([test "x$have_x" = "xyes"],
[qt_extra="Qt5X11Extras >= 5.0"],
[qt_extra=""])
AS_IF([test "x$with_qt" != "xno"],
[PKG_CHECK_MODULES([QT],
[Qt5Core >= 5 Qt5Gui >= 5 Qt5Widgets >= 5.0 $qt_extra],,
[with_qt5="no"
PKG_CHECK_MODULES([QT],
[QtCore >= 4 QtGui >= 4],,
[with_qt="no"])])])
AS_IF([test "x$with_qt" != "xno"],
[AS_IF([test "x$with_qt5" != "xno"],
[AC_CHECK_PROGS(MOC, [moc-qt5 moc])
AC_MSG_NOTICE([using moc from $MOC])
QT_VERSION=`$PKG_CONFIG Qt5Gui --modversion`
CPPFLAGS="$CPPFLAGS $QT_CPPFLAGS"
dnl -fPIC has no effect on Windows and breaks windres
AS_IF([test "x$win32" = "xno"], [CPPFLAGS="$CPPFLAGS -fPIC"])
AC_MSG_NOTICE([using Qt version $QT_VERSION])
qt_pkgconfig_file="zbar-qt5.pc"
],
[MOC=`$PKG_CONFIG QtGui --variable=moc_location`
AC_MSG_NOTICE([using moc from $MOC])
QT_VERSION=`$PKG_CONFIG QtGui --modversion`
AC_MSG_NOTICE([using Qt version $QT_VERSION])
qt_pkgconfig_file="zbar-qt.pc"
])])
AM_CONDITIONAL([HAVE_QT], [test "x$with_qt" = "xyes"])
AM_COND_IF([HAVE_QT],
[AC_CONFIG_FILES([zbar-qt.pc:"${qt_pkgconfig_file}.in"])]
)
dnl Java
have_java="maybe"
AC_ARG_VAR([JAVA_HOME], [root location of JDK])
AC_ARG_VAR([JAVAC], [location of Java language compiler])
AC_ARG_VAR([JAVAH], [location of Java header generator])
dnl If $JAVA_HOME not defined, try to autodetect it
AS_IF([test -z "$JAVA_HOME"],
[AC_PATH_PROGS([JAVAC], [javac jikes ecj gcj], [:], [$PATH])
AS_IF([test ! -z "$JAVAC"],
[JAVA_HOME=$( readlink -f ${JAVAC} | rev | cut -d/ -f3- | rev )])])
dnl If $JAVA_HOME is defined, set JAVA_PATH and JAVAC
AS_IF([test ! -z "$JAVA_HOME"],
[JAVA_PATH="$JAVA_HOME/bin$PATH_SEPARATOR$PATH"
AS_IF([test -z "$JAVAC"],
[AC_PATH_PROGS([JAVAC], [javac jikes ecj gcj], [:], [$JAVA_PATH])])])
AC_ARG_WITH([java],
[AS_HELP_STRING([--without-java],
[disable support for Java interface])],
[],
[with_java="check"])
JAVAC=${JAVAC/ecj/ecj -1.5}
dnl Javah was obsoleted on Java 8 and removed on Java 11. So, we need to
dnl look strictly at the $JAVA_HOME in order to avoid mixing different versions
AS_IF([test -z "$JAVAH"],
[AC_PATH_PROGS([JAVAH], [javah], [], [$JAVA_HOME/bin])])
AM_CONDITIONAL([HAVE_JAVAH], [test "x$JAVAH" != "x"])
AC_ARG_VAR([JAR], [location of Java archive tool])
AC_PATH_PROGS([JAR], [jar], [:], [$JAVA_PATH])
AS_IF([test "x$JAR" = "x:"], [have_java="no"])
AC_ARG_VAR([JAVA], [location of Java application launcher])
AC_PATH_PROGS([JAVA], [java], [/bin/false], [$JAVA_PATH])
AC_ARG_VAR([CLASSPATH], [Java class path (include JUnit to run java tests)])
AS_IF([test "x$CLASSPATH" = "x"], [CLASSPATH="."])
dnl Search for Java unit test library
AS_IF([test -z "$JUNIT_HOME"],
[JUNIT_HOME="/usr/share/java"])
AS_IF([test -f "$JUNIT_HOME/junit4.jar"],
[JUNIT="$JUNIT_HOME/junit4.jar"],
[AS_IF([test -f "$JUNIT_HOME/junit.jar"],
[JUNIT="$JUNIT_HOME/junit.jar"])])
AS_IF([test "x$JUNIT" != "x"],
[AS_IF([test -f "/usr/share/java/hamcrest/all.jar"],
[CLASSPATH="$JUNIT:/usr/share/java/hamcrest/all.jar:$CLASSPATH"
AC_SUBST(CLASSPATH)
with_java_unit="yes"])],
[AS_IF([test -f "/usr/share/java/hamcrest-all.jar"],
[CLASSPATH="$JUNIT:/usr/share/java/hamcrest-all.jar:$CLASSPATH"
AC_SUBST(CLASSPATH)
with_java_unit="yes"])])
AM_CONDITIONAL([HAVE_JAVA_UNIT], [test "x$with_java_unit" = "xyes"])
AC_ARG_VAR([JAVA_CFLAGS], [compiler flags for building JNI extensions])
AS_IF([test "x$JAVA_CFLAGS" = "x" && test "x$JAVA_HOME" != "x"],
[JAVA_CFLAGS="-I$JAVA_HOME/include"])
AS_IF([test -d "$JAVA_HOME/include/linux"],
[JAVA_CFLAGS="$JAVA_CFLAGS -I$JAVA_HOME/include/linux"])
AS_IF([test "x$with_java" != "xno"],
[CPPFLAGS_save="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS $JAVA_CFLAGS"
AC_CHECK_HEADERS([jni.h], [], [have_java="no"])
CPPFLAGS="$CPPFLAGS_save"
AS_IF([test "x$have_java" != "xno"],
[with_java="yes"],
[test "x$with_java" = "xyes"],
[AC_MSG_FAILURE([unable to find Java JNI! ensure CFLAGS are set appropriately or configure --without-java])],
[with_java="no"])
])
AM_CONDITIONAL([HAVE_JAVA], [test "x$with_java" = "xyes"])
dnl header files
dnl FIXME switches for shm, mmap
AC_HEADER_ASSERT
AC_CHECK_HEADERS([errno.h fcntl.h features.h inttypes.h float.h limits.h \
locale.h stddef.h stdlib.h string.h unistd.h sys/types.h sys/stat.h \
sys/ioctl.h sys/time.h sys/times.h sys/ipc.h sys/shm.h sys/mman.h])
AC_HEADER_MAJOR
AC_CHECK_HEADER_STDBOOL
dnl types
AC_TYPE_INT32_T
AC_TYPE_UINT32_T
AC_TYPE_UINT8_T
AC_TYPE_UINTPTR_T
AC_TYPE_UID_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
AC_CHECK_MEMBERS([struct stat.st_rdev])
dnl compile characteristics
AC_C_CONST
AC_C_INLINE
dnl functions
AC_FUNC_MMAP
AC_CHECK_FUNCS([alarm clock_gettime floor getcwd gettimeofday localeconv memchr memmove memset modf munmap pow select setenv sqrt strcasecmp strchr strdup strerror strrchr strstr strtol strtoul malloc realloc])
dnl output generation
dnl avoid doc rebuilds unless revision info changes
AC_CONFIG_COMMANDS([doc/version.xml],
[AS_IF([test -f doc/version.xml && \
! echo $VERSION | diff doc/version.xml - >/dev/null 2>&1 || \
! echo $VERSION | diff $srcdir/doc/version.xml - >/dev/null 2>&1 ],
[echo "writing new doc/version.xml" ; echo $VERSION > $srcdir/doc/version.xml ])],
[VERSION="$VERSION"]
)
AC_CONFIG_COMMANDS([doc/reldate.xml],
[AS_IF([test -f doc/reldate.xml && \
! echo $RELDATE | diff doc/reldate.xml - >/dev/null 2>&1 || \
! echo $RELDATE | diff $srcdir/doc/reldate.xml - >/dev/null 2>&1 ],
[echo "writing new doc/reldate.xml" ; echo $RELDATE > $srcdir/doc/reldate.xml ])],
[RELDATE="$RELDATE"]
)
echo "Generating config files"
AC_CONFIG_FILES([
Makefile
gtk/Makefile
java/Makefile
po/Makefile.in
zbar/Makefile
zbar.pc
zbar-gtk.pc
doc/doxygen.conf])
AC_CONFIG_FILES([test/test_examples.sh],[chmod 755 test/test_examples.sh])
AC_CONFIG_FILES([test/check_dbus.sh],[chmod 755 test/check_dbus.sh])
AC_OUTPUT
dnl summary log
echo ""
echo "please verify that the detected configuration matches your expectations:"
echo "------------------------------------------------------------------------"
AS_IF([test "x$USE_NLS" = "xyes"],
[echo "gettext $USE_NLS"]
)
AS_IF([test "x$win32" != "xno"],
[AS_IF([test "x$with_directshow" != "xno"],
[echo "DirectShow driver --with-directshow=$with_directshow"],
[echo "VfW driver --with-directshow=$with_directshow"]
)],
[echo "X --with-x=$have_x"]
)
AS_IF([test "x$with_python" != "xno"], pyver="\tpython${PYTHON_VERSION}")
AS_IF([test "x$with_gtk" != "xno"], gtkver="\tGtk${GTK_VERSION}")
AS_IF([test "x$with_qt" != "xno"], qtver="\tQt${QT_VERSION}")
echo "pthreads --enable-pthread=$enable_pthread"
echo "doc --enable-doc=$enable_doc"
echo "v4l --enable-video=$enable_video"
echo "jpeg --with-jpeg=$with_jpeg"
echo -e "Python --with-python=$with_python $pyver"
echo -e "GTK --with-gtk=$with_gtk $gtkver"
echo "GObject introspection --with-gir=$with_gir"
echo -e "Qt --with-qt=$with_qt $qtver"
echo "Java --with-java=$with_java"
AS_IF([test "x$win32" = "xno"],
[echo "Dbus --with-dbus=$with_dbus"])
AS_IF([test "x$have_GM" = "xyes"],
[echo "GraphicsMagick --with-graphicsmagick=yes"],
[echo "ImageMagick --with-imagemagick=$with_imagemagick"])
echo "Enabled codes: $enabled_codes"
echo "Disabled codes: $disabled_codes"
AS_IF([test "x$with_java" = "xyes"],
[echo "JAVA_HOME $JAVA_HOME"])
dnl Display "warnings" about disabled and experimental features
echo ""
AS_IF([test "x$enable_video" != "xyes"],
[echo " => zbarcam video scanner will *NOT* be built"])
AS_IF([test "x$have_libv4l" != "xyes"],
[echo " => libv4l will *NOT* be used"])
AS_IF([test "x$with_jpeg" != "xyes"],
[echo " => JPEG image conversions will *NOT* be supported"])
AS_IF([test "x$have_IM" != "xyes" && test "x$have_GM" != "xyes"],
[echo " => the zbarimg file scanner will *NOT* be built"])
AS_IF([test "x$have_GM" = "xyes"],
[echo " => ImageMagick is preferred, as GraphicsMagick doesn't support https"])
AS_IF([test "x$with_gtk" = "xno"],
[echo " => GTK support will *NOT* be built"])
AS_IF([test "x$with_pygtk2" != "xyes" && test "xPYTHON_VERSION_MAJOR" = "x2"],
[echo " => the Python 2 GTK widget wrapper will *NOT* be built"])
AS_IF([test "x$with_qt" != "xyes"],
[echo " => the Qt widget will *NOT* be built"])
AS_IF([test "x$with_qt" = "xyes" && test "x$enable_static_qt" = "xyes" ],
[echo " => Building a static Qt library"])
AS_IF([test "x$with_java" != "xyes"],
[echo " => the Java interface will *NOT* be built"])
AS_IF([test "x$with_java_unit" != "xyes"],
[echo " => the Java unit test will *NOT* be enabled"])
dnl echo "NPAPI Plugin --with-npapi=$with_npapi"
dnl AS_IF([test "x$with_mozilla" != "xyes"],
dnl [echo " => the Mozilla/Firefox/OpenOffice plugin will *NOT* be built"])
AS_IF([test "x$enable_pdf417" = "xyes"],
[echo " => the pdf417 code support is incomplete!"])

View File

@ -0,0 +1,15 @@
<!DOCTYPE busconfig PUBLIC
"-//freedesktop//DTD D-BUS Bus Configuration 1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/busconfig.dtd">
<busconfig>
<policy context="default">
<allow own="org.linuxtv.Zbar"/>
<allow send_destination="org.linuxtv.Zbar"/>
<allow send_destination="org.linuxtv.Zbar"
send_interface="org.linuxtv.Zbar1.Code"/>
<allow send_destination="org.linuxtv.Zbar"
send_interface="org.freedesktop.DBus.Properties"/>
<allow send_destination="org.linuxtv.Zbar"
send_interface="org.freedesktop.DBus.Introspectable"/>
</policy>
</busconfig>

55
doc/Makefile.am.inc Normal file
View File

@ -0,0 +1,55 @@
# documentation sources
DOCSOURCES = doc/manual.xml doc/version.xml doc/reldate.xml \
doc/ref/zbarimg.xml doc/ref/zbarcam.xml doc/ref/commonoptions.xml
MAINTAINERCLEANFILES += doc/man/man.stamp doc/version.xml doc/reldate.xml
# man page targets to distribute and install
dist_man_MANS =
if HAVE_MAGICK
dist_man_MANS += doc/man/zbarimg.1
endif
if HAVE_VIDEO
dist_man_MANS += doc/man/zbarcam.1
endif
# witness to man page build (many-to-many workaround)
man_stamp = doc/man/man.stamp
# TBD add manual content
#dist_doc_DATA = doc/zbar.pdf doc/zbar.html
# distribute all documentation related files to avoid end-user rebuilds
EXTRA_DIST += $(DOCSOURCES) $(man_stamp)
EXTRA_DIST += doc/api/footer.html doc/style.xsl
docs: $(dist_man_MANS) #dist_doc_DATA
PHONY += docs
doc_path = --searchpath $(abs_builddir)/doc -m $(abs_srcdir)/doc/style.xsl
# xmlto --searchpath broken again...
doc_path += --skip-validation
#pdf: doc/zbar-manual.pdf
#doc/zbar-manual.pdf: $(DOCSOURCES)
# $(XMLTO) $(XMLTOFLAGS) -o doc pdf $<
html-local: doc/html/index.html
doc/html/index.html: $(DOCSOURCES)
$(XMLTO) $(doc_path) $(XMLTOFLAGS) -o doc/html xhtml $<
CLEANFILES += doc/html/*.html
$(dist_man_MANS): $(man_stamp)
@if test ! -f $@ ; then \
rm -f $(man_stamp) ; \
$(MAKE) $(AM_MAKEFLAGS) $(man_stamp) ; \
fi
$(man_stamp): $(DOCSOURCES)
@$(mkdir_p) doc/man 2>/dev/null
@rm -f $(man_stamp).tmp
@touch $(man_stamp).tmp
$(XMLTO) $(doc_path) $(XMLTOFLAGS) -o doc/man man $<
@mv $(man_stamp).tmp $(man_stamp)

20
doc/api/footer.html Normal file
View File

@ -0,0 +1,20 @@
<hr></hr>
<div style="float: right; clear: right">
<a href="http://sourceforge.net">
<img style="border: none" src="http://sflogo.sourceforge.net/sflogo.php?group_id=189236&amp;type=3"
width="125" height="37" alt="SourceForge.net Logo"/>
</a>
</div>
<address><a href="mailto:spadix@users.sourceforge.net">spadix@users.sourceforge.net</a></address>
<p>Copyright 2008-2010 (c) Jeff Brown</p>
<p>This documentation is part of the ZBar Barcode Reader; you can
redistribute it and/or modify it under the terms of the
<a href="http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html">GNU
Lesser General Public License</a> as published by the Free Software
Foundation; either version 2.1 of the License, or (at your option) any
later version.</p>
</body></html>

39
doc/doxygen.conf.in Normal file
View File

@ -0,0 +1,39 @@
PROJECT_NAME = "ZBar Bar Code Reader Library"
PROJECT_NUMBER = "version @VERSION@"
INPUT = @top_srcdir@/include
RECURSIVE = YES
EXCLUDE = @top_srcdir@/include/zbar/zbargtk.h
EXCLUDE_PATTERNS = */.svn/* */.hg/*
STRIP_FROM_PATH = @top_srcdir@
OUTPUT_DIRECTORY = doc/api
CREATE_SUBDIRS = NO
OUTPUT_LANGUAGE = English
SOURCE_BROWSER = NO
VERBATIM_HEADERS = NO
TAB_SIZE = 4
JAVADOC_AUTOBRIEF = YES
SUBGROUPING = NO
SORT_MEMBER_DOCS = NO
SORT_BRIEF_DOCS = NO
TYPEDEF_HIDES_STRUCT = YES
HIDE_FRIEND_COMPOUNDS = YES
HIDE_IN_BODY_DOCS = YES
INTERNAL_DOCS = NO
MAX_INITIALIZER_LINES = 0
SHOW_INCLUDE_FILES = NO
EXTRACT_STATIC = YES
QUIET = YES
WARNINGS = YES
WARN_IF_UNDOCUMENTED = YES
WARN_IF_DOC_ERROR = YES
GENERATE_XML = YES
HTML_HEADER =
HTML_FOOTER = @top_srcdir@/doc/api/footer.html
HTML_STYLESHEET =

50
doc/manual.xml Normal file
View File

@ -0,0 +1,50 @@
<?xml version='1.0'?>
<!DOCTYPE book PUBLIC "-//OASIS//DTD DocBook XML V4.4//EN"
"file:///usr/share/sgml/docbook/xml-dtd-4.4/docbookx.dtd" [
<!ENTITY version SYSTEM "version.xml">
<!ENTITY date SYSTEM "reldate.xml">
<!ENTITY refcommonoptions SYSTEM "ref/commonoptions.xml">
<!ENTITY refzbarimg SYSTEM "ref/zbarimg.xml">
<!ENTITY refzbarcam SYSTEM "ref/zbarcam.xml">
]>
<book>
<title>ZBar Barcode Reader</title>
<bookinfo>
<productname>zbar-&version;</productname>
<date>&date;</date>
<author>
<firstname>Jeff</firstname><surname>Brown</surname>
<affiliation>
<address><email>spadix@users.sourceforge.net</email></address>
</affiliation>
<contrib>Lead developer</contrib>
</author>
<copyright>
<year>2007</year>
<year>2008</year>
<year>2009</year>
<year>2010</year>
<holder>Jeff Brown</holder>
</copyright>
<legalnotice><para>All Rights Reserved</para></legalnotice>
</bookinfo>
<chapter id="intro">
<title>Introduction</title>
<para></para>
</chapter>
<reference id="ref">
<title>ZBar Barcode Reader - Command Reference</title>
&refzbarcam;
&refzbarimg;
</reference>
</book>

165
doc/ref/commonoptions.xml Normal file
View File

@ -0,0 +1,165 @@
<varlistentry>
<term><option>-h</option></term>
<term><option>--help</option></term>
<listitem>
<simpara>Print a short help message describing command line
options to standard output and exit</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--version</option></term>
<listitem>
<simpara>Print program version information to standard output and
exit</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-v</option></term>
<term><option>--verbose<optional>=<replaceable
class="parameter">n</replaceable></optional></option></term>
<listitem>
<simpara>Increase debug output level. Multiple
<option>-v</option> options create more spew. Alternatively
specify <replaceable class="parameter">n</replaceable> to
set the debug level directly
</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-S<optional><replaceable
class="parameter">symbology</replaceable>.</optional><replaceable
class="parameter">config</replaceable><optional>=<replaceable
class="parameter">value</replaceable></optional></option></term>
<term><option>--set <optional><replaceable
class="parameter">symbology</replaceable>.</optional><replaceable
class="parameter">config</replaceable><optional>=<replaceable
class="parameter">value</replaceable></optional></option></term>
<listitem>
<simpara>Set decoder configuration option <replaceable
class="parameter">config</replaceable> for <replaceable
class="parameter">symbology</replaceable> to <replaceable
class="parameter">value</replaceable>. <replaceable
class="parameter">value</replaceable> defaults to 1 if omitted.
<replaceable class="parameter">symbology</replaceable> is one of
<option>ean13</option>, <option>ean8</option>,
<option>upca</option>, <option>upce</option>,
<option>isbn13</option>, <option>isbn10</option>,
<option>i25</option>, <option>codabar</option>, <option>code39</option>,
<option>code93</option>, <option>code128</option>,
<option>qrcode</option> or the special value <option>*</option>.
If <replaceable class="parameter">symbology</replaceable> is
omitted or <option>*</option>, the <replaceable
class="parameter">config</replaceable> will be set for all
applicable symbologies. These are the currently recognized
<replaceable class="parameter">config</replaceable>s. Prefix a
config with "no-" to negate it. Not all configs are appropriate
for every symbology.</simpara>
<variablelist>
<varlistentry>
<term><option>enable</option></term>
<listitem>
<simpara>Control decoding/reporting of a symbology. For
symbologies which are just subsets of <option>ean13</option>
(<option>upca</option>, <option>upce</option>,
<option>isbn13</option>, <option>isbn10</option>), this
config controls whether the subsets are detected and
reported as such. These special cases are disabled by
default, all other symbologies default to enabled</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>disable</option></term>
<listitem>
<simpara>Antonym for <option>enable</option></simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>emit-check</option></term>
<listitem>
<simpara>Control whether check digits are included in the
decoded output. Enabled by default. This config does not
apply for <option>code128</option>, which never returns the
check digit. It also not apply for cases where the check
digit is disabled (see <option>add-check</option>). Check
digits are currently not implemented for
<option>i25</option> or <option>code39</option></simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>add-check</option></term>
<listitem>
<simpara>Enable decode and verification of a check digit for
symbologies where it is optional: this will include
<option>code39</option> and <option>i25</option>, neither of
which implements the check digit yet</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>ascii</option></term>
<listitem>
<simpara>Enable escape sequences that encode the full ASCII
character set. This would apply to <option>code39</option>,
except that it's not implemented either...</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>position</option></term>
<listitem>
<simpara>Enable collection of symbol position information.
Enabled by default. Currently, the position information is
unusable, so you can save a few cycles by disabling
this.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>test-inverted</option></term>
<listitem>
<simpara>Specially for QR code images, sometimes the image
is inverted, e. g. lines are written in white instead of black.
This option makes ZBar to invert the image and parse again, in
case it fails using the normal order. Enabling it affects all
decoders.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>min-length=<replaceable class="parameter">n</replaceable></option></term>
<term><option>max-length=<replaceable class="parameter">n</replaceable></option></term>
<listitem>
<simpara>Bound the number of decoded characters in a valid symbol.
If a decode result is outside the configured min/max range
(inclusive), it will not be reported. Set to 0 to disable the
corresponding check. This setting applies to variable-length
symbologies: <option>i25</option>, <option>codabar</option>,
<option>code39</option>, <option>code128</option> and
<option>pdf417</option>. <option>min-length</option> defaults to 6
for <option>i25</option> and 1 for <option>code39</option> (per Code
39 autodiscrimination recommendation); all others default to
0</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>x-density=<replaceable class="parameter">n</replaceable></option></term>
<term><option>y-density=<replaceable class="parameter">n</replaceable></option></term>
<listitem>
<simpara>Adjust the density of the scanner passes. Lower values
scan more of the image at the cost of decreased performance.
Setting to 0 disables scanning along that axis. Defaults are both
1.</simpara>
</listitem>
</varlistentry>
</variablelist>
</listitem>
</varlistentry>

207
doc/ref/zbarcam.xml Normal file
View File

@ -0,0 +1,207 @@
<refentry xml:id="zbarcam"
xmlns:xlink="http://www.w3.org/1999/xlink">
<refmeta>
<refentrytitle>zbarcam</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>zbarcam</refname>
<refpurpose>scan and decode bar codes from a video device
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>zbarcam</command>
<arg><option>-qv</option></arg>
<arg><option>--quiet</option></arg>
<arg><option>--nodisplay</option></arg>
<arg><option>--xml</option></arg>
<arg><option>--verbose<arg>=<replaceable
class="parameter">n</replaceable></arg></option></arg>
<arg><option>--prescale=<replaceable
class="parameter">W</replaceable>x<replaceable
class="parameter">H</replaceable></option></arg>
<arg><option>-S<optional><replaceable
class="parameter">symbology</replaceable>.</optional><replaceable
class="parameter">config</replaceable><optional>=<replaceable
class="parameter">value</replaceable></optional></option></arg>
<arg><option>--set <optional><replaceable
class="parameter">symbology</replaceable>.</optional><replaceable
class="parameter">config</replaceable><optional>=<replaceable
class="parameter">value</replaceable></optional></option></arg>
<arg><replaceable class="parameter">device</replaceable></arg>
</cmdsynopsis>
<cmdsynopsis>
<command>zbarcam</command>
<group choice="req">
<arg choice="plain"><option>-h</option></arg>
<arg choice="plain"><option>--help</option></arg>
<arg choice="plain"><option>--version</option></arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para><command>zbarcam</command> scans a video4linux video source
(eg, a webcam) for bar codes and prints any decoded data to the
standard output. The video stream is also displayed to the
screen. </para>
<para><replaceable class="parameter">device</replaceable> is the
path to the video4linux (version 1 or 2) character device special
file (major number 81 and minor number 0 thru 63). It defaults to
<filename>/dev/video0</filename></para>
<para>The underlying library currently supports EAN-13 (including
UPC and ISBN subsets), EAN-8, DataBar, DataBar Expanded, Code 128,
Code 93, Code 39, Codabar, Interleaved 2 of 5 and QR Code symbologies.
The specific type of each detected symbol is printed with the decoded
data.</para>
</refsection>
<refsection>
<title>Options</title>
<para>This program follows the usual GNU command line syntax.
Single letter options may be bundled, long options start with two
dashes (`-').</para>
<variablelist>
&refcommonoptions;
<varlistentry>
<term><option>-q</option></term>
<term><option>--quiet</option></term>
<listitem>
<simpara>Quiet operation; disable the audible beep otherwise
emitted when a symbol is decoded</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--nodisplay</option></term>
<listitem>
<simpara>Disable output video window. Video input will be
scanned until the program is interrupted or otherwise
signaled</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--xml</option></term>
<listitem>
<simpara>Stream results using an XML output format. This
format wraps the raw data from the symbol with information
about the scan in an easy to parse format. The latest
schema is available from <link xlink:href="http://zbar.sourceforge.net/2008/barcode.xsd"/></simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--raw</option></term>
<listitem>
<simpara>Use raw symbol data output format. This format
prints symbol data separated by newlines without the
additional symbology type information that is printed by
default</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--prescale=<replaceable
class="parameter">W</replaceable>x<replaceable
class="parameter">H</replaceable></option></term>
<listitem>
<simpara>Request video input scaling from the camera driver.
Possibly useful for reducing huge frames to achieve a higher
frame rate. Note that the driver may adjust or completely
ignore the scaling request</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Examples</title>
<para>Scan for barcodes using the second video device and pipe the
resulting data through a script that searches for each code in a
database and does something useful with them:
<screen><command>zbarcam</command> <filename>/dev/video1</filename> | <command>upcrpc.py</command></screen>
The <command>upcrpc.py</command> example script included in the
<filename>examples/</filename> subdirectory of the distribution
will make an XMLRPC call to a popular internet UPC database and
print the product description if found.</para>
<para>Scan for barcodes using the default video device and stream
results to stdout in XML format, also disable recognition of
Interleaved 2 of 5 codes to prevent confusion with other
symbologies or background noise:
<screen><command>zbarcam</command> <option>--xml</option> <option>-Si25.disable</option></screen>
</para>
<para>Scan only for Code 39, without using the preview window -
maybe for a fixed installation. To enable only Code 39, first all
symbologies are disabled, then Code 39 is re-enabled:
<screen><command>zbarcam</command> <option>--nodisplay</option> <option>-Sdisable</option> <option>-Scode39.enable</option></screen>
</para>
</refsection>
<refsection>
<title>Exit Status</title>
<para><command>zbarcam</command> returns an exit code to indicate the
status of the program execution. Current exit codes are:</para>
<variablelist>
<varlistentry>
<term>0</term>
<listitem>
<para>Successful program completion.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>1</term>
<listitem>
<para>An error occurred. This includes bad arguments and I/O
errors.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>2</term>
<listitem>
<para>A fatal error occurred.</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="zbarimg"/></para>
<para><link xlink:href="http://zbar.sf.net/"/></para>
</refsection>
<refsection>
<title>Bugs</title>
<para>See <link xlink:href="http://sf.net/tracker/?group_id=189236&amp;atid=928515"/></para>
</refsection>
</refentry>

232
doc/ref/zbarimg.xml Normal file
View File

@ -0,0 +1,232 @@
<refentry xml:id="zbarimg"
xmlns:xlink="http://www.w3.org/1999/xlink">
<refmeta>
<refentrytitle>zbarimg</refentrytitle>
<manvolnum>1</manvolnum>
</refmeta>
<refnamediv>
<refname>zbarimg</refname>
<refpurpose>scan and decode bar codes from image file(s)
</refpurpose>
</refnamediv>
<refsynopsisdiv>
<cmdsynopsis>
<command>zbarimg</command>
<arg><option>-qv</option></arg>
<arg><option>--quiet</option></arg>
<arg><option>--verbose<arg>=<replaceable
class="parameter">n</replaceable></arg></option></arg>
<sbr/>
<group choice="req" rep="repeat">
<arg choice="plain"><option>-dD</option></arg>
<arg choice="plain"><option>--display</option></arg>
<arg choice="plain"><option>--nodisplay</option></arg>
<arg choice="plain"><option>--xml</option></arg>
<arg choice="plain"><option>--noxml</option></arg>
<arg choice="plain"><option>-S<optional><replaceable
class="parameter">symbology</replaceable>.</optional><replaceable
class="parameter">config</replaceable><optional>=<replaceable
class="parameter">value</replaceable></optional></option></arg>
<arg choice="plain"><option>--set <optional><replaceable
class="parameter">symbology</replaceable>.</optional><replaceable
class="parameter">config</replaceable><optional>=<replaceable
class="parameter">value</replaceable></optional></option></arg>
<arg choice="plain"><replaceable>image</replaceable></arg>
</group>
</cmdsynopsis>
<cmdsynopsis>
<command>zbarimg</command>
<group choice="req">
<arg choice="plain"><option>-h</option></arg>
<arg choice="plain"><option>--help</option></arg>
<arg choice="plain"><option>--version</option></arg>
</group>
</cmdsynopsis>
</refsynopsisdiv>
<refsection>
<title>Description</title>
<para>For each specified
<filename><replaceable>image</replaceable></filename> file
<command>zbarimg</command> scans the image for bar codes and
prints any decoded data to stdout. Images may optionally be
displayed to the screen.</para>
<para>The underlying library currently supports EAN-13 (including
UPC and ISBN subsets), EAN-8, DataBar, DataBar Expanded, Code 128,
Code 93, Code 39, Codabar, Interleaved 2 of 5 and QR Code symbologies.
The specific type of each detected symbol is printed with the decoded
data.</para>
<para>Note that "<filename><replaceable>image</replaceable></filename>"
in this context refers to any format supported by ImageMagick,
including many vector formats such as PDF and PostScript. Keep in
mind that vector formats are rasterized before scanning; manually
rasterize vector images before scanning to avoid unintentionally
corrupting embedded barcode bitmaps.</para>
</refsection>
<refsection>
<title>Options</title>
<para>This program follows the usual GNU command line syntax.
Single letter options may be bundled, long options start with two
dashes (`-').</para>
<variablelist>
&refcommonoptions;
<varlistentry>
<term><option>-q</option></term>
<term><option>--quiet</option></term>
<listitem>
<simpara>Quiet operation; only output decoded symbol data.
specifically this disables the statistics line printed (to
stderr) before exiting, as well as the warning message
printed (also to stderr) when no barcodes are found in an
image</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>-d</option></term>
<term><option>--display</option></term>
<term><option>-D</option></term>
<term><option>--nodisplay</option></term>
<listitem>
<simpara>Enable/disable display of subsequent
<filename><replaceable>image</replaceable></filename> files,
until next <option>--display</option> or
<option>--nodisplay</option> is encountered. This option
may appear multiple times to enable display of specific
images. Image display is disabled by default</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--xml</option></term>
<term><option>--noxml</option></term>
<listitem>
<simpara>Enable/disable result output using an XML format.
This format wraps the raw data from the symbol with
information about the scan (such as page indices) in an
easy to parse format. The latest schema is available from
<link xlink:href="http://zbar.sourceforge.net/2008/barcode.xsd"/>.</simpara>
</listitem>
</varlistentry>
<varlistentry>
<term><option>--raw</option></term>
<listitem>
<simpara>Enable raw symbol data output. This format prints symbol
data separated by newlines without the additional symbology type
information that is printed by default</simpara>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>Examples</title>
<para>Scan a PNG image of a UPC bar code symbol and pass
resulting data to a script that searches for the code in a
database and does something useful with it:
<screen><command>zbarimg</command> <filename>product.png</filename> | <command>upcrpc.py</command></screen>
The <command>upcrpc.py</command> example script included in the
<filename>examples/</filename> subdirectory of the distribution
will make an XMLRPC call to a popular internet UPC database and
print the product description if found.</para>
<para>Scan a JPEG image containing several barcodes and display
the image in a window, also disabling recognition of Interleaved 2
of 5 codes to prevent confusion with other symbologies or
background noise:
<screen><command>zbarimg</command> <option>--display</option> <option>-Si25.disable</option> <filename>label.jpg</filename></screen>
</para>
<para>Look in a scanned document only for Code 39, using XML
output format so the page numbers are available. To enable only
Code 39, first all symbologies are disabled, then Code 39 is
re-enabled:
<screen><command>zbarimg</command> <option>--xml</option> <option>-Sdisable</option> <option>-Scode39.enable</option> <filename>scan.tiff</filename></screen>
</para>
</refsection>
<refsection>
<title>Exit Status</title>
<para><command>zbarimg</command> returns an exit code to indicate the
status of the program execution. Current exit codes are:</para>
<variablelist>
<varlistentry>
<term>0</term>
<listitem>
<para>Barcodes successfully detected in all images. Warnings may
have been generated, but no errors.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>1</term>
<listitem>
<para>An error occurred while processing some image(s). This
includes bad arguments, I/O errors and image handling errors from
ImageMagick.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>2</term>
<listitem>
<para>ImageMagick fatal error.</para>
</listitem>
</varlistentry>
<varlistentry>
<term>3</term>
<listitem>
<para>The user quit the program before all images were scanned.
Only applies when running in interactive mode
(with <option>--display</option>)</para>
</listitem>
</varlistentry>
<varlistentry>
<term>4</term>
<listitem>
<para>No barcode was detected in one or more of the images. No
other errors occurred.</para>
</listitem>
</varlistentry>
</variablelist>
</refsection>
<refsection>
<title>See Also</title>
<para><xref linkend="zbarcam"/></para>
<para><link xlink:href="http://zbar.sf.net/"/></para>
</refsection>
<refsection>
<title>Bugs</title>
<para>See <link xlink:href="http://sf.net/tracker/?group_id=189236&amp;atid=928515"/></para>
</refsection>
</refentry>

9
doc/style.xsl Normal file
View File

@ -0,0 +1,9 @@
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:param name="make.year.ranges" select="1"/>
<xsl:param name="make.single.year.ranges" select="1"/>
<xsl:param name="use.id.as.filename" select="1"/>
</xsl:stylesheet>

BIN
examples/codabar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 198 B

BIN
examples/code-128.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

BIN
examples/code-39.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

BIN
examples/code-93.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.9 KiB

BIN
examples/code-upc-a.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
examples/databar-exp.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 199 B

BIN
examples/databar.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

BIN
examples/ean-13.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

BIN
examples/ean-2.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 132 B

BIN
examples/ean-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 179 B

BIN
examples/ean-8.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

BIN
examples/i2-5.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

47
examples/processor.c Normal file
View File

@ -0,0 +1,47 @@
#include <stdio.h>
#include <zbar.h>
static void my_handler (zbar_image_t *image,
const void *userdata)
{
/* extract results */
const zbar_symbol_t *symbol = zbar_image_first_symbol(image);
for(; symbol; symbol = zbar_symbol_next(symbol)) {
/* do something useful with results */
zbar_symbol_type_t typ = zbar_symbol_get_type(symbol);
const char *data = zbar_symbol_get_data(symbol);
printf("decoded %s symbol \"%s\"\n",
zbar_get_symbol_name(typ), data);
}
}
int main (int argc, char **argv)
{
const char *device = "/dev/video0";
/* create a Processor */
zbar_processor_t *proc = zbar_processor_create(1);
/* configure the Processor */
zbar_processor_set_config(proc, 0, ZBAR_CFG_ENABLE, 1);
/* initialize the Processor */
if(argc > 1)
device = argv[1];
zbar_processor_init(proc, device, 1);
/* setup a callback */
zbar_processor_set_data_handler(proc, my_handler, NULL);
/* enable the preview window */
zbar_processor_set_visible(proc, 1);
zbar_processor_set_active(proc, 1);
/* keep scanning until user provides key/mouse input */
zbar_processor_user_wait(proc, -1);
/* clean up */
zbar_processor_destroy(proc);
return(0);
}

45
examples/processor.cpp Normal file
View File

@ -0,0 +1,45 @@
#include <iostream>
#include <zbar.h>
using namespace std;
using namespace zbar;
class MyHandler : public Image::Handler
{
void image_callback (Image &image)
{
for(SymbolIterator symbol = image.symbol_begin();
symbol != image.symbol_end();
++symbol)
cout << "decoded " << symbol->get_type_name() << " symbol "
<< "\"" << symbol->get_data() << "\"" << endl;
}
};
int main (int argc, char **argv)
{
// create and initialize a Processor
const char *device = "/dev/video0";
if(argc > 1)
device = argv[1];
Processor proc(true, device);
// configure the Processor
proc.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
// setup a callback
MyHandler my_handler;
proc.set_handler(my_handler);
// enable the preview window
proc.set_visible();
proc.set_active();
try {
// keep scanning until user provides key/mouse input
proc.user_wait();
}
catch(ClosedError &e) {
}
return(0);
}

BIN
examples/qr-code-binary.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 922 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

BIN
examples/qr-code.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 210 B

104
examples/scan_image.c Normal file
View File

@ -0,0 +1,104 @@
#include <stdio.h>
#include <stdlib.h>
#include <png.h>
#include <zbar.h>
#if !defined(PNG_LIBPNG_VER) || \
PNG_LIBPNG_VER < 10018 || \
(PNG_LIBPNG_VER > 10200 && \
PNG_LIBPNG_VER < 10209)
/* Changes to Libpng from version 1.2.42 to 1.4.0 (January 4, 2010)
* ...
* 2. m. The function png_set_gray_1_2_4_to_8() was removed. It has been
* deprecated since libpng-1.0.18 and 1.2.9, when it was replaced with
* png_set_expand_gray_1_2_4_to_8() because the former function also
* expanded palette images.
*/
# define png_set_expand_gray_1_2_4_to_8 png_set_gray_1_2_4_to_8
#endif
zbar_image_scanner_t *scanner = NULL;
/* to complete a runnable example, this abbreviated implementation of
* get_data() will use libpng to read an image file. refer to libpng
* documentation for details
*/
static void get_data (const char *name,
int *width, int *height,
void **raw)
{
FILE *file = fopen(name, "rb");
if(!file) exit(2);
png_structp png =
png_create_read_struct(PNG_LIBPNG_VER_STRING,
NULL, NULL, NULL);
if(!png) exit(3);
if(setjmp(png_jmpbuf(png))) exit(4);
png_infop info = png_create_info_struct(png);
if(!info) exit(5);
png_init_io(png, file);
png_read_info(png, info);
/* configure for 8bpp grayscale input */
int color = png_get_color_type(png, info);
int bits = png_get_bit_depth(png, info);
if(color & PNG_COLOR_TYPE_PALETTE)
png_set_palette_to_rgb(png);
if(color == PNG_COLOR_TYPE_GRAY && bits < 8)
png_set_expand_gray_1_2_4_to_8(png);
if(bits == 16)
png_set_strip_16(png);
if(color & PNG_COLOR_MASK_ALPHA)
png_set_strip_alpha(png);
if(color & PNG_COLOR_MASK_COLOR)
png_set_rgb_to_gray_fixed(png, 1, -1, -1);
/* allocate image */
*width = png_get_image_width(png, info);
*height = png_get_image_height(png, info);
*raw = malloc(*width * *height);
png_bytep rows[*height];
int i;
for(i = 0; i < *height; i++)
rows[i] = *raw + (*width * i);
png_read_image(png, rows);
}
int main (int argc, char **argv)
{
if(argc < 2) return(1);
/* create a reader */
scanner = zbar_image_scanner_create();
/* configure the reader */
zbar_image_scanner_set_config(scanner, 0, ZBAR_CFG_ENABLE, 1);
/* obtain image data */
int width = 0, height = 0;
void *raw = NULL;
get_data(argv[1], &width, &height, &raw);
/* wrap image data */
zbar_image_t *image = zbar_image_create();
zbar_image_set_format(image, zbar_fourcc('Y','8','0','0'));
zbar_image_set_size(image, width, height);
zbar_image_set_data(image, raw, width * height, zbar_image_free_data);
/* scan the image for barcodes */
int n = zbar_scan_image(scanner, image);
/* extract results */
const zbar_symbol_t *symbol = zbar_image_first_symbol(image);
for(; symbol; symbol = zbar_symbol_next(symbol)) {
/* do something useful with results */
zbar_symbol_type_t typ = zbar_symbol_get_type(symbol);
const char *data = zbar_symbol_get_data(symbol);
printf("decoded %s symbol \"%s\"\n",
zbar_get_symbol_name(typ), data);
}
/* clean up */
zbar_image_destroy(image);
zbar_image_scanner_destroy(scanner);
return(0);
}

54
examples/scan_image.cpp Normal file
View File

@ -0,0 +1,54 @@
#include <iostream>
#include <zbar.h>
#include <Magick++.h>
#define STR(s) #s
using namespace std;
using namespace zbar;
int main (int argc, char **argv)
{
if(argc < 2) return(1);
#ifdef MAGICK_HOME
// http://www.imagemagick.org/Magick++/
// under Windows it is necessary to initialize the ImageMagick
// library prior to using the Magick++ library
Magick::InitializeMagick(MAGICK_HOME);
#endif
// create a reader
ImageScanner scanner;
// configure the reader
scanner.set_config(ZBAR_NONE, ZBAR_CFG_ENABLE, 1);
// obtain image data
Magick::Image magick(argv[1]); // read an image file
int width = magick.columns(); // extract dimensions
int height = magick.rows();
Magick::Blob blob; // extract the raw data
magick.modifyImage();
magick.write(&blob, "GRAY", 8);
const void *raw = blob.data();
// wrap image data
Image image(width, height, "Y800", raw, width * height);
// scan the image for barcodes
int n = scanner.scan(image);
// extract results
for(Image::SymbolIterator symbol = image.symbol_begin();
symbol != image.symbol_end();
++symbol) {
// do something useful with results
cout << "decoded " << symbol->get_type_name()
<< " symbol \"" << symbol->get_data() << '"' << endl;
}
// clean up
image.set_data(NULL, 0);
return(0);
}

View File

@ -0,0 +1,46 @@
<?xml version="1.0"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="scan_image"
RootNamespace="scan_image"
Keyword="Win32Proj">
<Platforms>
<Platform Name="Win32"/>
</Platforms>
<Configurations>
<Configuration
Name="Debug|Win32"
ConfigurationType="1">
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="..\include;&quot;C:\Program Files\ImageMagick-6.5.4-Q16\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;&quot;MAGICK_HOME=STR(C:\\Program Files\\ImageMagick-6.5.4-Q16)&quot;"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DisableSpecificWarnings="4100;4189;4251"
DebugInformationFormat="4"/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="..\lib\libzbar-0.lib kernel32.lib &quot;C:\Program Files\ImageMagick-6.5.4-Q16\lib\CORE_RL_Magick++_.lib&quot; $(NoInherit)"
ShowProgress="0"
GenerateDebugInformation="true"
SubSystem="1"
TargetMachine="1"/>
</Configuration>
</Configurations>
<Files>
<Filter
Name="Source Files"
Filter="cpp">
<File RelativePath=".\scan_image.cpp"/>
</Filter>
</Files>
</VisualStudioProject>

19
examples/sha1sum Normal file
View File

@ -0,0 +1,19 @@
a56811d078ea5cfac9be5deb4b6796177763e152 zbarimg codabar.png
cc53bf34878f769fc3611020c11e572f2853bd2a zbarimg code-128.png
7537d593ea42393a43bc0eda0a896c0e31017dd8 zbarimg code-39.png
f8f55b828eb7d0400f300be021d29293bd4a3191 zbarimg code-93.png
aebbdbed0b32d7fd72f1245e3fb384822d492062 zbarimg databar.png
9e245874d3229a575eabfdba1c668369c55960e3 zbarimg databar-exp.png
53429fc04dfcf674349e2db6cfbaf73e301fc3dc zbarimg ean-13.png
4095418b74efbb026dd730543558fefdda46f5b9 zbarimg ean-8.png
5501245dbba21c153f690787fc97ab50c973b846 zbarimg i2-5.png
b350ca7efad7a50c5ac082d5c683a8e8d8d380a7 zbarimg qr-code.png
84c0ce7072e2227073dc8bd1e5f4518d8f42ae3d zbarimg sqcode1-generated.png
84c0ce7072e2227073dc8bd1e5f4518d8f42ae3d zbarimg sqcode1-scanned.png
5ab2b518e2c9d827cedc5825d2e3c9646d43713a zbarimg -Sean2.enable ean-2.png
668fef8cb9caac34df8cb8564c2cde62e4af5e65 zbarimg -Sean5.enable ean-5.png
b567e550216fe24f7652f683146365a9fe7ee867 zbarimg -Sisbn10.enable ean-13.png
d0f37aa076d42c270f7231c5490beea5605e2ba0 zbarimg -Sisbn13.enable ean-13.png
3f041225df3b8364b5fd0daf9cf402e8a4731f9b zbarimg -Supca.enable code-upc-a.png
b350ca7efad7a50c5ac082d5c683a8e8d8d380a7 zbarimg -Stest-inverted qr-code-inverted.png
df896e459e47a7d392031a7d4962722a143e276b zbarimg --raw --oneshot -Sbinary qr-code-binary.png

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 332 KiB

46
examples/upcrpc.pl Executable file
View File

@ -0,0 +1,46 @@
#!/usr/bin/perl
use warnings;
use strict;
use Frontier::Client;
use Data::Dumper;
my $s = Frontier::Client->new('url' => 'http://www.upcdatabase.com/rpc');
$| = 1; # autoflush
foreach (@ARGV) {
lookup($_);
}
if(!-t) {
while(1) {
my $decode = <STDIN>;
last unless(defined($decode));
chomp($decode);
lookup($decode);
}
}
sub lookup {
my $decode = shift;
if($decode =~ m[^(EAN-13:|UPC-A:)?(\d{11,13})$] &&
($1 && $1 eq "UPC-A:") || ($2 && length($2) > 11)) {
my $ean = $2;
$ean = "0" . $ean
if($1 && $1 eq "UPC-A:");
$ean = $s->call('calculateCheckDigit', $ean . "C")
if(length($ean) == 12);
print("[$decode] ");
my $result = $s->call('lookupEAN', $s->string($ean));
if(ref($result)) {
print((!$result->{found} ||
(ref($result->{found}) && !$result->{found}->value()))
? "not found\n"
: "$result->{description}\n")
}
else {
print("$result\n");
}
}
else {
print("$decode\n");
}
}

50
examples/upcrpc.py Executable file
View File

@ -0,0 +1,50 @@
#!/usr/bin/env python
from __future__ import print_function
try:
from xmlrpc.client import ServerProxy
except:
from xmlrpclib import ServerProxy
import sys, re
server = ServerProxy("http://www.upcdatabase.com/rpc")
ean_re = re.compile(r'^(UPC-A:|EAN-13:)?(\d{11,13})$', re.M)
def lookup(decode):
match = ean_re.search(decode)
if match is None:
print(decode, end=" ")
return
ean = match.group(2)
if match.group(1) == "UPC-A:":
ean = "0" + ean;
elif len(ean) < 12:
print(decode, end=' ')
return
if len(ean) == 12:
ean = server.calculateCheckDigit(ean + "C")
print("[" + match.group(1) + ean + "]", end=' ')
result = server.lookupEAN(ean)
if isinstance(result, dict):
if "found" not in result or not result["found"] or \
"description" not in result:
print("not found")
else:
print(result["description"])
else:
print(str(result))
sys.stdout.flush()
if __name__ == "__main__":
del sys.argv[0]
if len(sys.argv):
for decode in sys.argv:
lookup(decode)
if not sys.stdin.isatty():
while 1:
decode = sys.stdin.readline()
if not decode:
break
lookup(decode)

88
gtk/Makefile.am Normal file
View File

@ -0,0 +1,88 @@
lib_LTLIBRARIES = libzbargtk.la
libzbargtk_la_CPPFLAGS = $(GTK_CFLAGS) $(AM_CPPFLAGS)
libzbargtk_la_LDFLAGS = -version-info $(ZGTK_LIB_VERSION) \
-export-symbols-regex "^zbar_.*" $(AM_LDFLAGS) -no-undefined
libzbargtk_la_LIBADD = $(GTK_LIBS) ../zbar/libzbar.la $(AM_LIBADD)
libzbargtk_la_DEPENDENCIES = ../zbar/libzbar.la
if HAVE_X
libzbargtk_la_CPPFLAGS += -DHAVE_X
endif
dist_libzbargtk_la_SOURCES = zbargtk.c zbargtkprivate.h
nodist_libzbargtk_la_SOURCES = zbarmarshal.c zbarmarshal.h
BUILT_SOURCES = zbarmarshal.c zbarmarshal.h
CLEANFILES = $(BUILT_SOURCES)
EXTRA_DIST = zbarmarshal.list
%.h: %.list
$(GLIB_GENMARSHAL) --g-fatal-warnings --prefix=zbar_marshal \
--header $^ > $@
%.c: %.list
$(GLIB_GENMARSHAL) --g-fatal-warnings --prefix=zbar_marshal \
--body $^ > $@
../zbar/libzbar.la:
$(MAKE) -C $(abs_top_srcdir) zbar/libzbar.la
../zbarcam/zbarcam-gtk: libzbargtk.la
$(MAKE) -C $(abs_top_srcdir) zbarcam/zbarcam-gtk
# GObject Introspection
include $(INTROSPECTION_MAKEFILE)
# NOTE:
#
# At least with Fedora 30 builds using mock (e. g. inside a chroot and
# having the build dir different than the source dir, using
# gobject-introspection-1.60, there is a bug with GIR file generation:
# sometimes, g-ir-scanner is not capable of producing a C file that would
# be loading libzbargtk.so.0. So, it fails with:
#
# error while loading shared libraries: libzbargtk.so.0:
# cannot open shared object file: No such file or directory
#
# I suspect that it has something to do with libtool-2.4.6.
# The fix is hackish, but it should be safe: it should manually include
# the paths where libtool generate those at INTROSPECTION_SCANNER_ARGS.
#
# It should be noticed that, this shouldn't affect a non-buggy environment,
# so, better to be safe than sorry.
INTROSPECTION_SCANNER_ARGS = --warn-all \
--symbol-prefix=zbar \
--identifier-prefix=zbar_ \
--identifier-prefix=ZBar \
--library-path=$(abs_builddir)/.libs \
--library-path=$(abs_top_builddir)/zbar/.libs
# Just in case
INTROSPECTION_SCANNER_ENV = GI_SCANNER_DISABLE_CACHE=yes
INTROSPECTION_GIRS = ZBar-1.0.gir
ZBar_1_0_gir_NAMESPACE = ZBar
ZBar_1_0_gir_VERSION = 1.0
ZBar_1_0_gir_LIBS = $(lib_LTLIBRARIES) $(top_builddir)/zbar/libzbar.la
ZBar_1_0_gir_FILES = $(top_builddir)/include/zbar/zbargtk.h zbargtk.c
ZBar_1_0_gir_INCLUDES = Gtk-@GTK_VERSION_MAJOR@ Gdk-@GTK_VERSION_MAJOR@
ZBar_1_0_gir_CFLAGS = $(libzbargtk_la_CPPFLAGS)
# This may generate some warnings, but it is needed for "make dist"
ZBar-1.0.gir: $(lib_LTLIBRARIES)
if HAVE_INTROSPECTION
girdir = $(INTROSPECTION_GIRDIR)
dist_gir_DATA = $(INTROSPECTION_GIRS)
typelibdir = $(INTROSPECTION_TYPELIBDIR)
typelib_DATA = ZBar-1.0.typelib
CLEANFILES += $(dist_gir_DATA) $(typelib_DATA)
endif

886
gtk/zbargtk.c Normal file
View File

@ -0,0 +1,886 @@
/*------------------------------------------------------------------------
* Copyright 2008-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
*
* This file is part of the ZBar Bar Code Reader.
*
* The ZBar Bar Code Reader is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* The ZBar Bar Code Reader is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser Public License
* along with the ZBar Bar Code Reader; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* http://sourceforge.net/projects/zbar
*------------------------------------------------------------------------*/
#include <gtk/gtk.h>
#ifdef HAVE_X
#include <gdk/gdkx.h>
#elif defined(_WIN32)
#include <gdk/gdkwin32.h>
#endif
#include <zbar/zbargtk.h>
#include "zbargtkprivate.h"
#include "zbarmarshal.h"
#ifndef G_PARAM_STATIC_STRINGS
# define G_PARAM_STATIC_STRINGS (G_PARAM_STATIC_NAME | G_PARAM_STATIC_NICK | G_PARAM_STATIC_BLURB)
#endif
#define DEFAULT_WIDTH 640
#define DEFAULT_HEIGHT 480
enum {
DECODED,
DECODED_TEXT,
LAST_SIGNAL
};
enum {
PROP_0,
PROP_VIDEO_DEVICE,
PROP_VIDEO_ENABLED,
PROP_VIDEO_OPENED,
};
static guint zbar_gtk_signals[LAST_SIGNAL] = { 0 };
G_DEFINE_TYPE(ZBarGtk, zbar_gtk, GTK_TYPE_WIDGET);
/* FIXME what todo w/errors? OOM? */
/* FIXME signal failure notifications to main gui idle handler */
void zbar_gtk_release_pixbuf (zbar_image_t *img)
{
GdkPixbuf *pixbuf = zbar_image_get_userdata(img);
g_assert(GDK_IS_PIXBUF(pixbuf));
/* remove reference */
zbar_image_set_userdata(img, NULL);
/* release reference to associated pixbuf and it's data */
g_object_unref(pixbuf);
}
gboolean zbar_gtk_image_from_pixbuf (zbar_image_t *zimg,
GdkPixbuf *pixbuf)
{
/* apparently should always be packed RGB? */
GdkColorspace colorspace = gdk_pixbuf_get_colorspace(pixbuf);
if(colorspace != GDK_COLORSPACE_RGB) {
g_warning("non-RGB color space not supported: %d\n", colorspace);
return(FALSE);
}
int nchannels = gdk_pixbuf_get_n_channels(pixbuf);
int bps = gdk_pixbuf_get_bits_per_sample(pixbuf);
long type = 0;
/* these are all guesses... */
if(nchannels == 3 && bps == 8)
type = zbar_fourcc('R','G','B','3');
else if(nchannels == 4 && bps == 8)
type = zbar_fourcc('B','G','R','4'); /* FIXME alpha flipped?! */
else if(nchannels == 1 && bps == 8)
type = zbar_fourcc('Y','8','0','0');
else if(nchannels == 3 && bps == 5)
type = zbar_fourcc('R','G','B','R');
else if(nchannels == 3 && bps == 4)
type = zbar_fourcc('R','4','4','4'); /* FIXME maybe? */
else {
g_warning("unsupported combination: nchannels=%d bps=%d\n",
nchannels, bps);
return(FALSE);
}
zbar_image_set_format(zimg, type);
/* FIXME we don't deal w/bpl...
* this will cause problems w/unpadded pixbufs :|
*/
unsigned pitch = gdk_pixbuf_get_rowstride(pixbuf);
unsigned width = pitch / ((nchannels * bps) / 8);
if((width * nchannels * 8 / bps) != pitch) {
g_warning("unsupported: width=%d nchannels=%d bps=%d rowstride=%d\n",
width, nchannels, bps, pitch);
return(FALSE);
}
unsigned height = gdk_pixbuf_get_height(pixbuf);
/* FIXME this isn't correct either */
unsigned long datalen = width * height * nchannels;
zbar_image_set_size(zimg, width, height);
/* when the zbar image is released, the pixbuf will be
* automatically be released
*/
zbar_image_set_userdata(zimg, pixbuf);
zbar_image_set_data(zimg, gdk_pixbuf_get_pixels(pixbuf), datalen,
zbar_gtk_release_pixbuf);
#ifdef DEBUG_ZBARGTK
g_message("colorspace=%d nchannels=%d bps=%d type=%.4s(%08lx)\n"
"\tpitch=%d width=%d height=%d datalen=0x%lx\n",
colorspace, nchannels, bps, (char*)&type, type,
pitch, width, height, datalen);
#endif
return(TRUE);
}
static inline gboolean zbar_gtk_video_open (ZBarGtk *self,
const char *video_device)
{
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
gboolean video_opened = FALSE;
zbar->video_opened = FALSE;
if(zbar->idle_id)
g_object_notify(G_OBJECT(self), "video-opened");
if(zbar->window) {
/* ensure old video doesn't have image ref
* (FIXME handle video destroyed w/images outstanding)
*/
zbar_window_draw(zbar->window, NULL);
gtk_widget_queue_draw(GTK_WIDGET(self));
}
if(zbar->video) {
zbar_video_destroy(zbar->video);
zbar->video = NULL;
}
if(video_device && video_device[0] && zbar->idle_id) {
/* create video
* FIXME video should support re-open
*/
zbar->video = zbar_video_create();
g_assert(zbar->video);
if(zbar_video_open(zbar->video, video_device)) {
zbar_video_error_spew(zbar->video, 0);
zbar_video_destroy(zbar->video);
zbar->video = NULL;
/* FIXME error propagation */
return(FALSE);
}
/* negotiation accesses the window format list,
* so we hold the lock for this part
*/
if(zbar->video_width && zbar->video_height)
zbar_video_request_size(zbar->video,
zbar->video_width, zbar->video_height);
video_opened = !zbar_negotiate_format(zbar->video, zbar->window);
if(video_opened) {
zbar->req_width = zbar_video_get_width(zbar->video);
zbar->req_height = zbar_video_get_height(zbar->video);
}
gtk_widget_queue_resize(GTK_WIDGET(self));
zbar->video_opened = video_opened;
if(zbar->idle_id)
g_object_notify(G_OBJECT(self), "video-opened");
}
return(video_opened);
}
static inline int zbar_gtk_process_image (ZBarGtk *self,
zbar_image_t *image)
{
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
if(!image)
return(-1);
zbar_image_t *tmp = zbar_image_convert(image, zbar_fourcc('Y','8','0','0'));
if(!tmp)
return(-1);
zbar_image_scanner_recycle_image(zbar->scanner, image);
int rc = zbar_scan_image(zbar->scanner, tmp);
zbar_image_set_symbols(image, zbar_image_get_symbols(tmp));
zbar_image_destroy(tmp);
if(rc < 0)
return(rc);
if(rc && zbar->idle_id) {
/* update decode results */
const zbar_symbol_t *sym;
for(sym = zbar_image_first_symbol(image);
sym;
sym = zbar_symbol_next(sym))
if(!zbar_symbol_get_count(sym)) {
zbar_symbol_type_t type = zbar_symbol_get_type(sym);
const char *data = zbar_symbol_get_data(sym);
g_signal_emit(self, zbar_gtk_signals[DECODED], 0,
type, data);
/* FIXME skip this when unconnected? */
gchar *text = g_strconcat(zbar_get_symbol_name(type),
":",
data,
NULL);
g_signal_emit(self, zbar_gtk_signals[DECODED_TEXT], 0, text);
g_free(text);
}
}
if(zbar->window) {
rc = zbar_window_draw(zbar->window, image);
gtk_widget_queue_draw(GTK_WIDGET(self));
}
else
rc = -1;
return(rc);
}
static gboolean zbar_processing_idle_callback(gpointer data)
{
ZBarGtk *self = data;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
GValue *msg = g_async_queue_try_pop(zbar->queue);
if (!msg) {
if (zbar->video_enabled_state) {
zbar_image_t *image = zbar_video_next_image(zbar->video);
if(zbar_gtk_process_image(self, image) < 0)
zbar->video_enabled_state = FALSE;
if(image)
zbar_image_destroy(image);
if (zbar->video_enabled_state)
return TRUE;
if(zbar_video_enable(zbar->video, 0)) {
zbar_video_error_spew(zbar->video, 0);
zbar->video_enabled_state = FALSE;
}
zbar_image_scanner_enable_cache(zbar->scanner, 0);
/* release video image and revert to logo */
if(zbar->window) {
zbar_window_draw(zbar->window, NULL);
gtk_widget_queue_draw(GTK_WIDGET(self));
}
/* must have been an error while streaming */
zbar_gtk_video_open(self, NULL);
}
return TRUE;
}
g_assert(G_IS_VALUE(msg));
GType type = G_VALUE_TYPE(msg);
if(type == G_TYPE_INT) {
/* video state change */
int state = g_value_get_int(msg);
if(state < 0) {
/* error identifying state */
g_value_unset(msg);
g_free(msg);
return TRUE;
}
g_assert(state >= 0 && state <= 1);
zbar->video_enabled_state = (state != 0);
} else if(type == G_TYPE_STRING) {
/* open new video device */
const char *video_device = g_value_get_string(msg);
zbar->video_enabled_state = zbar_gtk_video_open(self, video_device);
} else if(type == GDK_TYPE_PIXBUF) {
/* scan provided image and broadcast results */
zbar_image_t *image = zbar_image_create();
GdkPixbuf *pixbuf = GDK_PIXBUF(g_value_dup_object(msg));
if(zbar_gtk_image_from_pixbuf(image, pixbuf))
zbar_gtk_process_image(self, image);
else
g_object_unref(pixbuf);
zbar_image_destroy(image);
} else {
gchar *dbg = g_strdup_value_contents(msg);
g_warning("unknown message type (%x) received: %s\n",
(unsigned)type, dbg);
g_free(dbg);
}
g_value_unset(msg);
g_free(msg);
msg = NULL;
if(zbar->video_enabled_state) {
/* release reference to any previous pixbuf */
if(zbar->window)
zbar_window_draw(zbar->window, NULL);
if(zbar_video_enable(zbar->video, 1)) {
zbar_video_error_spew(zbar->video, 0);
zbar->video_enabled_state = FALSE;
return TRUE;
}
zbar_image_scanner_enable_cache(zbar->scanner, 1);
return TRUE;
}
return TRUE;
}
static void zbar_gtk_realize (GtkWidget *widget)
{
ZBarGtk *self = ZBAR_GTK(widget);
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
gtk_widget_set_realized(widget, TRUE);
#if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 14
// FIXME: this is deprecated after 3.14 - no idea what replaces it
#else
gtk_widget_set_double_buffered(widget, FALSE);
#endif
GdkWindowAttr attributes;
GtkAllocation allocation;
gtk_widget_get_allocation(widget, &allocation);
attributes.x = allocation.x;
attributes.y = allocation.y;
attributes.width = allocation.width;
attributes.height = allocation.height;
attributes.wclass = GDK_INPUT_OUTPUT;
attributes.window_type = GDK_WINDOW_CHILD;
attributes.event_mask = (gtk_widget_get_events(widget) |
GDK_EXPOSURE_MASK);
GdkWindow *window = gdk_window_new(gtk_widget_get_parent_window(widget),
&attributes,
GDK_WA_X | GDK_WA_Y);
gtk_widget_set_window(widget, window);
gdk_window_set_user_data(window, widget);
#if GTK_MAJOR_VERSION == 3 && GTK_MINOR_VERSION < 18
gdk_window_set_background_pattern(window, NULL);
#elif GTK_MAJOR_VERSION < 3
gdk_window_set_back_pixmap(window, NULL, TRUE);
#endif
/* attach zbar_window to underlying X window */
#ifdef HAVE_X
if(zbar_window_attach(zbar->window,
GDK_DISPLAY_XDISPLAY(gdk_display_get_default()),
GDK_WINDOW_XID(window)))
#elif defined(_WIN32)
if(zbar_window_attach(zbar->window,
GDK_WINDOW_HWND (window),
0))
#endif
zbar_window_error_spew(zbar->window, 0);
}
static inline GValue *zbar_gtk_new_value (GType type)
{
return(g_value_init(g_malloc0(sizeof(GValue)), type));
}
static void zbar_gtk_unrealize (GtkWidget *widget)
{
GdkWindow *window;
if(gtk_widget_get_mapped(widget))
gtk_widget_unmap(widget);
gtk_widget_set_mapped(widget, FALSE);
ZBarGtk *self = ZBAR_GTK(widget);
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
if(zbar->video_enabled) {
zbar->video_enabled = FALSE;
GValue *msg = zbar_gtk_new_value(G_TYPE_INT);
g_value_set_int(msg, 0);
g_async_queue_push(zbar->queue, msg);
}
zbar_window_attach(zbar->window, NULL, 0);
gtk_widget_set_realized(widget, FALSE);
window = gtk_widget_get_window(widget);
gdk_window_set_user_data(window, NULL);
gdk_window_destroy(window);
gtk_widget_set_window(widget, NULL);
}
#if GTK_MAJOR_VERSION >= 3
static void zbar_get_preferred_width(GtkWidget *widget,
gint *minimum_width,
gint *natural_width)
{
ZBarGtk *self = ZBAR_GTK(widget);
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
/* use native video size (max) if available,
* arbitrary defaults otherwise.
* video attributes maintained under main gui idle handler
*/
#if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 22
GdkRectangle geo;
GdkDisplay *display = gdk_display_get_default();
GdkMonitor *monitor = gdk_display_get_monitor(display, 0);
gdk_monitor_get_geometry(monitor, &geo);
unsigned int screen_width = geo.width;
#else
unsigned int screen_width = gdk_screen_width();
#endif
if (zbar->req_width > screen_width) {
float scale = screen_width * .8 / zbar->req_width;
zbar->req_width *= scale;
zbar->req_height *= scale;
}
*minimum_width = zbar->req_width;
*natural_width = zbar->req_width;
}
static void zbar_get_preferred_height(GtkWidget *widget,
gint *minimum_height,
gint *natural_height)
{
ZBarGtk *self = ZBAR_GTK(widget);
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
/* use native video size (max) if available,
* arbitrary defaults otherwise.
* video attributes maintained under main gui idle handler
*/
#if GTK_MAJOR_VERSION >= 3 && GTK_MINOR_VERSION >= 22
GdkRectangle geo;
GdkDisplay *display = gdk_display_get_default();
GdkMonitor *monitor = gdk_display_get_monitor(display, 0);
gdk_monitor_get_geometry(monitor, &geo);
unsigned int screen_height = geo.height;
#else
unsigned int screen_height = gdk_screen_height();
#endif
if (zbar->req_height > screen_height) {
float scale = screen_height * .8 / zbar->req_height;
zbar->req_width *= scale;
zbar->req_height *= scale;
}
*minimum_height = zbar->req_height;
*natural_height = zbar->req_height;
}
static gboolean zbar_gtk_scale_draw(GtkWidget *widget, cairo_t *cr)
{
// NOTE: should we change something here?
ZBarGtk *self = ZBAR_GTK(widget);
if(!self->_private)
return(FALSE);
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
if(gtk_widget_get_visible(widget) &&
gtk_widget_get_mapped(widget) &&
zbar_window_redraw(zbar->window))
return(TRUE);
return(FALSE);
}
#else
static void zbar_gtk_size_request (GtkWidget *widget,
GtkRequisition *requisition)
{
ZBarGtk *self = ZBAR_GTK(widget);
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
/* use native video size (max) if available,
* arbitrary defaults otherwise.
* video attributes maintained under main gui idle handler
*/
requisition->width = zbar->req_width;
requisition->height = zbar->req_height;
}
static gboolean zbar_gtk_expose (GtkWidget *widget,
GdkEventExpose *event)
{
ZBarGtk *self = ZBAR_GTK(widget);
if(!self->_private)
return(FALSE);
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
if(gtk_widget_get_visible(widget) &&
gtk_widget_get_mapped(widget) &&
zbar_window_redraw(zbar->window))
return(TRUE);
return(FALSE);
}
#endif
static void zbar_gtk_size_allocate (GtkWidget *widget,
GtkAllocation *allocation)
{
ZBarGtk *self = ZBAR_GTK(widget);
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
(*GTK_WIDGET_CLASS(zbar_gtk_parent_class)->size_allocate)
(widget, allocation);
if(zbar->window)
zbar_window_resize(zbar->window,
allocation->width, allocation->height);
}
void zbar_gtk_scan_image (ZBarGtk *self,
GdkPixbuf *img)
{
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
g_object_ref(G_OBJECT(img));
/* queue for scanning by the processor idle handler */
GValue *msg = zbar_gtk_new_value(GDK_TYPE_PIXBUF);
/* this grabs a new reference to the image,
* eventually released by the processor idle handler
*/
g_value_set_object(msg, img);
g_async_queue_push(zbar->queue, msg);
}
const char *zbar_gtk_get_video_device (ZBarGtk *self)
{
if(!self->_private)
return(NULL);
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
if(zbar->video_device)
return(zbar->video_device);
else
return("");
}
void zbar_gtk_set_video_device (ZBarGtk *self,
const char *video_device)
{
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
g_free((void*)zbar->video_device);
zbar->video_device = g_strdup(video_device);
zbar->video_enabled = video_device && video_device[0];
/* push another copy to processor idle handler */
GValue *msg = zbar_gtk_new_value(G_TYPE_STRING);
if(video_device)
g_value_set_string(msg, video_device);
else
g_value_set_static_string(msg, "");
g_async_queue_push(zbar->queue, msg);
g_object_freeze_notify(G_OBJECT(self));
g_object_notify(G_OBJECT(self), "video-device");
g_object_notify(G_OBJECT(self), "video-enabled");
g_object_thaw_notify(G_OBJECT(self));
}
gboolean zbar_gtk_get_video_enabled (ZBarGtk *self)
{
if(!self->_private)
return(FALSE);
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
return(zbar->video_enabled);
}
void zbar_gtk_set_video_enabled (ZBarGtk *self,
gboolean video_enabled)
{
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
video_enabled = (video_enabled != FALSE);
if(zbar->video_enabled != video_enabled) {
zbar->video_enabled = video_enabled;
/* push state change to processor idle handler */
GValue *msg = zbar_gtk_new_value(G_TYPE_INT);
g_value_set_int(msg, zbar->video_enabled);
g_async_queue_push(zbar->queue, msg);
g_object_notify(G_OBJECT(self), "video-enabled");
}
}
gboolean zbar_gtk_get_video_opened (ZBarGtk *self)
{
if(!self->_private)
return(FALSE);
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
return(zbar->video_opened);
}
void zbar_gtk_request_video_size (ZBarGtk *self,
int width,
int height)
{
if(!self->_private || width < 0 || height < 0)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
zbar->req_width = zbar->video_width = width;
zbar->req_height = zbar->video_height = height;
gtk_widget_queue_resize(GTK_WIDGET(self));
}
static void zbar_gtk_set_property (GObject *object,
guint prop_id,
const GValue *value,
GParamSpec *pspec)
{
ZBarGtk *self = ZBAR_GTK(object);
switch(prop_id) {
case PROP_VIDEO_DEVICE:
zbar_gtk_set_video_device(self, g_value_get_string(value));
break;
case PROP_VIDEO_ENABLED:
zbar_gtk_set_video_enabled(self, g_value_get_boolean(value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}
static void zbar_gtk_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
ZBarGtk *self = ZBAR_GTK(object);
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
switch(prop_id) {
case PROP_VIDEO_DEVICE:
if(zbar->video_device)
g_value_set_string(value, zbar->video_device);
else
g_value_set_static_string(value, "");
break;
case PROP_VIDEO_ENABLED:
g_value_set_boolean(value, zbar->video_enabled);
break;
case PROP_VIDEO_OPENED:
g_value_set_boolean(value, zbar->video_opened);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID(object, prop_id, pspec);
}
}
static void zbar_gtk_init (ZBarGtk *self)
{
ZBarGtkPrivate *zbar = g_object_new(ZBAR_TYPE_GTK_PRIVATE, NULL);
self->_private = (void*)zbar;
zbar->window = zbar_window_create();
g_assert(zbar->window);
zbar->req_width = zbar->video_width = DEFAULT_WIDTH;
zbar->req_height = zbar->video_height = DEFAULT_HEIGHT;
/* use a queue to signalize about the need to handle decoding and video */
zbar->queue = g_async_queue_new();
zbar->idle_id = g_idle_add(zbar_processing_idle_callback, self);
zbar->video_enabled_state = FALSE;
/* Prepare for idle handler */
g_object_ref(zbar);
g_assert(zbar->queue);
g_async_queue_ref(zbar->queue);
zbar->scanner = zbar_image_scanner_create();
g_assert(zbar->scanner);
}
static void zbar_gtk_dispose (GObject *object)
{
ZBarGtk *self = ZBAR_GTK(object);
if(!self->_private)
return;
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(self->_private);
self->_private = NULL;
g_free((void*)zbar->video_device);
zbar->video_device = NULL;
/* signal processor idle handler to exit */
GValue *msg = zbar_gtk_new_value(G_TYPE_INT);
g_value_set_int(msg, -1);
g_async_queue_push(zbar->queue, msg);
zbar->idle_id = 0;
/* there are no external references which might call other APIs */
g_async_queue_unref(zbar->queue);
g_object_unref(G_OBJECT(zbar));
}
static void zbar_gtk_private_finalize (GObject *object)
{
ZBarGtkPrivate *zbar = ZBAR_GTK_PRIVATE(object);
if (zbar->idle_id) {
if(zbar->window)
zbar_window_draw(zbar->window, NULL);
g_object_unref(zbar);
g_source_remove(zbar->idle_id);
zbar->idle_id = 0;
}
if(zbar->window) {
zbar_window_destroy(zbar->window);
zbar->window = NULL;
}
if(zbar->scanner) {
zbar_image_scanner_destroy(zbar->scanner);
zbar->scanner = NULL;
}
if(zbar->video) {
zbar_video_destroy(zbar->video);
zbar->video = NULL;
}
g_async_queue_unref(zbar->queue);
zbar->queue = NULL;
}
static void zbar_gtk_class_init (ZBarGtkClass *klass)
{
zbar_gtk_parent_class = g_type_class_peek_parent(klass);
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->dispose = zbar_gtk_dispose;
object_class->set_property = zbar_gtk_set_property;
object_class->get_property = zbar_gtk_get_property;
GtkWidgetClass *widget_class = (GtkWidgetClass*)klass;
widget_class->realize = zbar_gtk_realize;
widget_class->unrealize = zbar_gtk_unrealize;
#if GTK_MAJOR_VERSION >= 3
widget_class->get_preferred_width = zbar_get_preferred_width;
widget_class->get_preferred_height = zbar_get_preferred_height;
widget_class->draw = zbar_gtk_scale_draw;
#else
widget_class->size_request = zbar_gtk_size_request;
widget_class->expose_event = zbar_gtk_expose;
#endif
widget_class->size_allocate = zbar_gtk_size_allocate;
widget_class->unmap = NULL;
zbar_gtk_signals[DECODED] =
g_signal_new("decoded",
G_TYPE_FROM_CLASS(object_class),
G_SIGNAL_RUN_CLEANUP,
G_STRUCT_OFFSET(ZBarGtkClass, decoded),
NULL, NULL,
zbar_marshal_VOID__INT_STRING,
G_TYPE_NONE, 2,
G_TYPE_INT, G_TYPE_STRING);
zbar_gtk_signals[DECODED_TEXT] =
g_signal_new("decoded-text",
G_TYPE_FROM_CLASS(object_class),
G_SIGNAL_RUN_CLEANUP,
G_STRUCT_OFFSET(ZBarGtkClass, decoded_text),
NULL, NULL,
g_cclosure_marshal_VOID__STRING,
G_TYPE_NONE, 1,
G_TYPE_STRING);
GParamSpec *p = g_param_spec_string("video-device",
"Video device",
"the platform specific name of the video device",
NULL,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(object_class, PROP_VIDEO_DEVICE, p);
p = g_param_spec_boolean("video-enabled",
"Video enabled",
"controls streaming from the video device",
FALSE,
G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(object_class, PROP_VIDEO_ENABLED, p);
p = g_param_spec_boolean("video-opened",
"Video opened",
"current opened state of the video device",
FALSE,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS);
g_object_class_install_property(object_class, PROP_VIDEO_OPENED, p);
}
static void zbar_gtk_private_class_init (ZBarGtkPrivateClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS(klass);
object_class->finalize = zbar_gtk_private_finalize;
}
static GType zbar_gtk_private_get_type (void)
{
static GType type = 0;
if(!type) {
static const GTypeInfo info = {
sizeof(ZBarGtkPrivateClass),
NULL, NULL,
(GClassInitFunc)zbar_gtk_private_class_init,
NULL, NULL,
sizeof(ZBarGtkPrivate),
};
type = g_type_register_static(G_TYPE_OBJECT, "ZBarGtkPrivate",
&info, 0);
}
return(type);
}
GtkWidget *zbar_gtk_new (void)
{
return(GTK_WIDGET(g_object_new(ZBAR_TYPE_GTK, NULL)));
}

101
gtk/zbargtkprivate.h Normal file
View File

@ -0,0 +1,101 @@
/*------------------------------------------------------------------------
* Copyright 2008-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
*
* This file is part of the ZBar Bar Code Reader.
*
* The ZBar Bar Code Reader is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* The ZBar Bar Code Reader is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser Public License
* along with the ZBar Bar Code Reader; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* http://sourceforge.net/projects/zbar
*------------------------------------------------------------------------*/
#ifndef __ZBAR_GTK_PRIVATE_H__
#define __ZBAR_GTK_PRIVATE_H__
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <zbar.h>
G_BEGIN_DECLS
#define ZBAR_TYPE_GTK_PRIVATE (zbar_gtk_private_get_type())
#define ZBAR_GTK_PRIVATE(obj) \
(G_TYPE_CHECK_INSTANCE_CAST((obj), ZBAR_TYPE_GTK_PRIVATE, ZBarGtkPrivate))
#define ZBAR_GTK_PRIVATE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_CAST((klass), ZBAR_TYPE_GTK_PRIVATE, ZBarGtkPrivateClass))
#define ZBAR_IS_GTK_PRIVATE(obj) \
(G_TYPE_CHECK_INSTANCE_TYPE((obj), ZBAR_TYPE_GTK_PRIVATE))
#define ZBAR_IS_GTK_PRIVATE_CLASS(klass) \
(G_TYPE_CHECK_CLASS_TYPE((klass), ZBAR_TYPE_GTK_PRIVATE))
#define ZBAR_GTK_PRIVATE_GET_CLASS(obj) \
(G_TYPE_INSTANCE_GET_CLASS((obj), ZBAR_TYPE_GTK_PRIVATE, ZBarGtkPrivateClass))
/* zbar widget processor thread shared/private data */
typedef struct _ZBarGtkPrivate
{
GObject object;
/* these are all owned by the main gui thread */
gint idle_id;
const char *video_device;
gboolean video_enabled, video_enabled_state;
/* messages are queued from the gui thread to the processor thread.
* each message is a GValue containing one of:
* - G_TYPE_INT: state change
* 1 = video enable
* 0 = video disable
* -1 = terminate processor thread
* - G_TYPE_STRING: a named video device to open ("" to close)
* - GDK_TYPE_PIXBUF: an image to scan
*/
GAsyncQueue *queue;
/* current processor state is shared:
* written by processor thread just after opening video or
* scanning an image, read by main gui thread during size_request.
* protected by main gui lock
*/
unsigned req_width, req_height;
unsigned video_width, video_height;
gboolean video_opened;
/* window is shared: owned by main gui thread.
* processor thread only calls draw() and negotiate_format().
* protected by main gui lock (and internal lock)
*/
zbar_window_t *window;
/* video and scanner are owned by the processor thread */
zbar_video_t *video;
zbar_image_scanner_t *scanner;
} ZBarGtkPrivate;
typedef struct _ZBarGtkPrivateClass
{
GObjectClass parent_class;
} ZBarGtkPrivateClass;
static GType zbar_gtk_private_get_type(void) G_GNUC_CONST;
G_END_DECLS
#endif

1
gtk/zbarmarshal.list Normal file
View File

@ -0,0 +1 @@
VOID:INT,STRING

13
include/Makefile.am.inc Normal file
View File

@ -0,0 +1,13 @@
zincludedir = $(includedir)/zbar
include_HEADERS = include/zbar.h
zinclude_HEADERS = include/zbar/Scanner.h include/zbar/Decoder.h \
include/zbar/Exception.h include/zbar/Symbol.h include/zbar/Image.h \
include/zbar/ImageScanner.h include/zbar/Video.h include/zbar/Window.h \
include/zbar/Processor.h
if HAVE_GTK
zinclude_HEADERS += include/zbar/zbargtk.h
endif
if HAVE_QT
zinclude_HEADERS += include/zbar/QZBar.h include/zbar/QZBarImage.h
endif

1655
include/zbar.h Normal file

File diff suppressed because it is too large Load Diff

202
include/zbar/Decoder.h Normal file
View File

@ -0,0 +1,202 @@
//------------------------------------------------------------------------
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_DECODER_H_
#define _ZBAR_DECODER_H_
/// @file
/// Decoder C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Decoder.h"
#endif
#include <string>
namespace zbar {
/// low-level bar width stream decoder interface.
/// identifies symbols and extracts encoded data
class Decoder {
public:
/// Decoder result handler.
/// applications should subtype this and pass an instance to
/// set_handler() to implement result processing
class Handler {
public:
virtual ~Handler() { }
/// invoked by the Decoder as decode results become available.
virtual void decode_callback(Decoder &decoder) = 0;
};
/// constructor.
Decoder ()
: _handler(NULL)
{
_decoder = zbar_decoder_create();
}
~Decoder ()
{
zbar_decoder_destroy(_decoder);
}
/// clear all decoder state.
/// see zbar_decoder_reset()
void reset ()
{
zbar_decoder_reset(_decoder);
}
/// mark start of a new scan pass.
/// see zbar_decoder_new_scan()
void new_scan ()
{
zbar_decoder_new_scan(_decoder);
}
/// process next bar/space width from input stream.
/// see zbar_decode_width()
zbar_symbol_type_t decode_width (unsigned width)
{
return(zbar_decode_width(_decoder, width));
}
/// process next bar/space width from input stream.
/// see zbar_decode_width()
Decoder& operator<< (unsigned width)
{
zbar_decode_width(_decoder, width);
return(*this);
}
/// retrieve color of @em next element passed to Decoder.
/// see zbar_decoder_get_color()
zbar_color_t get_color () const
{
return(zbar_decoder_get_color(_decoder));
}
/// retrieve last decoded symbol type.
/// see zbar_decoder_get_type()
zbar_symbol_type_t get_type () const
{
return(zbar_decoder_get_type(_decoder));
}
/// retrieve string name of last decoded symbol type.
/// see zbar_get_symbol_name()
const char *get_symbol_name () const
{
return(zbar_get_symbol_name(zbar_decoder_get_type(_decoder)));
}
/// retrieve string name for last decode addon.
/// see zbar_get_addon_name()
/// @deprecated in 0.11
const char *get_addon_name () const
{
return(zbar_get_addon_name(zbar_decoder_get_type(_decoder)));
}
/// retrieve last decoded data in ASCII format as a char array.
/// see zbar_decoder_get_data()
const char *get_data_chars() const
{
return(zbar_decoder_get_data(_decoder));
}
/// retrieve last decoded data as a std::string.
/// see zbar_decoder_get_data()
const std::string get_data_string() const
{
return(std::string(zbar_decoder_get_data(_decoder),
zbar_decoder_get_data_length(_decoder)));
}
/// retrieve last decoded data as a std::string.
/// see zbar_decoder_get_data()
const std::string get_data() const
{
return(get_data_string());
}
/// retrieve length of decoded binary data.
/// see zbar_decoder_get_data_length()
int get_data_length() const
{
return(zbar_decoder_get_data_length(_decoder));
}
/// retrieve last decode direction.
/// see zbar_decoder_get_direction()
/// @since 0.11
int get_direction() const
{
return(zbar_decoder_get_direction(_decoder));
}
/// setup callback to handle result data.
void set_handler (Handler &handler)
{
_handler = &handler;
zbar_decoder_set_handler(_decoder, _cb);
zbar_decoder_set_userdata(_decoder, this);
}
/// set config for indicated symbology (0 for all) to specified value.
/// @see zbar_decoder_set_config()
/// @since 0.4
int set_config (zbar_symbol_type_t symbology,
zbar_config_t config,
int value)
{
return(zbar_decoder_set_config(_decoder, symbology, config, value));
}
/// set config parsed from configuration string.
/// @see zbar_decoder_parse_config()
/// @since 0.4
int set_config (std::string cfgstr)
{
return(zbar_decoder_parse_config(_decoder, cfgstr.c_str()));
}
private:
friend class Scanner;
zbar_decoder_t *_decoder;
Handler *_handler;
static void _cb (zbar_decoder_t *cdcode)
{
Decoder *dcode = (Decoder*)zbar_decoder_get_userdata(cdcode);
if(dcode && dcode->_handler)
dcode->_handler->decode_callback(*dcode);
}
};
}
#endif

188
include/zbar/Exception.h Normal file
View File

@ -0,0 +1,188 @@
//------------------------------------------------------------------------
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_EXCEPTION_H_
#define _ZBAR_EXCEPTION_H_
/// @file
/// C++ Exception definitions
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Exception.h"
#endif
#include <cstddef>
#include <exception>
#include <new>
namespace zbar {
/// base class for exceptions defined by this API.
class Exception : public std::exception {
public:
/// create exception from C library error
Exception (const void *obj = NULL)
: std::exception(),
_obj(obj)
{ }
~Exception () throw() { }
/// retrieve error message
virtual const char* what () const throw()
{
if(!_obj)
return("zbar library unspecified generic error");
return(_zbar_error_string(_obj, 0));
}
private:
const void *_obj;
};
/// internal library error.
class InternalError : public Exception {
public:
/// create exception from C library error
InternalError (const void *obj)
: Exception(obj)
{ }
};
/// unsupported request.
class UnsupportedError : public Exception {
public:
/// create exception from C library error
UnsupportedError (const void *obj)
: Exception(obj)
{ }
};
/// invalid request.
class InvalidError : public Exception {
public:
/// create exception from C library error
InvalidError (const void *obj)
: Exception(obj)
{ }
};
/// failed system call.
class SystemError : public Exception {
public:
/// create exception from C library error
SystemError (const void *obj)
: Exception(obj)
{ }
};
/// locking error.
class LockingError : public Exception {
public:
/// create exception from C library error
LockingError (const void *obj)
: Exception(obj)
{ }
};
/// all resources busy.
class BusyError : public Exception {
public:
/// create exception from C library error
BusyError (const void *obj)
: Exception(obj)
{ }
};
/// X11 display error.
class XDisplayError : public Exception {
public:
/// create exception from C library error
XDisplayError (const void *obj)
: Exception(obj)
{ }
};
/// X11 protocol error.
class XProtoError : public Exception {
public:
/// create exception from C library error
XProtoError (const void *obj)
: Exception(obj)
{ }
};
/// output window is closed.
class ClosedError : public Exception {
public:
/// create exception from C library error
ClosedError (const void *obj)
: Exception(obj)
{ }
};
/// image format error
class FormatError : public Exception {
// FIXME needs c equivalent
virtual const char* what () const throw()
{
// FIXME what format?
return("unsupported format");
}
};
/// @internal
/// extract error information and create exception.
static inline std::exception throw_exception (const void *obj)
{
switch(_zbar_get_error_code(obj)) {
case ZBAR_ERR_NOMEM:
throw std::bad_alloc();
case ZBAR_ERR_INTERNAL:
throw InternalError(obj);
case ZBAR_ERR_UNSUPPORTED:
throw UnsupportedError(obj);
case ZBAR_ERR_INVALID:
throw InvalidError(obj);
case ZBAR_ERR_SYSTEM:
throw SystemError(obj);
case ZBAR_ERR_LOCKING:
throw LockingError(obj);
case ZBAR_ERR_BUSY:
throw BusyError(obj);
case ZBAR_ERR_XDISPLAY:
throw XDisplayError(obj);
case ZBAR_ERR_XPROTO:
throw XProtoError(obj);
case ZBAR_ERR_CLOSED:
throw ClosedError(obj);
default:
throw Exception(obj);
}
}
}
#endif

329
include/zbar/Image.h Normal file
View File

@ -0,0 +1,329 @@
//------------------------------------------------------------------------
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_IMAGE_H_
#define _ZBAR_IMAGE_H_
/// @file
/// Image C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Image.h"
#endif
#include <assert.h>
#include <iterator>
#include "Symbol.h"
#include "Exception.h"
namespace zbar {
class Video;
/// stores image data samples along with associated format and size
/// metadata
class Image {
public:
/// general Image result handler.
/// applications should subtype this and pass an instance to
/// eg. ImageScanner::set_handler() to implement result processing
class Handler {
public:
virtual ~Handler() { }
/// invoked by library when Image should be processed
virtual void image_callback(Image &image) = 0;
/// cast this handler to the C handler
operator zbar_image_data_handler_t* () const
{
return(_cb);
}
private:
static void _cb (zbar_image_t *zimg,
const void *userdata)
{
if(userdata) {
Image *image = (Image*)zbar_image_get_userdata(zimg);
if(image)
((Handler*)userdata)->image_callback(*image);
else {
Image tmp(zimg, 1);
((Handler*)userdata)->image_callback(tmp);
}
}
}
};
class SymbolIterator : public zbar::SymbolIterator {
public:
/// default constructor.
SymbolIterator ()
: zbar::SymbolIterator()
{ }
/// constructor.
SymbolIterator (const SymbolSet &syms)
: zbar::SymbolIterator(syms)
{ }
/// copy constructor.
SymbolIterator (const SymbolIterator& iter)
: zbar::SymbolIterator(iter)
{ }
};
/// constructor.
/// create a new Image with the specified parameters
Image (unsigned width = 0,
unsigned height = 0,
const std::string& format = "",
const void *data = NULL,
unsigned long length = 0)
: _img(zbar_image_create())
{
zbar_image_set_userdata(_img, this);
if(width && height)
set_size(width, height);
if(format.length())
set_format(format);
if(data && length)
set_data(data, length);
}
~Image ()
{
if(zbar_image_get_userdata(_img) == this)
zbar_image_set_userdata(_img, NULL);
zbar_image_ref(_img, -1);
}
/// cast to C image object
operator const zbar_image_t* () const
{
return(_img);
}
/// cast to C image object
operator zbar_image_t* ()
{
return(_img);
}
/// retrieve the image format.
/// see zbar_image_get_format()
unsigned long get_format () const
{
return(zbar_image_get_format(_img));
}
/// specify the fourcc image format code for image sample data.
/// see zbar_image_set_format()
void set_format (unsigned long format)
{
zbar_image_set_format(_img, format);
}
/// specify the fourcc image format code for image sample data.
/// see zbar_image_set_format()
void set_format (const std::string& format)
{
unsigned long fourcc = zbar_fourcc_parse(format.c_str());
zbar_image_set_format(_img, fourcc);
}
/// retrieve a "sequence" (page/frame) number associated with this
/// image.
/// see zbar_image_get_sequence()
/// @since 0.6
unsigned get_sequence () const
{
return(zbar_image_get_sequence(_img));
}
/// associate a "sequence" (page/frame) number with this image.
/// see zbar_image_set_sequence()
/// @since 0.6
void set_sequence (unsigned sequence_num)
{
zbar_image_set_sequence(_img, sequence_num);
}
/// retrieve the width of the image.
/// see zbar_image_get_width()
unsigned get_width () const
{
return(zbar_image_get_width(_img));
}
/// retrieve the height of the image.
/// see zbar_image_get_height()
unsigned get_height () const
{
return(zbar_image_get_height(_img));
}
/// retrieve both dimensions of the image.
/// see zbar_image_get_size()
/// @since 0.11
void get_size (unsigned &width,
unsigned &height) const
{
zbar_image_get_size(_img, &width, &height);
}
/// specify the pixel size of the image.
/// see zbar_image_set_size()
void set_size (unsigned width,
unsigned height)
{
zbar_image_set_size(_img, width, height);
}
/// retrieve the scan crop rectangle.
/// see zbar_image_get_crop()
void get_crop (unsigned &x,
unsigned &y,
unsigned &width,
unsigned &height) const
{
zbar_image_get_crop(_img, &x, &y, &width, &height);
}
/// set the scan crop rectangle.
/// see zbar_image_set_crop()
void set_crop (unsigned x,
unsigned y,
unsigned width,
unsigned height)
{
zbar_image_set_crop(_img, x, y, width, height);
}
/// return the image sample data.
/// see zbar_image_get_data()
const void *get_data () const
{
return(zbar_image_get_data(_img));
}
/// return the size of the image sample data.
/// see zbar_image_get_data_length()
/// @since 0.6
unsigned long get_data_length () const
{
return(zbar_image_get_data_length(_img));
}
/// specify image sample data.
/// see zbar_image_set_data()
void set_data (const void *data,
unsigned long length)
{
zbar_image_set_data(_img, data, length, _cleanup);
}
/// image format conversion.
/// see zbar_image_convert()
Image convert (unsigned long format) const
{
zbar_image_t *img = zbar_image_convert(_img, format);
if(img)
return(Image(img));
throw FormatError();
}
/// image format conversion.
/// see zbar_image_convert()
/// @since 0.11
Image convert (std::string format) const
{
unsigned long fourcc = zbar_fourcc_parse(format.c_str());
return(convert(fourcc));
}
/// image format conversion with crop/pad.
/// see zbar_image_convert_resize()
/// @since 0.4
Image convert (unsigned long format,
unsigned width,
unsigned height) const
{
zbar_image_t *img =
zbar_image_convert_resize(_img, format, width, height);
if(img)
return(Image(img));
throw FormatError();
}
const SymbolSet get_symbols () const {
return(SymbolSet(zbar_image_get_symbols(_img)));
}
void set_symbols (const SymbolSet &syms) {
zbar_image_set_symbols(_img, syms);
}
/// create a new SymbolIterator over decoded results.
SymbolIterator symbol_begin () const {
return(SymbolIterator(get_symbols()));
}
/// return a SymbolIterator suitable for ending iteration.
SymbolIterator symbol_end () const {
return(SymbolIterator());
}
protected:
friend class Video;
/// constructor.
/// @internal
/// create a new Image from a zbar_image_t C object
Image (zbar_image_t *src,
int refs = 0)
: _img(src)
{
if(refs)
zbar_image_ref(_img, refs);
zbar_image_set_userdata(_img, this);
}
/// default data cleanup (noop)
/// @internal
static void _cleanup (zbar_image_t *img)
{
// by default nothing is cleaned
assert(img);
}
private:
zbar_image_t *_img;
};
}
#endif

149
include/zbar/ImageScanner.h Normal file
View File

@ -0,0 +1,149 @@
//------------------------------------------------------------------------
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_IMAGE_SCANNER_H_
#define _ZBAR_IMAGE_SCANNER_H_
/// @file
/// Image Scanner C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/ImageScanner.h"
#endif
#include "Image.h"
namespace zbar {
/// mid-level image scanner interface.
/// reads barcodes from a 2-D Image
class ImageScanner {
public:
/// constructor.
ImageScanner (zbar_image_scanner_t *scanner = NULL)
{
if(scanner)
_scanner = scanner;
else
_scanner = zbar_image_scanner_create();
}
~ImageScanner ()
{
zbar_image_scanner_destroy(_scanner);
}
/// cast to C image_scanner object
operator zbar_image_scanner_t* () const
{
return(_scanner);
}
/// setup result handler callback.
void set_handler (Image::Handler &handler)
{
zbar_image_scanner_set_data_handler(_scanner, handler, &handler);
}
/// request sending decoded codes via D-Bus
/// @see zbar_processor_parse_config()
/// @since 0.21
int request_dbus(bool enabled)
{
return zbar_image_scanner_request_dbus(_scanner, enabled);
}
/// set config for indicated symbology (0 for all) to specified value.
/// @see zbar_image_scanner_set_config()
/// @since 0.4
int set_config (zbar_symbol_type_t symbology,
zbar_config_t config,
int value)
{
return(zbar_image_scanner_set_config(_scanner, symbology,
config, value));
}
/// set config for indicated symbology (0 for all) to specified value.
/// @see zbar_image_scanner_set_config()
/// @since 0.22
int get_config (zbar_symbol_type_t symbology,
zbar_config_t config,
int &value)
{
return(zbar_image_scanner_get_config(_scanner, symbology,
config, &value));
}
/// set config parsed from configuration string.
/// @see zbar_image_scanner_parse_config()
/// @since 0.4
int set_config (std::string cfgstr)
{
return(zbar_image_scanner_parse_config(_scanner, cfgstr.c_str()));
}
/// enable or disable the inter-image result cache.
/// see zbar_image_scanner_enable_cache()
void enable_cache (bool enable = true)
{
zbar_image_scanner_enable_cache(_scanner, enable);
}
/// remove previous results from scanner and image.
/// @see zbar_image_scanner_recycle_image()
/// @since 0.10
void recycle_image (Image &image)
{
zbar_image_scanner_recycle_image(_scanner, image);
}
/// retrieve decode results for last scanned image.
/// @see zbar_image_scanner_get_results()
/// @since 0.10
const SymbolSet get_results () const {
return(SymbolSet(zbar_image_scanner_get_results(_scanner)));
}
/// scan for symbols in provided image.
/// see zbar_scan_image()
int scan (Image& image)
{
return(zbar_scan_image(_scanner, image));
}
/// scan for symbols in provided image.
/// see zbar_scan_image()
ImageScanner& operator<< (Image& image)
{
scan(image);
return(*this);
}
private:
zbar_image_scanner_t *_scanner;
};
}
#endif

223
include/zbar/Processor.h Normal file
View File

@ -0,0 +1,223 @@
//------------------------------------------------------------------------
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_PROCESSOR_H_
#define _ZBAR_PROCESSOR_H_
/// @file
/// Processor C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Processor.h"
#endif
#include "Exception.h"
#include "Image.h"
namespace zbar {
/// high-level self-contained image processor.
/// processes video and images for barcodes, optionally displaying
/// images to a library owned output window
class Processor {
public:
/// value to pass for no timeout.
static const int FOREVER = -1;
/// constructor.
Processor (bool threaded = true,
const char *video_device = "",
bool enable_display = true)
{
_processor = zbar_processor_create(threaded);
if(!_processor)
throw std::bad_alloc();
init(video_device, enable_display);
}
~Processor ()
{
zbar_processor_destroy(_processor);
}
/// cast to C processor object.
operator zbar_processor_t* ()
{
return(_processor);
}
/// opens a video input device and/or prepares to display output.
/// see zbar_processor_init()
void init (const char *video_device = "",
bool enable_display = true)
{
if(zbar_processor_init(_processor, video_device, enable_display))
throw_exception(_processor);
}
/// setup result handler callback.
/// see zbar_processor_set_data_handler()
void set_handler (Image::Handler& handler)
{
zbar_processor_set_data_handler(_processor, handler, &handler);
}
/// set config for indicated symbology (0 for all) to specified value.
/// @see zbar_processor_set_config()
/// @since 0.4
int set_config (zbar_symbol_type_t symbology,
zbar_config_t config,
int value)
{
return(zbar_processor_set_config(_processor, symbology,
config, value));
}
/// set config parsed from configuration string.
/// @see zbar_processor_parse_config()
/// @since 0.4
int set_config (std::string cfgstr)
{
return(zbar_processor_parse_config(_processor, cfgstr.c_str()));
}
/// retrieve the current state of the output window.
/// see zbar_processor_is_visible()
bool is_visible ()
{
int rc = zbar_processor_is_visible(_processor);
if(rc < 0)
throw_exception(_processor);
return(rc != 0);
}
/// show or hide the display window owned by the library.
/// see zbar_processor_set_visible()
void set_visible (bool visible = true)
{
if(zbar_processor_set_visible(_processor, visible) < 0)
throw_exception(_processor);
}
/// control the processor in free running video mode.
/// see zbar_processor_set_active()
void set_active (bool active = true)
{
if(zbar_processor_set_active(_processor, active) < 0)
throw_exception(_processor);
}
/// retrieve decode results for last scanned image.
/// @see zbar_processor_get_results()
/// @since 0.10
const SymbolSet get_results () const {
return(SymbolSet(zbar_processor_get_results(_processor)));
}
/// wait for input to the display window from the user.
/// see zbar_processor_user_wait()
int user_wait (int timeout = FOREVER)
{
int rc = zbar_processor_user_wait(_processor, timeout);
if(rc < 0)
throw_exception(_processor);
return(rc);
}
/// process from the video stream until a result is available.
/// see zbar_process_one()
void process_one (int timeout = FOREVER)
{
if(zbar_process_one(_processor, timeout) < 0)
throw_exception(_processor);
}
/// process the provided image for barcodes.
/// see zbar_process_image()
void process_image (Image& image)
{
if(zbar_process_image(_processor, image) < 0)
throw_exception(_processor);
}
/// process the provided image for barcodes.
/// see zbar_process_image()
Processor& operator<< (Image& image)
{
process_image(image);
return(*this);
}
/// force specific input and output formats for debug/testing.
/// see zbar_processor_force_format()
void force_format (unsigned long input_format,
unsigned long output_format)
{
if(zbar_processor_force_format(_processor, input_format,
output_format))
throw_exception(_processor);
}
/// force specific input and output formats for debug/testing.
/// see zbar_processor_force_format()
void force_format (std::string& input_format,
std::string& output_format)
{
unsigned long ifourcc = zbar_fourcc_parse(input_format.c_str());
unsigned long ofourcc = zbar_fourcc_parse(output_format.c_str());
if(zbar_processor_force_format(_processor, ifourcc, ofourcc))
throw_exception(_processor);
}
/// request a preferred size for the video image from the device.
/// see zbar_processor_request_size()
/// @since 0.6
void request_size (int width, int height)
{
zbar_processor_request_size(_processor, width, height);
}
/// request a preferred driver interface version for debug/testing.
/// see zbar_processor_request_interface()
/// @since 0.6
void request_interface (int version)
{
zbar_processor_request_interface(_processor, version);
}
/// request a preferred I/O mode for debug/testing.
/// see zbar_processor_request_iomode()
/// @since 0.7
void request_iomode (int iomode)
{
if(zbar_processor_request_iomode(_processor, iomode))
throw_exception(_processor);
}
private:
zbar_processor_t *_processor;
};
}
#endif

215
include/zbar/QZBar.h Normal file
View File

@ -0,0 +1,215 @@
//------------------------------------------------------------------------
// Copyright 2008-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _QZBAR_H_
#define _QZBAR_H_
/// @file
/// Barcode Reader Qt4 Widget
#include <QtGui>
#if QT_VERSION >= 0x050000
# include <QtWidgets>
#else
# include <qwidget.h>
#endif
#include <zbar.h>
namespace zbar {
class QZBarThread;
/// barcode reader Qt4 widget.
/// embeds a barcode reader directly into a Qt4 based GUI. the widget
/// can process barcodes from a video source (using the QZBar::videoDevice
/// and QZBar::videoEnabled properties) or from individual QImages
/// supplied to the QZBar::scanImage() slot
/// @since 1.5
class QZBar : public QWidget
{
Q_OBJECT
/// the currently opened video device.
///
/// setting a new device opens it and automatically sets
/// QZBar::videoEnabled
///
/// @see videoDevice(), setVideoDevice()
Q_PROPERTY(QString videoDevice
READ videoDevice
WRITE setVideoDevice
DESIGNABLE false)
/// video device streaming state.
///
/// use to pause/resume video scanning.
///
/// @see isVideoEnabled(), setVideoEnabled()
Q_PROPERTY(bool videoEnabled
READ isVideoEnabled
WRITE setVideoEnabled
DESIGNABLE false)
/// video device opened state.
///
/// (re)setting QZBar::videoDevice should eventually cause it
/// to be opened or closed. any errors while streaming/scanning
/// will also cause the device to be closed
///
/// @see isVideoOpened()
Q_PROPERTY(bool videoOpened
READ isVideoOpened
DESIGNABLE false)
public:
// Should match the types at video_control_type_e
// get_controls() will do the mapping between the two types.
enum ControlType {
Unknown,
Integer,
Menu,
Button,
Integer64,
String,
Boolean,
};
/// constructs a barcode reader widget with the given @a parent
QZBar(QWidget *parent = NULL, int verbosity = 0);
~QZBar();
/// retrieve the currently opened video device.
/// @returns the current video device or the empty string if no
/// device is opened
QString videoDevice() const;
/// retrieve the current video enabled state.
/// @returns true if video scanning is currently enabled, false
/// otherwise
bool isVideoEnabled() const;
/// retrieve the current video opened state.
/// @returns true if video device is currently opened, false otherwise
bool isVideoOpened() const;
/// @{
/// @internal
QSize sizeHint() const;
int heightForWidth(int) const;
QPaintEngine *paintEngine() const;
/// @}
public Q_SLOTS:
/// open a new video device.
///
/// use an empty string to close a currently opened device.
///
/// @note since opening a device may take some time, this call will
/// return immediately and the device will be opened asynchronously
void setVideoDevice(const QString &videoDevice);
/// enable/disable video scanning.
/// has no effect unless a video device is opened
void setVideoEnabled(bool videoEnabled = true);
/// scan for barcodes in a QImage.
void scanImage(const QImage &image);
/// get controls from the camera device
int get_controls(int index, char **name = NULL, char **group = NULL,
enum ControlType *type = NULL,
int *min = NULL, int *max = NULL,
int *def = NULL, int *step = NULL);
/// Get items for control menus
QVector< QPair< int , QString > > get_menu(int index);
// get/set controls from the camera device
int set_control(char *name, bool value);
int set_control(char *name, int value);
int get_control(char *name, bool *value);
int get_control(char *name, int *value);
int set_config(std::string cfgstr);
int set_config(zbar_symbol_type_t symbology,
zbar_config_t config,
int value);
int get_config(zbar_symbol_type_t symbology,
zbar_config_t config,
int &value);
void request_size(unsigned width, unsigned height, bool trigger = true);
int get_resolution(int index, unsigned &width, unsigned &height, float &max_fps);
unsigned videoWidth();
unsigned videoHeight();
int request_dbus(bool enabled);
Q_SIGNALS:
/// emitted when when a video device is opened or closed.
///
/// (re)setting QZBar::videoDevice should eventually cause it
/// to be opened or closed. any errors while streaming/scanning
/// will also cause the device to be closed
void videoOpened(bool videoOpened);
/// emitted when a barcode is decoded from an image.
/// the symbol type and contained data are provided as separate
/// parameters.
void decoded(int type, const QString &data);
/// emitted when a barcode is decoded from an image.
/// the symbol type name is prefixed to the data, separated by a
/// colon
void decodedText(const QString &text);
/// @{
/// @internal
protected:
void attach();
void showEvent(QShowEvent*);
void paintEvent(QPaintEvent*);
void resizeEvent(QResizeEvent*);
void changeEvent(QEvent*);
void dragEnterEvent(QDragEnterEvent*);
void dropEvent(QDropEvent*);
protected Q_SLOTS:
void sizeChange();
/// @}
private:
QZBarThread *thread;
QString _videoDevice;
bool _videoEnabled;
bool _attached;
};
};
#endif

78
include/zbar/QZBarImage.h Normal file
View File

@ -0,0 +1,78 @@
//------------------------------------------------------------------------
// Copyright 2008-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _QZBARIMAGE_H_
#define _QZBARIMAGE_H_
/// @file
/// QImage to Image type conversion wrapper
#include <qimage.h>
#include <zbar.h>
namespace zbar {
/// wrap a QImage and convert into a format suitable for scanning.
class QZBarImage
: public Image
{
public:
/// construct a zbar library image based on an existing QImage.
QZBarImage (const QImage &qimg)
: qimg(qimg)
{
QImage::Format fmt = qimg.format();
if(fmt != QImage::Format_RGB32 &&
fmt != QImage::Format_ARGB32 &&
fmt != QImage::Format_ARGB32_Premultiplied)
throw FormatError();
unsigned bpl = qimg.bytesPerLine();
unsigned width = bpl / 4;
unsigned height = qimg.height();
set_size(width, height);
set_format(zbar_fourcc('B','G','R','4'));
#if QT_VERSION >= QT_VERSION_CHECK(5,10,0)
unsigned long datalen = qimg.sizeInBytes();
#elif QT_VERSION >= QT_VERSION_CHECK(5,0,0)
unsigned long datalen = qimg.byteCount();
#else
unsigned long datalen = qimg.numBytes();
#endif
set_data(qimg.bits(), datalen);
if((width * 4 != bpl) ||
(width * height * 4 > datalen))
throw FormatError();
}
private:
QImage qimg;
};
};
#endif

162
include/zbar/Scanner.h Normal file
View File

@ -0,0 +1,162 @@
//------------------------------------------------------------------------
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_SCANNER_H_
#define _ZBAR_SCANNER_H_
/// @file
/// Scanner C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Scanner.h"
#endif
#include <stdio.h>
namespace zbar {
/// low-level linear intensity sample stream scanner interface.
/// identifies "bar" edges and measures width between them.
/// optionally passes to bar width Decoder
class Scanner {
public:
/// constructor.
/// @param decoder reference to a Decoder instance which will
/// be passed scan results automatically
Scanner (Decoder& decoder)
{
_scanner = zbar_scanner_create(decoder._decoder);
}
/// constructor.
/// @param decoder pointer to a Decoder instance which will
/// be passed scan results automatically
Scanner (Decoder* decoder = NULL)
{
zbar_decoder_t *zdcode = NULL;
if(decoder)
zdcode = decoder->_decoder;
_scanner = zbar_scanner_create(zdcode);
}
~Scanner ()
{
zbar_scanner_destroy(_scanner);
}
/// clear all scanner state.
/// see zbar_scanner_reset()
void reset ()
{
zbar_scanner_reset(_scanner);
}
/// mark start of a new scan pass.
/// see zbar_scanner_new_scan()
zbar_symbol_type_t new_scan ()
{
_type = zbar_scanner_new_scan(_scanner);
return(_type);
}
/// flush scanner pipeline.
/// see zbar_scanner_flush()
zbar_symbol_type_t flush ()
{
_type = zbar_scanner_flush(_scanner);
return(_type);
}
/// process next sample intensity value.
/// see zbar_scan_y()
zbar_symbol_type_t scan_y (int y)
{
_type = zbar_scan_y(_scanner, y);
return(_type);
}
/// process next sample intensity value.
/// see zbar_scan_y()
Scanner& operator<< (int y)
{
_type = zbar_scan_y(_scanner, y);
return(*this);
}
/// process next sample from RGB (or BGR) triple.
/// see zbar_scan_rgb24()
zbar_symbol_type_t scan_rgb24 (unsigned char *rgb)
{
_type = zbar_scan_rgb24(_scanner, rgb);
return(_type);
}
/// process next sample from RGB (or BGR) triple.
/// see zbar_scan_rgb24()
Scanner& operator<< (unsigned char *rgb)
{
_type = zbar_scan_rgb24(_scanner, rgb);
return(*this);
}
/// retrieve last scanned width.
/// see zbar_scanner_get_width()
unsigned get_width () const
{
return(zbar_scanner_get_width(_scanner));
}
/// retrieve last scanned color.
/// see zbar_scanner_get_color()
zbar_color_t get_color () const
{
return(zbar_scanner_get_color(_scanner));
}
/// retrieve last scan result.
zbar_symbol_type_t get_type () const
{
return(_type);
}
/// cast to C scanner
operator zbar_scanner_t* () const
{
return(_scanner);
}
/// retrieve C scanner
const zbar_scanner_t *get_c_scanner () const
{
return(_scanner);
}
private:
zbar_scanner_t *_scanner;
zbar_symbol_type_t _type;
};
}
#endif

541
include/zbar/Symbol.h Normal file
View File

@ -0,0 +1,541 @@
//------------------------------------------------------------------------
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_SYMBOL_H_
#define _ZBAR_SYMBOL_H_
/// @file
/// Symbol C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Symbol.h"
#endif
#include <stdlib.h>
#include <string>
#include <ostream>
#include <assert.h>
namespace zbar {
class SymbolIterator;
/// container for decoded result symbols associated with an image
/// or a composite symbol.
class SymbolSet {
public:
/// constructor.
SymbolSet (const zbar_symbol_set_t *syms = NULL)
: _syms(syms)
{
ref();
}
/// copy constructor.
SymbolSet (const SymbolSet& syms)
: _syms(syms._syms)
{
ref();
}
/// destructor.
~SymbolSet ()
{
ref(-1);
}
/// assignment.
SymbolSet& operator= (const SymbolSet& syms)
{
syms.ref();
ref(-1);
_syms = syms._syms;
return(*this);
}
/// truth testing.
bool operator! () const
{
return(!_syms || !get_size());
}
/// manipulate reference count.
void ref (int delta = 1) const
{
if(_syms)
zbar_symbol_set_ref((zbar_symbol_set_t*)_syms, delta);
}
/// cast to C symbol set.
operator const zbar_symbol_set_t* () const
{
return(_syms);
}
int get_size () const
{
return((_syms) ? zbar_symbol_set_get_size(_syms) : 0);
}
/// create a new SymbolIterator over decoded results.
SymbolIterator symbol_begin() const;
/// return a SymbolIterator suitable for ending iteration.
const SymbolIterator symbol_end() const;
private:
const zbar_symbol_set_t *_syms;
};
/// decoded barcode symbol result object. stores type, data, and
/// image location of decoded symbol
class Symbol {
public:
/// image pixel location (x, y) coordinate tuple.
class Point {
public:
int x; ///< x-coordinate.
int y; ///< y-coordinate.
Point () { }
Point(int x, int y)
: x(x), y(y)
{ }
/// copy constructor.
Point (const Point& pt)
: x(pt.x),
y(pt.y)
{ }
/// assignment.
Point& operator= (const Point& pt)
{
x = pt.x;
y = pt.y;
return(*this);
}
};
/// iteration over Point objects in a symbol location polygon.
class PointIterator
: public std::iterator<std::input_iterator_tag, Point> {
public:
/// constructor.
PointIterator (const Symbol *sym = NULL,
int index = 0)
: _sym(sym),
_index(index)
{
if(sym)
sym->ref(1);
if(!sym ||
(unsigned)_index >= zbar_symbol_get_loc_size(*_sym))
_index = -1;
}
/// copy constructor.
PointIterator (const PointIterator& iter)
: _sym(iter._sym),
_index(iter._index)
{
if(_sym)
_sym->ref();
}
/// destructor.
~PointIterator ()
{
if(_sym)
_sym->ref(-1);
}
/// assignment.
PointIterator& operator= (const PointIterator& iter)
{
if(iter._sym)
iter._sym->ref();
if(_sym)
_sym->ref(-1);
_sym = iter._sym;
_index = iter._index;
return(*this);
}
/// truth testing.
bool operator! () const
{
return(!_sym || _index < 0);
}
/// advance iterator to next Point.
PointIterator& operator++ ()
{
unsigned int i = ++_index;
if(!_sym || i >= zbar_symbol_get_loc_size(*_sym))
_index = -1;
return(*this);
}
/// retrieve currently referenced Point.
const Point operator* () const
{
assert(!!*this);
if(!*this)
return(Point());
return(Point(zbar_symbol_get_loc_x(*_sym, _index),
zbar_symbol_get_loc_y(*_sym, _index)));
}
/// test if two iterators refer to the same Point in the same
/// Symbol.
bool operator== (const PointIterator& iter) const
{
return(_index == iter._index &&
((_index < 0) || _sym == iter._sym));
}
/// test if two iterators refer to the same Point in the same
/// Symbol.
bool operator!= (const PointIterator& iter) const
{
return(!(*this == iter));
}
private:
const Symbol *_sym;
int _index;
};
/// constructor.
Symbol (const zbar_symbol_t *sym = NULL)
: _xmlbuf(NULL),
_xmllen(0)
{
init(sym);
ref();
}
/// copy constructor.
Symbol (const Symbol& sym)
: _sym(sym._sym),
_type(sym._type),
_data(sym._data),
_xmlbuf(NULL),
_xmllen(0)
{
ref();
}
/// destructor.
~Symbol () {
if(_xmlbuf)
free(_xmlbuf);
ref(-1);
}
/// assignment.
Symbol& operator= (const Symbol& sym)
{
sym.ref(1);
ref(-1);
_sym = sym._sym;
_type = sym._type;
_data = sym._data;
return(*this);
}
Symbol& operator= (const zbar_symbol_t *sym)
{
if(sym)
zbar_symbol_ref(sym, 1);
ref(-1);
init(sym);
return(*this);
}
/// truth testing.
bool operator! () const
{
return(!_sym);
}
void ref (int delta = 1) const
{
if(_sym)
zbar_symbol_ref((zbar_symbol_t*)_sym, delta);
}
/// cast to C symbol.
operator const zbar_symbol_t* () const
{
return(_sym);
}
/// test if two Symbol objects refer to the same C symbol.
bool operator== (const Symbol& sym) const
{
return(_sym == sym._sym);
}
/// test if two Symbol objects refer to the same C symbol.
bool operator!= (const Symbol& sym) const
{
return(!(*this == sym));
}
/// retrieve type of decoded symbol.
zbar_symbol_type_t get_type () const
{
return(_type);
}
/// retrieve the string name of the symbol type.
const std::string get_type_name () const
{
return(zbar_get_symbol_name(_type));
}
/// retrieve the string name for any addon.
/// @deprecated in 0.11
const std::string get_addon_name () const
{
return(zbar_get_addon_name(_type));
}
/// retrieve data decoded from symbol.
const std::string get_data () const
{
return(_data);
}
/// retrieve length of binary data
unsigned get_data_length () const
{
return((_sym) ? zbar_symbol_get_data_length(_sym) : 0);
}
/// retrieve inter-frame coherency count.
/// see zbar_symbol_get_count()
/// @since 0.5
int get_count () const
{
return((_sym) ? zbar_symbol_get_count(_sym) : -1);
}
/// retrieve loosely defined relative quality metric.
/// see zbar_symbol_get_quality()
/// @since 0.11
int get_quality () const
{
return((_sym) ? zbar_symbol_get_quality(_sym) : 0);
}
SymbolSet get_components () const
{
return(SymbolSet((_sym) ? zbar_symbol_get_components(_sym) : NULL));
}
/// create a new PointIterator at the start of the location
/// polygon.
PointIterator point_begin() const
{
return(PointIterator(this));
}
/// return a PointIterator suitable for ending iteration.
const PointIterator point_end() const
{
return(PointIterator());
}
/// see zbar_symbol_get_loc_size().
int get_location_size () const
{
return((_sym) ? zbar_symbol_get_loc_size(_sym) : 0);
}
/// see zbar_symbol_get_loc_x().
int get_location_x (unsigned index) const
{
return((_sym) ? zbar_symbol_get_loc_x(_sym, index) : -1);
}
/// see zbar_symbol_get_loc_y().
int get_location_y (unsigned index) const
{
return((_sym) ? zbar_symbol_get_loc_y(_sym, index) : -1);
}
/// see zbar_symbol_get_orientation().
/// @since 0.11
int get_orientation () const
{
return(zbar_symbol_get_orientation(_sym));
}
/// see zbar_symbol_xml().
const std::string xml () const
{
if(!_sym)
return("");
return(zbar_symbol_xml(_sym, (char**)&_xmlbuf, (unsigned*)&_xmllen));
}
protected:
/// (re)initialize Symbol from C symbol object.
void init (const zbar_symbol_t *sym = NULL)
{
_sym = sym;
if(sym) {
_type = zbar_symbol_get_type(sym);
_data = std::string(zbar_symbol_get_data(sym),
zbar_symbol_get_data_length(sym));
}
else {
_type = ZBAR_NONE;
_data = "";
}
}
private:
const zbar_symbol_t *_sym;
zbar_symbol_type_t _type;
std::string _data;
char *_xmlbuf;
unsigned _xmllen;
};
/// iteration over Symbol result objects in a scanned Image or SymbolSet.
class SymbolIterator
: public std::iterator<std::input_iterator_tag, Symbol> {
public:
/// default constructor.
SymbolIterator ()
{ }
/// constructor.
SymbolIterator (const SymbolSet &syms)
: _syms(syms)
{
const zbar_symbol_set_t *zsyms = _syms;
if(zsyms)
_sym = zbar_symbol_set_first_symbol(zsyms);
}
/// copy constructor.
SymbolIterator (const SymbolIterator& iter)
: _syms(iter._syms)
{
const zbar_symbol_set_t *zsyms = _syms;
if(zsyms)
_sym = zbar_symbol_set_first_symbol(zsyms);
}
~SymbolIterator ()
{
}
/// assignment.
SymbolIterator& operator= (const SymbolIterator& iter)
{
_syms = iter._syms;
_sym = iter._sym;
return(*this);
}
bool operator! () const
{
return(!_syms || !_sym);
}
/// advance iterator to next Symbol.
SymbolIterator& operator++ ()
{
if(!!_sym)
_sym = zbar_symbol_next(_sym);
else if(!!_syms)
_sym = zbar_symbol_set_first_symbol(_syms);
return(*this);
}
/// retrieve currently referenced Symbol.
const Symbol operator* () const
{
return(_sym);
}
/// access currently referenced Symbol.
const Symbol* operator-> () const
{
return(&_sym);
}
/// test if two iterators refer to the same Symbol
bool operator== (const SymbolIterator& iter) const
{
// it is enough to test the symbols, as they belong
// to only one set (also simplifies invalid case)
return(_sym == iter._sym);
}
/// test if two iterators refer to the same Symbol
bool operator!= (const SymbolIterator& iter) const
{
return(!(*this == iter));
}
const SymbolIterator end () const {
return(SymbolIterator());
}
private:
SymbolSet _syms;
Symbol _sym;
};
inline SymbolIterator SymbolSet::symbol_begin () const {
return(SymbolIterator(*this));
}
inline const SymbolIterator SymbolSet::symbol_end () const {
return(SymbolIterator());
}
/// @relates Symbol
/// stream the string representation of a Symbol.
static inline std::ostream& operator<< (std::ostream& out,
const Symbol& sym)
{
out << sym.get_type_name() << ":" << sym.get_data();
return(out);
}
}
#endif

227
include/zbar/Video.h Normal file
View File

@ -0,0 +1,227 @@
//------------------------------------------------------------------------
// Copyright 2007-2010 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_VIDEO_H_
#define _ZBAR_VIDEO_H_
/// @file
/// Video Input C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Video.h"
#endif
#include "Image.h"
namespace zbar {
/// mid-level video source abstraction.
/// captures images from a video device
class Video {
public:
/// constructor.
Video (zbar_video_t *video = NULL)
{
if(video)
_video = video;
else
_video = zbar_video_create();
}
/// constructor.
Video (std::string& device)
{
_video = zbar_video_create();
open(device);
}
~Video ()
{
zbar_video_destroy(_video);
}
/// cast to C video object.
operator zbar_video_t* () const
{
return(_video);
}
/// open and probe a video device.
void open (std::string& device)
{
if(zbar_video_open(_video, device.c_str()))
throw_exception(_video);
}
/// close video device if open.
void close ()
{
if(zbar_video_open(_video, NULL))
throw_exception(_video);
}
/// initialize video using a specific format for debug.
/// see zbar_video_init()
void init (unsigned long fourcc)
{
if(zbar_video_init(_video, fourcc))
throw_exception(_video);
}
/// initialize video using a specific format for debug.
/// see zbar_video_init()
void init (std::string& format)
{
unsigned int fourcc = zbar_fourcc_parse(format.c_str());
if(zbar_video_init(_video, fourcc))
throw_exception(_video);
}
/// retrieve file descriptor associated with open *nix video device.
/// see zbar_video_get_fd()
int get_fd ()
{
return(zbar_video_get_fd(_video));
}
/// retrieve current output image width.
/// see zbar_video_get_width()
int get_width ()
{
return(zbar_video_get_width(_video));
}
/// retrieve current output image height.
/// see zbar_video_get_height()
int get_height ()
{
return(zbar_video_get_height(_video));
}
/// start/stop video capture.
/// see zbar_video_enable()
void enable (bool enable = true)
{
if(zbar_video_enable(_video, enable))
throw_exception(_video);
}
/// retrieve next captured image.
/// see zbar_video_next_image()
Image next_image ()
{
zbar_image_t *img = zbar_video_next_image(_video);
if(!img)
throw_exception(_video);
return(Image(img));
}
/// request a preferred size for the video image from the device.
/// see zbar_video_request_size()
/// @since 0.6
void request_size (int width, int height)
{
zbar_video_request_size(_video, width, height);
}
/// request a preferred driver interface version for debug/testing.
/// see zbar_video_request_interface()
/// @since 0.6
void request_interface (int version)
{
zbar_video_request_interface(_video, version);
}
/// request a preferred I/O mode for debug/testing.
/// see zbar_video_request_iomode()
/// @since 0.7
void request_iomode (int iomode)
{
if(zbar_video_request_iomode(_video, iomode))
throw_exception(_video);
}
/// get the information about a control at a given index
/// see zbar_video_get_controls()
/// @since 0.11
struct video_controls_s *get_controls(int index)
{
return(zbar_video_get_controls(_video, index));
}
/// set the value on an integer control
/// see zbar_video_set_control_n()
/// @since 0.11
int set_control (const char *name,
int value)
{
return zbar_video_set_control (_video, name, value);
}
/// set the value on a boolean control
/// see zbar_video_set_control_b()
/// @since 0.11
int set_control (const char *name,
bool value)
{
return zbar_video_set_control (_video, name, value ? 1 : 0);
}
/// get the value on a boolean control
/// see zbar_video_get_control_b()
/// @since 0.11
int get_control (const char *name,
int *value)
{
return zbar_video_get_control (_video, name, value);
}
/// get the value on an integer control
/// see zbar_video_get_control_n()
/// @since 0.11
int get_control (const char *name,
bool *value)
{
int __value;
int ret = zbar_video_get_control (_video, name, &__value);
*value = __value ? true : false;
return ret;
}
/// get the information about a control at a given index
/// see zbar_video_get_resolutions()
/// @since 0.22
struct video_resolution_s *get_resolution(int index)
{
return(zbar_video_get_resolutions(_video, index));
}
private:
zbar_video_t *_video;
};
}
#endif

136
include/zbar/Window.h Normal file
View File

@ -0,0 +1,136 @@
//------------------------------------------------------------------------
// Copyright 2007-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#ifndef _ZBAR_WINDOW_H_
#define _ZBAR_WINDOW_H_
/// @file
/// Output Window C++ wrapper
#ifndef _ZBAR_H_
# error "include zbar.h in your application, **not** zbar/Window.h"
#endif
#include "Image.h"
namespace zbar {
/// mid-level output window abstraction.
/// displays images to user-specified platform specific output window
class Window {
public:
/// constructor.
Window (zbar_window_t *window = NULL)
{
if(window)
_window = window;
else
_window = zbar_window_create();
}
/// constructor.
Window (void *x11_display_w32_hwnd,
unsigned long x11_drawable)
{
_window = zbar_window_create();
attach(x11_display_w32_hwnd, x11_drawable);
}
~Window ()
{
zbar_window_destroy(_window);
}
/// cast to C window object.
operator zbar_window_t* () const
{
return(_window);
}
/// associate reader with an existing platform window.
/// see zbar_window_attach()
void attach (void *x11_display_w32_hwnd,
unsigned long x11_drawable = 0)
{
if(zbar_window_attach(_window,
x11_display_w32_hwnd, x11_drawable) < 0)
throw_exception(_window);
}
/// control content level of the reader overlay.
/// see zbar_window_set_overlay()
void set_overlay (int level)
{
zbar_window_set_overlay(_window, level);
}
/// retrieve current content level of reader overlay.
/// see zbar_window_get_overlay()
/// draw a new image into the output window.
/// see zbar_window_draw()
void draw (Image& image)
{
if(zbar_window_draw(_window, image) < 0)
throw_exception(_window);
}
/// clear the image from the output window.
/// see zbar_window_draw()
void clear ()
{
if(zbar_window_draw(_window, NULL) < 0)
throw_exception(_window);
}
/// redraw the last image.
/// zbar_window_redraw()
void redraw ()
{
if(zbar_window_redraw(_window) < 0)
throw_exception(_window);
}
/// resize the image window.
/// zbar_window_resize()
void resize (unsigned width, unsigned height)
{
if(zbar_window_resize(_window, width, height) < 0)
throw_exception(_window);
}
private:
zbar_window_t *_window;
};
/// select a compatible format between video input and output window.
/// see zbar_negotiate_format()
static inline void negotiate_format (Video& video, Window& window)
{
if(zbar_negotiate_format(video, window) < 0)
throw_exception(video);
}
}
#endif

257
include/zbar/zbargtk.h Normal file
View File

@ -0,0 +1,257 @@
/*------------------------------------------------------------------------
* Copyright 2008-2009 (c) Jeff Brown <spadix@users.sourceforge.net>
*
* This file is part of the ZBar Bar Code Reader.
*
* The ZBar Bar Code Reader is free software; you can redistribute it
* and/or modify it under the terms of the GNU Lesser Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* The ZBar Bar Code Reader is distributed in the hope that it will be
* useful, but WITHOUT ANY WARRANTY; without even the implied warranty
* of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser Public License for more details.
*
* You should have received a copy of the GNU Lesser Public License
* along with the ZBar Bar Code Reader; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor,
* Boston, MA 02110-1301 USA
*
* http://sourceforge.net/projects/zbar
*------------------------------------------------------------------------*/
#ifndef __ZBAR_GTK_H__
#define __ZBAR_GTK_H__
/*
* NOTE: before modifying this file, please see:
*
* https://wiki.gnome.org/Projects/GObjectIntrospection/Annotations/
* https://gi.readthedocs.io/en/latest/annotations/giannotations.html
*
* For the annotations needed for Gobject Introspection (GIR) to work
*/
/**
* SECTION:ZBarGtk
* @short_description: barcode reader GTK+ 2.x widget
* @Title: ZBar Gtk bindings
* @include: zbar/zbargtk.h
*
* embeds a barcode reader directly into a GTK+ based GUI. the widget
* can process barcodes from a video source (using the
* #ZBarGtk:video-device and #ZBarGtk:video-enabled properties) or
* from individual GdkPixbufs supplied to zbar_gtk_scan_image()
*
* Since: 1.0
*/
#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <zbar.h>
G_BEGIN_DECLS
/* --- type macros --- */
#define ZBAR_TYPE_GTK (zbar_gtk_get_type())
#define ZBAR_GTK(object) (G_TYPE_CHECK_INSTANCE_CAST((object), ZBAR_TYPE_GTK, ZBarGtk))
#define ZBAR_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), ZBAR_TYPE_GTK, ZBarGtkClass))
#define ZBAR_IS_GTK(object) (G_TYPE_CHECK_INSTANCE_TYPE((object), ZBAR_TYPE_GTK))
#define ZBAR_IS_GTK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), ZBAR_TYPE_GTK))
#define ZBAR_GTK_GET_CLASS(object) (G_TYPE_INSTANCE_GET_CLASS((object), ZBAR_TYPE_GTK, ZBarGtkClass))
/* --- typedefs & structures --- */
typedef struct _ZBarGtk ZBarGtk;
typedef struct _ZBarGtkClass ZBarGtkClass;
/**
* _ZBarGtk: (rename-to ZBarGtk) (ref-func zbar_gtk_new) (get-value-func zbar_gtk_get_type)
* @widget: pointer to GtkWidget
* @_private: used internally
*/
struct _ZBarGtk {
GtkWidget widget;
gpointer *_private;
/* properties */
/*
* ZBarGtk:video-device:
*
* the currently set video device.
*
* setting a new device opens it and automatically sets
* #ZBarGtk:video-enabled. set the empty string ("") or NULL to
* close.
*/
/*
* ZBarGtk:video-enabled:
*
* video device streaming state.
*
* use to pause/resume video scanning.
*/
/*
* ZBarGtk:video-opened:
*
* video device opened state.
*
* (re)setting #ZBarGtk:video-device should eventually cause it
* to be opened or closed. any errors while streaming/scanning
* will also cause the device to be closed
*/
};
/**
* _ZBarGtkClass:
*/
struct _ZBarGtkClass {
GtkWidgetClass parent_class;
/* signals */
/**
* ZBarGtk::decoded:
* @widget: the object that received the signal
* @symbol_type: the type of symbol decoded (a zbar_symbol_type_t)
* @data: the data decoded from the symbol
*
* emitted when a barcode is decoded from an image.
* the symbol type and contained data are provided as separate
* parameters
*/
void (*decoded) (ZBarGtk *zbar,
zbar_symbol_type_t symbol_type,
const char *data);
/**
* ZBarGtk::decoded-text:
* @widget: the object that received the signal
* @text: the decoded data prefixed by the string name of the
* symbol type (separated by a colon)
*
* emitted when a barcode is decoded from an image.
* the symbol type name is prefixed to the data, separated by a
* colon
*/
void (*decoded_text) (ZBarGtk *zbar,
const char *text);
/**
* ZBarGtk:scan-image:
* @widget: the object that received the signal
* @image: the image to scan for barcodes
*/
void (*scan_image) (ZBarGtk *zbar,
GdkPixbuf *image);
};
/**
* zbar_gtk_get_type: (skip)
* Returns ZBarGtk type
* @returns: #GType
*/
GType zbar_gtk_get_type(void) G_GNUC_CONST;
/**
* zbar_gtk_new:
* create a new barcode reader widget instance.
* initially has no associated video device or image.
*
* Returns: (transfer full): a new #ZBarGtk widget instance
*/
GtkWidget *zbar_gtk_new(void);
/**
* zbar_gtk_scan_image:
* @zbar: pointer to #ZBarGtk
* @image: the GdkPixbuf used to store the image
*
*/
void zbar_gtk_scan_image(ZBarGtk *zbar,
GdkPixbuf *image);
/**
* zbar_gtk_get_video_device:
* retrieve the currently opened video device.
* @zbar: pointer to #ZBarGtk
*
* Returns: the current video device or NULL if no device is opened
*/
const char *zbar_gtk_get_video_device(ZBarGtk *zbar);
/**
* zbar_gtk_set_video_device:
* open a new video device.
* @zbar: pointer to #ZBarGtk
* @video_device: (nullable) (type filename) : the platform specific name of
* the device to open. use NULL to close a currently opened device.
*
* @note since opening a device may take some time, this call will
* return immediately and the device will be opened asynchronously
*/
void zbar_gtk_set_video_device(ZBarGtk *zbar,
const char *video_device);
/**
* zbar_gtk_get_video_enabled:
* retrieve the current video enabled state.
* @zbar: pointer to #ZBarGtk
*
* Returns: true if video scanning is currently enabled, false otherwise
*/
gboolean zbar_gtk_get_video_enabled(ZBarGtk *zbar);
/**
* zbar_gtk_set_video_enabled:
* enable/disable video scanning.
* @zbar: pointer to #ZBarGtk
* @video_enabled: true to enable video scanning, false to disable
*
* has no effect unless a video device is opened
*/
void zbar_gtk_set_video_enabled(ZBarGtk *zbar,
gboolean video_enabled);
/**
* zbar_gtk_get_video_opened:
* retrieve the current video opened state.
* @zbar: pointer to #ZBarGtk
*
* Returns: true if video device is currently opened, false otherwise
*/
gboolean zbar_gtk_get_video_opened(ZBarGtk *zbar);
/**
* zbar_gtk_request_video_size:
* set video camera resolution.
* @zbar: pointer to #ZBarGtk
* @width: width in pixels
* @height: height in pixels
*
* @note this call must be made before video is initialized
*/
void zbar_gtk_request_video_size(ZBarGtk *zbar,
int width,
int height);
/**
* zbar_gtk_image_from_pixbuf:
* utility function to populate a zbar_image_t from a GdkPixbuf.
* @image: (type gpointer) : the zbar library image destination to populate
* @pixbuf: the GdkPixbuf source
*
* Returns: TRUE if successful or FALSE if the conversion could not be
* performed for some reason
*/
gboolean zbar_gtk_image_from_pixbuf(zbar_image_t *image,
GdkPixbuf *pixbuf);
G_END_DECLS
#endif

138
iphone/ChangeLog Normal file
View File

@ -0,0 +1,138 @@
version 1.3.1:
* fix examples
- fix EmbedReader initial iPad orientation
- fix TabReader shouldn't show controls
* add retry workaround when device lock fails
- add iPhone 5 launch image to examples
- doc updates
* Lion and Xcode updates
- fix new warnings/errors
- find missing buddy
- fix SDK bg image: force resolution to 72dpi
* Fix EmbedReader example rotation interaction
version 1.2.2:
* reduce controller present and dismiss latency
- add simple shutter to mask video start
version 1.2.1:
* fix overlay resizing bug
version 1.2:
* release updates
version 1.1.3:
* fix UITabViewController rotation interaction
version 1.1.2:
* add maxZoom for increasing zoom range
- workaround camera preview initial location/size bug
* add emulation for UI videoQuality to adjust camera resolution
* fix several simulator-related bugs
- fix device property missing from simulated ZBarReaderView
- fix AVCaptureDevice referenced from ZBarReaderViewController
- fix simulated camera gesture multiple recognition
version 1.1.1:
* fix ReaderSample project path to ZBarSDK
* README document new examples
- make ReaderSample scheme public
* documentation updates
* add emulation for UI camera device and flash mode properties
* workaround orientation bugs in parent controllers
- enable orientation and iPad support for all examples
* add orientation detection fall back
* fix captureReader not exposed to simulator
* fix camera preview stale rotation corner
- fix ZBarReaderViewController toolbar layout accomodation
- switch pre-release samples to use debug library
* update docs to note possible link order dependency
* add missing references to new samples
* add IB support to ZBarReaderViewController
- add tabbed reader sample
* add embedded reader sample
- factor out camera simulation logic
* fix readertest max quality result filtering
- thanks to John Boydon for finding this!
* improve support for resizing, rotating and embedding the reader
* add readertest fixed zoom stops
* add manual frame capture
- readertest save as PNG
* enhance readertest to support default/demo pre-config and distribution
* updates for Xcode 4
* expose tracking box color
version 1.1:
* fix doc typo (bug #3139087)
- add modifier bit docs
version 1.0.1:
* hotfix broken ZBarHelpController back button
* release updates
- update docs
* fix support for GS1 AIs
* fix simulated camera image orientation/scaling
* cleanup and expose ZBarHelpController
* expose enable for reader capture processing
* workaround iOS 4.2 hang
- update to use latest SDK
* add support for Code 93 symbology
version 1.0:
* update to SDK 4.1, clean out LLVM warnings
* fix camera simulation gesture
version 0.1.2:
* fix missing header dependency
* doc enhancements
* force controls to front when showsZBarControls is enabled
* fix initial zoom crop (performance bug)
* workaround iPhone quartz access past image data
version 0.1.1:
* migrate to binary iPhone SDK distribution (NB backward incompatibilities!)
- restructure headers
version 0.1:
* workaround for iPhone simulator builds
- refactor ZBarReaderView for capture/simulator specific implementations
- fix tracking calculations
- fix captured video frame color conversion
* fix for poor iPhone 4 performance
* enable torch for iPhone 4
* fix iPhone circular ref bug
* add iPhone cache flush, change new libs to weak refs
* fix iPhone async ref bug
* enhance iPhone readertest w/more options
* add iPhone zoom support, integrate with crop
* add iPhone OS 4.0 video capture support
- replacement view controller for new camera reader
- separate view for use without controller
- separate capture delegate for use standalone
- add continuous autofocus
* cleanup and expose iphone help display API
* fixes to new iphone help display
* migrate iphone help display to integrated web page (NB resource updates!)
- allows easier customization
- local links open directly, external links confirm and jump out to Safari
- JavaScript hook for help context customization
- also enhanced default help (note this changes the required resources)
- fix to disable scanning during help overlay
- thanks to iafanasyev and others for detailed suggestions
* fix iphone custom overlay response (bug #2959617)
- thanks to an anonymous user for the patch!
* iphone widget performance tuning enhancements
- fix crop calculation bug in ZBarImage
- add properties to control pre-scan image cropping and scaling
- add property for scanner cache control
- enable some scanner density control (FIXME should be property)
- fix ifdef for quality control (FIXME should be property)
- add "sequence" mode test (not actually so useful)
* realtime scanning for iphone widget
- uses UIGetScreenImage() (NB private)
- ZBarImage from CGImage (instead of UIImage)
- add crop to scaling step
- expose symbol set unfiltered results
* iphone widget back compat updates, add basic test app
* add Obj-C wrapper
* first pass working iPhone "widget"

66
iphone/README Normal file
View File

@ -0,0 +1,66 @@
ZBar iOS SDK
============
ZBar Bar Code Reader is an open source software suite for reading bar
codes from various sources, such as video streams, image files and raw
intensity sensors. It supports EAN-13/UPC-A, UPC-E, EAN-8, DataBar,
Code 128, Code 93, Code 39, Codabar, Interleaved 2 of 5 and QR Code.
These are the Objective C wrappers and integrated widget for developing
with the library on the iOS platform.
Check the ZBar project home page for the latest release, forums, etc.
* http://zbar.sourceforge.net/iphone
Installation
------------
If you are migrating from a pre-SDK source version of the library,
first make sure you remove all of the old references to zbar.xcodeproj
and libzbar.a and revert any related build settings.
To add the SDK to an Xcode project:
1. Drag ZBarSDK into your Xcode project.
3. Add these system frameworks to your project:
* AVFoundation.framework (weak)
* CoreMedia.framework (weak)
* CoreVideo.framework (weak)
* QuartzCore.framework
* libiconv.dylib
Documentation
-------------
See Documentation.html for complete SDK documentation.
Examples
--------
You should be able to open and build the examples directly from the
disk image (ignore warnings about the read-only volume). If you have
problems with this, please copy the examples to your local drive
instead and build from there.
A tutorial that walks through installing and using the SDK is
available in the documentation. The SDK disk image also contains the
resulting Xcode project at Examples/ReaderSample.
Examples/readertest demonstrates most of the configuration options
available for the reader.
Examples/TabReader shows how you can use Interface Builder to add the
reader as a tab in a UITabBarController.
Examples/EmbedReader shows how a ZBarReaderView may be embedded
directly in the application view hierarchy.
Copyright and License
---------------------
Licensed under the GNU Lesser General Public License, version 2.1.
http://www.gnu.org/licenses/old-licenses/lgpl-2.1.txt
Copyright 2008-2011 © Jeff Brown <spadix@users.sourceforge.net> et al
See the included files COPYING and LICENSE.md for details

43
iphone/ZBarCVImage.h Normal file
View File

@ -0,0 +1,43 @@
//------------------------------------------------------------------------
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#import <ZBarSDK/ZBarImage.h>
#import <CoreVideo/CoreVideo.h>
// ZBarImage referring to a CVPixelBuffer. used internally to handle
// asynchronous conversion to UIImage
@interface ZBarCVImage
: ZBarImage
{
CVPixelBufferRef pixelBuffer;
void *rgbBuffer;
NSInvocationOperation *conversion;
}
- (void) waitUntilConverted;
@property (nonatomic) CVPixelBufferRef pixelBuffer;
@property (nonatomic, readonly) void *rgbBuffer;
@end

195
iphone/ZBarCVImage.m Normal file
View File

@ -0,0 +1,195 @@
//------------------------------------------------------------------------
// Copyright 2010 (c) Jeff Brown <spadix@users.sourceforge.net>
//
// This file is part of the ZBar Bar Code Reader.
//
// The ZBar Bar Code Reader is free software; you can redistribute it
// and/or modify it under the terms of the GNU Lesser Public License as
// published by the Free Software Foundation; either version 2.1 of
// the License, or (at your option) any later version.
//
// The ZBar Bar Code Reader is distributed in the hope that it will be
// useful, but WITHOUT ANY WARRANTY; without even the implied warranty
// of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser Public License for more details.
//
// You should have received a copy of the GNU Lesser Public License
// along with the ZBar Bar Code Reader; if not, write to the Free
// Software Foundation, Inc., 51 Franklin St, Fifth Floor,
// Boston, MA 02110-1301 USA
//
// http://sourceforge.net/projects/zbar
//------------------------------------------------------------------------
#import "ZBarCVImage.h"
#define MODULE ZBarCVImage
#import "debug.h"
static NSOperationQueue *conversionQueue;
static const void*
asyncProvider_getBytePointer (void *info)
{
// block until data is available
ZBarCVImage *image = info;
assert(image);
[image waitUntilConverted];
void *buf = image.rgbBuffer;
assert(buf);
return(buf);
}
static const CGDataProviderDirectCallbacks asyncProvider = {
.version = 0,
.getBytePointer = asyncProvider_getBytePointer,
.releaseBytePointer = NULL,
.getBytesAtPosition = NULL,
.releaseInfo = (void*)CFRelease,
};
@implementation ZBarCVImage
@synthesize pixelBuffer, rgbBuffer;
- (void) dealloc
{
self.pixelBuffer = NULL;
if(rgbBuffer) {
free(rgbBuffer);
rgbBuffer = NULL;
}
[conversion release];
conversion = nil;
[super dealloc];
}
- (void) setPixelBuffer: (CVPixelBufferRef) newbuf
{
CVPixelBufferRef oldbuf = pixelBuffer;
if(newbuf)
CVPixelBufferRetain(newbuf);
pixelBuffer = newbuf;
if(oldbuf)
CVPixelBufferRelease(oldbuf);
}
- (void) waitUntilConverted
{
// operation will at least have been queued already
NSOperation *op = [conversion retain];
if(!op)
return;
[op waitUntilFinished];
[op release];
}
- (UIImage*) UIImageWithOrientation: (UIImageOrientation) orient
{
if(!conversion && !rgbBuffer) {
// start format conversion in separate thread
NSOperationQueue *queue = conversionQueue;
if(!queue) {
queue = conversionQueue = [NSOperationQueue new];
queue.maxConcurrentOperationCount = 1;
}
else
[queue waitUntilAllOperationsAreFinished];
conversion = [[NSInvocationOperation alloc]
initWithTarget: self
selector: @selector(convertCVtoRGB)
object: nil];
[queue addOperation: conversion];
[conversion release];
}
// create UIImage before converted data is available
CGSize size = self.size;
int w = size.width;
int h = size.height;
CGDataProviderRef datasrc =
CGDataProviderCreateDirect([self retain], 3 * w * h, &asyncProvider);
CGColorSpaceRef cs = CGColorSpaceCreateDeviceRGB();
CGImageRef cgimg =
CGImageCreate(w, h, 8, 24, 3 * w, cs,
kCGBitmapByteOrderDefault, datasrc,
NULL, YES, kCGRenderingIntentDefault);
CGColorSpaceRelease(cs);
CGDataProviderRelease(datasrc);
UIImage *uiimg =
[UIImage imageWithCGImage: cgimg
scale: 1
orientation: orient];
CGImageRelease(cgimg);
return(uiimg);
}
// convert video frame to a CGImage compatible RGB format
// FIXME this is temporary until we can find the native way...
- (void) convertCVtoRGB
{
timer_start;
unsigned long format = self.format;
assert(format == zbar_fourcc('C','V','2','P'));
if(format != zbar_fourcc('C','V','2','P'))
return;
CVPixelBufferLockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly);
int w = CVPixelBufferGetWidth(pixelBuffer);
int h = CVPixelBufferGetHeight(pixelBuffer);
int dy = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 0);
int duv = CVPixelBufferGetBytesPerRowOfPlane(pixelBuffer, 1);
uint8_t *py = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 0);
uint8_t *puv = CVPixelBufferGetBaseAddressOfPlane(pixelBuffer, 1);
if(!py || !puv || dy < w || duv < w)
goto error;
int datalen = 3 * w * h;
// Quartz accesses some undocumented amount past allocated data?
// ...allocate extra to compensate
uint8_t *pdst = rgbBuffer = malloc(datalen + 3 * w);
if(!pdst)
goto error;
[self setData: rgbBuffer
withLength: datalen];
for(int y = 0; y < h; y++) {
const uint8_t *qy = py;
const uint8_t *quv = puv;
for(int x = 0; x < w; x++) {
int Y1 = *(qy++) - 16;
int Cb = *(quv) - 128;
int Cr = *(quv + 1) - 128;
Y1 *= 4769;
quv += (x & 1) << 1;
int r = (Y1 + 6537 * Cr + 2048) / 4096;
int g = (Y1 - 1604 * Cb - 3329 * Cr + 2048) / 4096;
int b = (Y1 + 8263 * Cb + 2048) / 4096;
r = (r | -!!(r >> 8)) & -((r >> 8) >= 0);
g = (g | -!!(g >> 8)) & -((g >> 8) >= 0);
b = (b | -!!(b >> 8)) & -((b >> 8) >= 0);
*(pdst++) = r;
*(pdst++) = g;
*(pdst++) = b;
}
py += dy;
if(y & 1)
puv += duv;
}
error:
CVPixelBufferUnlockBaseAddress(pixelBuffer, kCVPixelBufferLock_ReadOnly);
zlog(@"convert time %gs", timer_elapsed(t_start, timer_now()));
// release buffer as soon as conversion is complete
self.pixelBuffer = NULL;
conversion = nil;
}
@end

Some files were not shown because too many files have changed in this diff Show More