Tuesday, March 6, 2012

Shared Libraries with Eclipse on 86_64 (64 bits) systems

If you followed my previous post http://linuxtortures.blogspot.com/2012/02/shared-libraries-with-eclipse.html
where I explained how to develop shared shared libraries there are a couple of extra steps that you must follow if you want to do the same onto a 84_64 system.

A. Download the appropriated version of eclipse from the official download page.

The package deployed for debian amd64 (Eclipse-CDT) does not work very well, so in this case the trick of adding the backports repository will not be useful.




B. Eclipse is java-based so you can just untar the file and execute the 'eclipse' file inside:



If you find difficulties when executing eclipse, or eclipse environment generates errors most probably there are dependencies that are not fulfilled. A non very elegant solution could be install the eclipse-cdt from the backports (It will automatically install all the needed dependencies) and then uninstall it. Then you can should be able to execute your 'manually' downloaded eclipse without issues.

C. Making and compiling Shared libraries:

Here there is a slight difference regarding the previous post. If you want to make a shared library compile within a 64 bits system you will need the 'Position Independent Code' (basically it will add the options '-fPIC'  to g++, otherwise you will receive a nice error like the following:

/usr/bin/ld: ./MyClass.o: relocation R_X86_64_32S against `vtable for MyClass' can not be used when making a shared object; recompile with -fPIC

Fortunately Eclipse allows us  to make this in a graphical way (Right click on the shared library --> Properties) and check the following check-box:


That should make the work. If you are very interested on this option you can find more information here:

http://www.technovelty.org/code/c/amd64-pic.html

Friday, March 2, 2012

Image processing with OpenCV

Hi again!! Following the format of my previous posts I will try to show step by step how to install and configure the OpenCV libraries, one of main open source references regarding image and video processing.

A. Installing the dependencies on Debian Squeeze

1. CMake

sudo apt-get install cmake


2. pkg-config

sudo apt-get install pkg-config



3. GTK

sudo apt-get install libgtk2.0-cil libgtk2.0-cil-dev
sudo apt-get install libgtk2.0-0 sudo apt-get install libgtk2.0-dev


4. Miscellaneous dependencies


sudo apt-get install swig
sudo apt-get install libjpeg62 libjpeg62-dev
sudo apt-get install libtiff4  libtiff4-dev
sudo apt-get install libjasper1 libjasper-dev 
sudo apt-get install libpng12-0 libpng-dev
sudo apt-get install zlib1g zlib1g-dev
sudo apt-get install openexr
sudo apt-get install ffmpeg
sudo apt-get install libgstreamer0.10-0 libgstreamer0.10-dev
sudo apt-get install libv4l-0 libv4l-dev
sudo apt-get install libxine1 libxine-dev
sudo apt-get install libunicap2 libunicap2-dev
sudo apt-get install libdc1394-22 libdc1394-22-dev

sudo apt-get install libavcodec52 libavcodec-dev
sudo apt-get install libavutil49 libavutil-dev
sudo apt-get install libpostproc51 libpostproc-dev
sudo apt-get install libswscale0 libswscale-dev
sudo apt-get install libavfilter0 libavfilter-dev


B. Download the libcv libraries and untar it on a local directory. You can download it from here: http://opencv.willowgarage.com/wiki/

C. Compiling the libcv library and headers


cd /home/javier/Desktop/OpenCV-2.3.1/
mkdir release
cd release



cmake D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_EXAMPLES=ON ..


My results:



-- General configuration for opencv 2.3.1 =====================================
-- 
--     Built as dynamic libs?:     YES
--     Compiler:                   /usr/bin/c++
--     C++ flags (Release):          -Wall -pthread -march=i686 -ffunction-sections  -O3 -DNDEBUG  -fomit-frame-pointer -msse -msse2 -mfpmath=387 -DNDEBUG 
--     C++ flags (Debug):            -Wall -pthread -march=i686 -ffunction-sections  -g  -O0 -DDEBUG -D_DEBUG -ggdb3 
--     Linker flags (Release):
--     Linker flags (Debug):
-- 
--   GUI: 
--     GTK+ 2.x:                   YES
--     GThread:                    YES
-- 
--   Media I/O: 
--     ZLib:                       YES
--     JPEG:                       TRUE
--     PNG:                        TRUE
--     TIFF:                       TRUE
--     JPEG 2000:                  TRUE
--     OpenEXR:                    NO
--     OpenNI:                     NO
--     OpenNI PrimeSensor Modules: NO
--     XIMEA:                      NO
-- 
--   Video I/O:
--     DC1394 1.x:                 NO
--     DC1394 2.x:                 YES
--     FFMPEG:                     YES
--       codec:                    YES
--       format:                   YES
--       util:                     YES
--       swscale:                  YES
--       gentoo-style:             YES
--     GStreamer:                  NO
--     UniCap:                     NO
--     PvAPI:                      NO
--     V4L/V4L2:                   Using libv4l
--     Xine:                       NO
-- 
--   Other third-party libraries:
--     Use IPP:                    NO
--     Use TBB:                    NO
--     Use ThreadingFramework:     NO
--     Use Cuda:                   NO
--     Use Eigen:                  NO
-- 
--   Interfaces:
--     Python:                     YES
--     Python interpreter:         /usr/bin/python2.6 -B (ver 2.6)
--     Python numpy:               YES
--     Java:                       NO
-- 
--   Documentation:
--     Sphinx:                     NO
--     PdfLaTeX compiler:          NO
--     Build Documentation:        NO
-- 
--   Tests and samples:
--     Tests:                      YES
--     Examples:                   YES
-- 
--   Install path:                 /usr/local
-- 
--   cvconfig.h is in:             /home/javier/Desktop/OpenCV-2.3.1/release
-- -----------------------------------------------------------------
-- General configuration for opencv 2.3.1 =====================================
-- 
--     Built as dynamic libs?:     YES
--     Compiler:                   /usr/bin/c++
--     C++ flags (Release):          -Wall -pthread -march=i686 -ffunction-sections  -O3 -DNDEBUG  -fomit-frame-pointer -msse -msse2 -mfpmath=387 -DNDEBUG 
--     C++ flags (Debug):            -Wall -pthread -march=i686 -ffunction-sections  -g  -O0 -DDEBUG -D_DEBUG -ggdb3 
--     Linker flags (Release):
--     Linker flags (Debug):
-- 
--   GUI: 
--     GTK+ 2.x:                   YES
--     GThread:                    YES
-- 
--   Media I/O: 
--     ZLib:                       YES
--     JPEG:                       TRUE
--     PNG:                        TRUE
--     TIFF:                       TRUE
--     JPEG 2000:                  TRUE
--     OpenEXR:                    NO
--     OpenNI:                     NO
--     OpenNI PrimeSensor Modules: NO
--     XIMEA:                      NO
-- 
--   Video I/O:
--     DC1394 1.x:                 NO
--     DC1394 2.x:                 YES
--     FFMPEG:                     YES
--       codec:                    YES
--       format:                   YES
--       util:                     YES
--       swscale:                  YES
--       gentoo-style:             YES
--     GStreamer:                  NO
--     UniCap:                     NO
--     PvAPI:                      NO
--     V4L/V4L2:                   Using libv4l
--     Xine:                       NO
-- 
--   Other third-party libraries:
--     Use IPP:                    NO
--     Use TBB:                    NO
--     Use ThreadingFramework:     NO
--     Use Cuda:                   NO
--     Use Eigen:                  NO
-- 
--   Interfaces:
--     Python:                     YES
--     Python interpreter:         /usr/bin/python2.6 -B (ver 2.6)
--     Python numpy:               YES
--     Java:                       NO
-- 
--   Documentation:
--     Sphinx:                     NO
--     PdfLaTeX compiler:          NO
--     Build Documentation:        NO
-- 
--   Tests and samples:
--     Tests:                      YES
--     Examples:                   YES
-- 
--   Install path:                 /usr/local
-- 
--   cvconfig.h is in:             /home/javier/Desktop/OpenCV-2.3.1/release
-- -----------------------------------------------------------------




D. Installing the libraries and headers

make


sudo make install


E. Our first opencv project with Eclipse

1. Open Eclipse and add a new 'Hello World' C++ project



2. Include the following libraries (You can find more information about how to add shared libraries in my previous post: http://linuxtortures.blogspot.com/2012/02/shared-libraries-with-eclipse.html)



3. For our first project we will just open and display an image. Include the following code in your main method:


Note that it is supposed that it exists a picture called 'gnu-linux.jpg' on the folder /home/javier/Desktop/

Compile your project and run it. If you have have problems running your project:


error while loading shared libraries: libmytestsharedlibrary.so: cannot open shared object file: No such file or directory


Create the following file :

/etc/ld.so.conf.d/opencv.conf


Add the following line:

/usr/local/lib


And execute the following command:

sudo ldconfig

Explanations about all this process can be found as well in my previous post.

If everything went ok the system should have prompted your picture:



RESOURCES

Books:

http://www.amazon.com/Learning-OpenCV-Computer-Vision-Library/dp/0596516134

http://www.packtpub.com/opencv-2-computer-vision-application-programming-cookbook/book

Webs

http://opencv.willowgarage.com/wiki/

Thursday, March 1, 2012

Todo's

I will keep a list of posts (In most of the cases series of posts) that I have in mind, if you are interested on anyone in particular just let me know it by leaving a comment and I will prioritize it.

C++ and MySQL

libmysqlcppcon-dev
libboost-all-dev


Debian Packages

Advanced Image processing with OpenCV 

Web Services on C++ with gSoap

Client
wsdl2h -o calc.h http://www.genivia.com/calc.wsdl
sudo soapcpp2 -i -C -I/usr/include/gsoap calc.h

Server
soapcpp2 -I/usr/include/gsoap calc.h

C++ Documentation with Doxygene

sudo apt-get install doxygen
doxygen -g myconfig

INPUT
OUTPUT_DIRECTORY
RECURSIVE

FILE_PATTERNS          = *.cpp *.h
GENERATE_XML           = YES


Apache modules development


Android development with eclipse and Android sdk

http://dimitar.me/how-to-connect-your-android-phone-to-ubuntu-to-do-developmenttestinginstallations-or-tethering/

lsusb > id
gedit /etc/udev/rules.d/51-android.rules
SUBSYSTEMS==”usb”, ATTRS{idVendor}==”0bb4″, ATTRS{idProduct}==”0c01″, MODE=”0666″
$ sudo restart udev

***SCREENSHOTS
https://help.ubuntu.com/community/AndroidScreenshots
Settings > Applications > Development