Configuring the OpenCV1.0 environment under Linux

Source: Internet
Author: User
Tags gtk image processing library

I have been shouting to learn the image recognition, identification of a simple, car grade, verification code and so on, previously checked data, OPENCV can be achieved. Yesterday spent an afternoon finally configured the environment, today write down the summary.

OpenCV This name contains the meaning of both open and computer vision. In fact, open refers to open source (open source, which is the opensource), and computer vision refers to computer vision. For more detailed information, please refer to: Http://zh.wikipedia.org/wiki/OpenCV

Configuring the Environment System Information: Linux

[Email protected]:~$ cat/etc/debian_version
7.6
[Email protected]:~$ cat/proc/version
Linux version 3.2.0-4-amd64 ([email protected]) (GCC version 4.6.3 (Debian 4.6.3-14)) #1 SMP Debian 3.2.60-1+deb7u1
[Email protected]:~$

OpenCV Version: 1.0

Why choose 1.0 for installation?

Because I want to realize the function is relatively simple, simple check data found the latest OpenCV2.4.9 version added C + + library, I am C + + slag Slag, the book is 1.0 version of the hand, older, so the decisive installation version selected 1.0.

Why choose to install on Linux?

Installed on Windows, there is a lot of information and tutorials, but the version has been compromised to 1.0, just as Linux on the installation industry forget almost, moreover, the personal think, under the Linux installation success, Windows should also be able, conversely, not necessarily, so choose to install on Linux.

Well, the crap doesn't say much, start the installation. (To save time, it is highly recommended to finish the tutorial before installing)

First step: Get the installation package

To http://sourceforge.net/projects/opencvlibrary/files/opencv-unix/1.0/download opencv-1.0.0.tar.gz source code package or to HTTP.// download at the bottom of the opencv.org/downloads.html

Step Two: Unzip

First, switch to the root user, and then locate the download location

#cd/home/your_user_name/downloads/

#tar-ZXVF opencv-1.0.0.tar.gz

At this time, a directory named: opencv-1.0.0 will appear in the current directory

#cd opencv-1.0.0

Step three: Execute./configure

#./configure

After executing this command, I did not go well and reported some errors:

Prompt you to install some of the libraries you need, I installed two, no error.

#apt-get Install g++

#apt-get Install Pkg-config

Fourth step: Execute./configure, if the following message appears, indicates success:

#./configure

General Configuration ================================================
compiler:g++
Cxxflags:-wall-fno-rtti-pipe-o3-fomit-frame-pointer

Install Path:/usr/local

Highgui Configuration ================================================

Windowing System--------------
Use Carbon/mac OS x:no
Use GTK + 2.x:yes
Use Gthread:yes

Image I/O---------------------
Use Libjpeg:yes
Use Zlib:yes
Use Libpng:yes
Use Libtiff:yes
Use Libjasper:yes
Use Libilmimf:no

Video I/O---------------------
Use Quicktime/mac OS x:no
Use Xine:no
Use Ffmpeg:no
Use dc1394 & Raw1394:no
Use V4l:no
Use V4l2:yes

Wrappers for other languages =========================================
SWIG
Python No

Additional Build Settings ============================================
Build Demo Apps Yes

Now run make ...

Fifth step: Run make

#make

The following error message appears after make:

.. /.. /cxcore/include/cxmisc.h:133:6: Error: #elif with no expression

Cause Analysis:
GCC 4.4 would introduce better checks in the preprocessor. The problem
is pretty obvious:you ' re using a #elif without any condition when
You really want a #else.

You can reproduce the problem with the gcc-snapshot from unstable.

> Automatic build of opencv_1.0.0-6.1 on EM64T by Sbuild/amd64 0.53
...
>/bin/sh. /.. /libtool--tag=cxx--mode=compile g++-dhave_config_h-i.-I.. /.. -I.-I.. /.. /cxcore/include-i. /.. -dndebug-fno-strict-aliasing-wall-g-fopenmp-o2-g-mt cxalloc.lo-md-mp-mf. Deps/cxalloc. Tpo-c-O Cxalloc.lo cxalloc.cpp
> g++-dhave_config_h-i.-I.. /.. -I.-I.. /.. /cxcore/include-i. /.. -dndebug-fno-strict-aliasing-wall-g-fopenmp-o2-g-mt cxalloc.lo-md-mp-mf. Deps/cxalloc. Tpo-c Cxalloc.cpp-fpic-dpic-o. LIBS/CXALLOC.O
> in file included from _cxcore.h:60,
> From cxalloc.cpp:42:
>.. /.. /cxcore/include/cxmisc.h:133:6: Error: #elif with no expression
> make[4]: * * * [Cxalloc.lo] Error 1
> make[4]: Leaving directory '/BUILD/TBM/OPENCV-1.0.0/CXCORE/SRC '
> make[3]: * * * [all-recursive] Error 1

Workaround:

Workaround:

---cxcore/include/cxmisc.h~ 2008-11-07 15:12:58.000000000 +0000 (delete)
+ + + cxcore/include/cxmisc.h 2008-11-07 15:13:03.000000000 +0000 (Open)
@@ -130,7 +130,7 @@
#include <alloca.h>
#elif defined Have_alloca
#include <stdlib.h>
-#elif
+ #else
#error
#endif

The above meaning is: The file #elif changed to #else after the compilation success!!!

Sixth step: Execute./configure,make

#./configure

#make

The following error is prompted:

g++-wall-fno-rtti-pipe-o3-fomit-frame-pointer-o. libs/opencv-haartraining haartraining.o libcvhaartraining.a.. /.. /.. /otherlibs/highgui/.libs/libhighgui.so/home/genie/downloads/opencv-1.0.0/cv/src/.libs/libcv.so. /.. /.. /cv/src/.libs/libcv.so/home/genie/downloads/opencv-1.0.0/cxcore/src/.libs/libcxcore.so. /.. /.. /cxcore/src/.libs/libcxcore.so-lpthread-ldl-lm
.. /.. /.. /otherlibs/highgui/.libs/libhighgui.so:undefined reference to ' cvcapturefromcam_v4l (int) '
Collect2:error:ld returned 1 exit status
MAKE[4]: * * * [opencv-haartraining] Error 1
MAKE[4]: Leaving directory '/HOME/GENIE/DOWNLOADS/OPENCV-1.0.0/APPS/HAARTRAINING/SRC '
MAKE[3]: * * * [all-recursive] Error 1
MAKE[3]: Leaving directory '/home/genie/downloads/opencv-1.0.0/apps/haartraining '
MAKE[2]: * * * [all-recursive] Error 1
MAKE[2]: Leaving directory '/home/genie/downloads/opencv-1.0.0/apps '
MAKE[1]: * * * [all-recursive] Error 1
MAKE[1]: Leaving directory '/home/genie/downloads/opencv-1.0.0 '
Make: * * * [ALL] Error 2

Workaround: https://code.ros.org/trac/opencv/changeset/5206, some file directories may be different, but the content is the same

Workaround: https://code.ros.org/trac/opencv/changeset/5206, some file directories may be different, but the content is the same

Unmodified:other
Added:Green part
Removed:Red part


Tabularunified Branches/2.2/opencv/cnconfig.h.cmake

Old line   New line number
   /*V4L2 capturing support */
#cmakedefine have_camv4l2
+
/* V4L/ V4l2 capturing support via libv4l */
#cmakedefine have_libv4l
$
/* Carbon windowing Environment */


Tabularunified Branches/2.2/opencv/modules/highgui/src/cap.cpp
172 172 return capture;
173 173 #endif
174 #if defined (have_camv4l) | | Defined (HAVE_CAMV4L2)
174 #if defined have_libv4l | | (Defined (HAVE_CAMV4L) && defined (HAVE_CAMV4L2))   
175 175 capture = cvcreatecameracapture_v4l (index);
176 176 if (capture)

Tabularunified Branches/2.2/opencv/modules/highgui/src/cap_libv4l.cpp
225 225 #include "precomp.hpp"
226 226
227 #if!defined WIN32 && defined Have_camv4l && defined have_camv4l2
227 #if!defined WIN32 && defined Have_libv4l
228 228
229 229 #defined CLEAR (x) memset (& (x), 0, sizeof (x))
.... ...
242 242 #include <sys/ioctl.h>
243 243
244#ifdef have_camv4l
244 245 #include <linux/videodev.h>
246#endif
247#ifdef HAVE_CAMV4L2
245 248 #include <linux/videodev2.h>
249#endif
246 250
247 251 #include <libv4l1.h>

7th step: Add a Library
Do a system update first

#apt-get Update

#apt-get Upgrade

Re-execute

#apt-cache Search OpenCV

After displaying the following information

Libcv-dev-translation Package for Libcv-dev
Libcv2.3-computer Vision library-libcv* Translation Package
Libcvaux-dev-translation Package for Libcvaux-dev
Libcvaux2.3-computer Vision Library-libcvaux Translation Package
Libhighgui-dev-translation Package for Libhighgui-dev
Libhighgui2.3-computer Vision Library-libhighgui Translation Package
libopencv-calib3d-dev-development files for Libopencv-calib3d
Libopencv-calib3d2.3-computer Vision Camera Calibration Library
libopencv-contrib-dev-development files for Libopencv-contrib
Libopencv-contrib2.3-computer Vision Contrib Library
libopencv-core-dev-development files for Libopencv-core
Libopencv-core2.3-computer Vision Core Library
libopencv-dev-development files for OpenCV
libopencv-features2d-dev-development files for libopencv-features2d
Libopencv-features2d2.3-computer Vision Feature Detection and Descriptor Extraction Library
libopencv-flann-dev-development files for Libopencv-flann
Libopencv-flann2.3-computer Vision clustering and Search in multi-dimensional spaces library
libopencv-gpu-dev-development files for Libopencv-gpu
Libopencv-gpu2.3-computer Vision GPU Processing Library
libopencv-highgui-dev-development files for Libopencv-highgui
Libopencv-highgui2.3-computer Vision High-level GUI and Media I/O Library
libopencv-imgproc-dev-development files for Libopencv-imgproc
Libopencv-imgproc2.3-computer Vision Image Processing Library
libopencv-legacy-dev-development files for Libopencv-legacy
Libopencv-legacy2.3-computer Vision Legacy Library
libopencv-ml-dev-development files for libopencv-ml
Libopencv-ml2.3-computer Vision Machine Learning Library
libopencv-objdetect-dev-development files for Libopencv-objdetect
Libopencv-objdetect2.3-computer Vision Object Detection Library
libopencv-video-dev-development files for Libopencv-video
Libopencv-video2.3-computer Vision Video Analysis Library
OPENCV-DOC-OPENCV Documentation and examples
Python-opencv-python bindings for the computer Vision Library

Re-execute: The following command, according to your own list to make a corresponding replacement, there may be some libraries will not be used, but in order to prevent future problems, I have all installed.

#apt-get Install Libcvaux-dev libcvaux2.3 libhighgui-dev libhighgui2.3 libopencv-calib3d-dev libopencv-calib3d2.3 Libopencv-contrib-dev libopencv-contrib2.3 Libopencv-core-dev libopencv-core2.3 Libopencv-dev Libopencv-features2d-dev libopencv-features2d2.3 Libopencv-flann-dev libopencv-flann2.3 Libopencv-gpu-dev libopencv-gpu2.3 Libopencv-highgui-dev libopencv-highgui2.3 Libopencv-imgproc-dev libopencv-imgproc2.3 Libopencv-legacy-dev libopencv-legacy2.3 Libopencv-ml-dev libopencv-ml2.3 Libopencv-objdetect-dev libopencv-objdetect2.3 Libopencv-video-dev libopencv-video2.3 Opencv-doc PYTHON-OPENCV

8th step: Re-execute./configure and make

#./configure

#make

9th step: I was basically no error, and then execute make install, if you have errors, welcome comments to inform

10th Step: Update the dynamic link library

#vim/etc/ld.so.conf

Add:/usr/local/lib to file in last line

Execute the following command:

#ldconfig

At this point: installation is complete.

Verify that the installation is successful:

Into the sample/c.

Pass

#ls

You can see this file with Drawing.c.

Execute the following command

# g++ Drawing.c-o drawing ' pkg-config--cflags--libs OpenCV '

Execution./drawing

The error is indicated: OpenCV error:unspecified error (the function is not implemented. Rebuild the library with Windows, GTK + 2.x or Carbon support.

Reason: The simple explanation is that your GTK + 2.x will be installed prior to OPENCV

So, reinstall GTK + 2.x, and then re-execute

#./configure

#make,

#make Install

#make Check (checks whether the installation is all correct)

Then compile with the g++ of the verification phase,

Re-execute

#./drawing

There was an animated effect.

Thanks to the following links and literature, help me solve a lot of problems:

https://code.ros.org/trac/opencv/changeset/5206

http://blog.csdn.net/loveaborn/article/details/7647734

http://www.raben.com/content/opencv-installation-ubuntu-1204

HTTP://OPENCV.WIKISPACES.COM/1) +installation+on+linux

http://blog.163.com/dingmz_frcmyblog/blog/static/217304023201321310532566/

Http://bbs.ednchina.com/BLOG_ARTICLE_277614.HTM

Http://www.arm9home.net/read.php?tid-15163.html

Http://www.arm9home.net/simple/index.php?t15163.html

Http://www.arm9home.net/read.php?tid-80418.html

Http://www.arm9home.net/read.php?tid-8386.html

"OpenCV Tutorial Basics"

www.google.com.hk

Www.baidu.com

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.