Linux, C++ and other Tortures

  • Subscribe to our RSS feed.
  • Twitter
  • StumbleUpon
  • Reddit
  • Facebook
  • Digg

Friday, 2 March 2012

Image processing with OpenCV

Posted on 11:28 by Unknown
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/

Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest
Posted in | No comments
Newer Post Older Post Home

0 comments:

Post a Comment

Subscribe to: Post Comments (Atom)

Popular Posts

  • Mercurial with Apache... on the Cloud!!
    And here we go with our third tutorial explaining how to deploy and enjoy applications 'In the cloud'. This time we will take advant...
  • Cross Compiling and Cross Debugging C++ with Eclipse from Debian Squeeze x64 to Debian Squeeze ARM (Raspberry Pi)
    1. Introduction I have received yesterday my Raspberry Pi ( http://www.raspberrypi.org/ )  unit.  Fig 1. Raspberry Pi connected After comple...
  • Shared Libraries with Eclipse
    Hello there! So here we go with another tutorial, this time explaining how to develop shared libraries using Eclipse-CDT as IDE. If you are...
  • Unit Testing with CppUnit and Eclipse
    As I already mentioned in one of my previous posts, CppUnit is a powerful framework that allows us to automatize the unit testing execution....
  • Communicating with RaspBerry via GSoap Web Services
    According to wikipedia "A Web service is a method of communication between two electronic devices over the Web (Internet)." I wou...
  • 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 deve...
  • Configuring Ubuntu on my new HP G62-a55SF
    As usual, after the Operative System installation, there are some drivers to configure and some programs and features to install. Comparing ...
  • Using C++ Libraries from Python
    It's been a while since my last post but here I am back with a very interesting post about Wrapping C++ libraries to be used in python. ...
  • 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 ...
  • Continuous Integration with Jenkins, Mercurial and CppUnit on C++
    Hello again!! Today I am going to talk about Jenkins, an open source tool that enables the continuous integration and delivery for our proje...

Blog Archive

  • ▼  2012 (9)
    • ►  December (1)
    • ►  July (1)
    • ►  June (1)
    • ►  April (2)
    • ▼  March (3)
      • Shared Libraries with Eclipse on 86_64 (64 bits) s...
      • Image processing with OpenCV
      • Todo's
    • ►  February (1)
  • ►  2011 (7)
    • ►  December (5)
    • ►  January (2)
  • ►  2010 (3)
    • ►  December (3)
Powered by Blogger.

About Me

Unknown
View my complete profile