Zbar ON IMX6 Sabrelite Board
Zbar Library
About Zbar
Zbar is an open source C bar code reading library with C++, Python, Perl and Ruby bindings. It is used for reading bar codes from various sources such as video streams, image files and raw intensity sensors. It supports many popular symbologies (types of bar codes) including EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code.
ZBar is licensed under the GNU LGPL 2.1 to enable development of both open source and commercial projects.
Features of Zbar
- Cross platform - Linux/Unix, Windows, iPhone®, embedded...
- It supports many popular symbologies (types of bar codes) including EAN-13/UPC-A, UPC-E, EAN-8, Code 128, Code 39, Interleaved 2 of 5 and QR Code.
- Reads bar codes from various sources such as video streams, image files at a very high speed.
- A bar code scanning widget can be integraed into Qt, GTK+ or PyGTK GUI application.
- Suitable for embedded applications using inexpensive processors/hardware.
- Has interfaces to video4linux.
- The output window can be opened and owned by the library, or attached to an application managed window embedded in a GUI
- A simple inexpensive web camera can be used for scanning bar codes and QR codes instead of expensive bar code scanners.
- Supports USB, OV5642 CSI and OV5640 MIPI cameras for reading the barcodes.
Applications of Zbar
- Retail
- Automated document processing
- Inventory tracking
- Mobile applications
How to use the Zbar library
- First we have to build the Zbar library for the desired platform.
- Develop an application using the Zbar library.
- Build the application for the desired platform.
- Run the application on that particular platform.
Our achievements
- We have built the Zbar library for x86 and ARM platforms.
- Developed a Bar code and QR code reader by integrating the Zbar library into Qt application.
- Executed the application successfully on both x86 and ARM platforms.
Technical Detailes on USB Interface:
1) Introduction
Purpose
This document describes how to build Zbar for IMX6 with Intex camera.
Scope
This document is written for the developers and engineers working on IMX6 SABRELITE to build Zbar barcode reader library for IMX6.
2) Downloading Source code
To Download the source code for Zbar open the following link: http://zbar.sourceforge.net/download.html
To Download the source code for ImageMagick open the following link: http://www.imagemagick.org/script/download.php
3) Building Zbar
Prerequisites:
- LTIB build environment
- A USB camera
Open the Terminal and type following commands
cd /home/<path to ltib>
./ltib -m config
Enable “Configure the kernel” option by pressing “space bar” on the keyboard.
[*] Configure the kernel
Goto packagelist-->X11-->Change “ Do not install X11” to “X.Org 7.5”
Enable “build full modular X Server “
Goto X11 libraries and packages-->Enable “ twm “
Exit and save the configuration.
Run
./ltib
Now Enable the following options in Kernel configuration:
Device Drivers--> Multimedia Support--> Video for Linux
Device Drivers--> Multimedia Support-->Video Capture Adapters --> V4L USB devices-->USB Video Class and GSPCA based Webcams
Device Drivers--> USB Support --> USB Gadget Support-->USB Webcam Gadget
Exit from that menu and save the configuration.
./ltib -m prep -p libjpeg.spec
./ltib -m scbuild -p libjpeg.spec
./ltib -m scinstall -p libjpeg.spec
./ltib -m scdeploy -p libjpeg.spec
./ltib -m prep -p atk.spec
./ltib -m scbuild -p atk.spec
./ltib -m scinstall -p atk.spec
./ltib -m scdeploy -p atk.spec
./ltib -m prep -p fontconfig.spec
./ltib -m scbuild -p fontconfig.spec
./ltib -m scinstall -p fontconfig.spec
./ltib -m scdeploy -p fontconfig.spec
./ltib -m prep -p freetype.spec
./ltib -m scbuild -p freetype.spec
./ltib -m scinstall -p freetype.spec
./ltib -m scdeploy -p freetype.spec
./ltib -m prep -p pixman.spec
./ltib -m scbuild -p pixman.spec
./ltib -m scinstall -p pixman.spec
./ltib -m scdeploy -p pixman.spec
./ltib -m prep -p zlib.spec
./ltib -m scbuild -p zlib.spec
./ltib -m scinstall -p zlib.spec
./ltib -m scdeploy -p zlib.spec
./ltib -m prep -p libpng.spec
./ltib -m scbuild -p libpng.spec
./ltib -m scinstall -p libpng.spec
./ltib -m scdeploy -p libpng.spec
./ltib -m prep -p cairo.spec
./ltib -m scbuild -p cairo.spec
./ltib -m scinstall -p cairo.spec
./ltib -m scdeploy -p cairo.spec
./ltib -m prep -p libxml2.spec
./ltib -m scbuild -p libxml2.spec
./ltib -m scinstall -p libxml2.spec
./ltib -m scdeploy -p libxml2.spec
./ltib -m prep -p pango.spec
./ltib -m scbuild -p pango.spec
./ltib -m scinstall -p pango.spec
./ltib -m scdeploy -p pango.spec
./ltib -m prep -p libtiff.spec
./ltib -m scbuild -p libtiff.spec
./ltib -m scinstall -p libtiff.spec
./ltib -m scdeploy -p libtiff.spec
./ltib -m prep -p gtk2.spec
./ltib -m scbuild -p gtk2.spec
./ltib -m scinstall -p gtk2.spec
./ltib -m scdeploy -p gtk2.spec
./ltib -m prep -p v4l-utils.spec
./ltib -m scbuild -p v4l-utils.spec
./ltib -m scinstall -p v4l-utils.spec
./ltib -m scdeploy -p v4l-utils.spec
Installing ImageMagick:
Extract ImageMagick previously downloaded.
Suppose that the name of the folder is “ImageMagick-6.8.6-9”, rename it to “ImageMagick-6.8.6”.
Now:
tar -jcvf ImageMagick-6.8.6.tar.bz2 ImageMagick-6.8.6
sudo cp /home/<path to ImageMagick>.tar.bz2 /opt/freescale/pkgs/
mkdir dist/lfs-5.1/ImageMagick
cp dist/lfs-5.1/template/template.spec dist/lfs-5.1/ImageMagick/
mv dist/lfs-5.1/ImageMagick/template.spec dist/lfs-5.1/ImageMagick/ImageMagick.spec
vi dist/lfs-5.1/ImageMagick/ImageMagick.spec
Add the following contents into the spec file:
%define pfx /opt/freescale/rootfs/%{_target_cpu}
Summary : Software suite to create, edit, compose, or convert bitmap images
Name : ImageMagick
Version : 6.8.6
Release : 9
and save the changes.
./ltib -m prep -p ImageMagick.spec
./ltib -m scbuild -p ImageMagick.spec
./ltib -m scinstall -p ImageMagick.spec
./ltib -m scdeploy -p ImageMagick.spec
mkdir dist/lfs-5.1/zbar
cp dist/lfs-5.1/template/template.spec dist/lfs-5.1/zbar/
mv dist/lfs-5.1/zbar/template.spec dist/lfs-5.1/zbar.spec
vi dist/lfs-5.1/zbar/zbar.spec
write following details in the zbar.spec file and leave the remaining unchanged.
Summary : Software for reading barcodes.
Name : zbar
Version : 0.10
Release : 1
License : LGPL
%Build
./configure --prefix=%{_prefix} --host=$CFGHOST --build=%{_build} --without-python
./ltib -m prep -p zbar.spec
./ltib -m scbuild -p zbar.spec
./ltib -m scinstall -p zbar.spec
./ltib -m scdeploy -p zbar.spec
4) Copying Rootfs
→ The file system format ext3 or ext4 is a good option for removable media due to the
built-in journaling. Run the following command to format the partition:
$ sudo mkfs.ext3 /dev/sdb1
Or
$ sudo mkfs.ext4 /dev/sdb1
→ Copy the target file system to the partition:
$ mkdir /home/user/mountpoint
$ sudo mount /dev/sdb1 /home/user/mountpoint
→ Extract rootfs package to certain directory: extract rootfs.ext2.gz to /home/user/rootfs for example:
$ gunzip rootfs.ext2.gz
$ mount -o loop -t ext2 rootfs.ext2 /home/user/rootfs
→ Assume that the root file system files are located in /home/user/rootfs as in the previous step:
$ cd /home/user/rootfs
$ sudo cp -rpa [A-z]* /home/user/mountpoint
$ sudo umount /home/user/mountpoint
5) Fixing Errors
Error (1):
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking dependency style of gcc... (cached) gcc3
checking for xsltproc... no
configure: error: XCB requires xsltproc.
error: Bad exit status from /home/sainath/ltib/ltib/tmp/rpm-tmp.13371 (%build)
RPM build errors:
Bad exit status from /home/sainath/ltib/ltib/tmp/rpm-tmp.13371 (%build)
Build time for libxcb: 9 seconds
Failed building libxcb
f_buildrpms() returned an error, exiting
traceback:
main:572
These packages failed to build:
libxcb
Build Failed
Exiting on error or interrupt
Solution:
sudo apt-get install xsltproc
then run
./ltib
Error (2):
configure: error: in `/home/sainath/ltib/ltib/rpm/BUILD/zbar-0.10':
configure: error: test for video support failed!
rebuild your kernel to include video4linux support or
configure --disable-video to skip building video support.
See `config.log' for more details.
error: Bad exit status from /home/sainath/ltib/ltib/tmp/rpm-tmp.92831 (%build)
Solution:
Link for zbar patches:
https://github.com/PhantomX/slackbuilds/tree/master/zbar/patches
copy zbar_v4l.patch file to <path>/ltib/rpm/BUILD/zbar-0.10/
Apply patch
patch -p1 –verbose -i patch0_zbar_v4l.patch
autoconf
./ltib -m scbuild -p zbar.spec
Error (3):
+ make
cd . && /bin/bash /home/sainath/ltib/ltib/rpm/BUILD/zbar-0.10/config/missing --run autoconf
Can't locate object method "path" via package "Autom4te::Request" at //opt/freescale/ltib/usr/bin/autom4te line 81.
make: *** [configure] Error 1
error: Bad exit status from /home/sainath/ltib/ltib/tmp/rpm-tmp.7861 (%build)
RPM build errors:
Bad exit status from /home/sainath/ltib/ltib/tmp/rpm-tmp.7861 (%build)
Build time for zbar: 8 seconds
Failed building zbar
f_scbuild() returned an error, exiting
traceback:
main:572
Solution:
cd /opt/freescale/ltib/usr/bin/
sudo rm auto*
cd <path>/ltib/
./ltib -m scbuild -p zbar.spec
Error (4):
libtool: link: cannot find the library `/usr/lib/libMagickCore-6.Q16.la' or unhandled argument `/usr/lib/libMagickCore-6.Q16.la'
make[1]: *** [zbarimg/zbarimg] Error 1
Solution:
cd rootfs/usr/lib/
ls | grep Magic
Below is the result of above command on my PC:
ImageMagick-6.8.6
libMagick++-6.Q16.a
libMagick++-6.Q16.la
libMagick++-6.Q16.so
libMagick++-6.Q16.so.2
libMagick++-6.Q16.so.2.0.0
libMagickCore-6.Q16.a
libMagickCore-6.Q16.la
libMagickCore-6.Q16.so
libMagickCore-6.Q16.so.1
libMagickCore-6.Q16.so.1.0.0
libMagickWand-6.Q16.a
libMagickWand-6.Q16.la
libMagickWand-6.Q16.so
libMagickWand-6.Q16.so.1
libMagickWand-6.Q16.so.1.0.0
Remove all “.la” files of ImageMagick. And build the zbar again.
Error (5):
make[3]: Leaving directory `/home/sainath/ltib/ltib/rpm/BUILD/gtk+-2.14.3/modules'
make[2]: Leaving directory `/home/sainath/ltib/ltib/rpm/BUILD/gtk+-2.14.3/modules'
Making all in demos
make[2]: Entering directory `/home/sainath/ltib/ltib/rpm/BUILD/gtk+-2.14.3/demos'
no --raw --build-list\
apple_red ./apple-red.png\
gnome_foot ./gnome-foot.png\
> test-inline-pixbufs.h\
|| (rm -f test-inline-pixbufs.h && false)
/bin/bash: no: command not found
make[2]: *** [test-inline-pixbufs.h] Error 1
make[2]: Leaving directory `/home/sainath/ltib/ltib/rpm/BUILD/gtk+-2.14.3/demos'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/sainath/ltib/ltib/rpm/BUILD/gtk+-2.14.3'
make: *** [all] Error 2
error: Bad exit status from /home/sainath/ltib/ltib/tmp/rpm-tmp.15343 (%build)
RPM build errors:
Bad exit status from /home/sainath/ltib/ltib/tmp/rpm-tmp.15343 (%build)
Build time for gtk2: 572 seconds
Failed building gtk2
Solution:
sudo apt-get install libgtk2.0-dev
sudo apt-get install libgdk-pixbuf2.0-dev
sudo rm -r rpm/BUILD/gtk2
./ltib -m prep -p gtk2.spec
./ltib -m scbuild -p gtk2.spec
Error (6):
error Qzbar.cpp: x11Info was not declared in this scope
error 'fromstdstring' is not a member of 'qstring'
error 'tostdstring' is not a member of 'qstring'
Solution:
Copy “patch1_qt.patch” into “zbar-0.10” directory.
Execute below command on terminal
patch -p2 –verbose -i patch1_qt.patch