ubuntu14.04 under Configuration using openCV3.0

Source: Internet
Author: User

Operating system Ubuntu 14.04 LTS

[OPENCV Version] 3.0.0-beta

[Eclipse Version] 3.8.1

Knowledge Required:

    • Linux System shell Command basics
    • Compilation fundamentals, Precompiled--compilation---Links
    • Make, CMake knowledge
    • IDE Usage Experience
    • gcc,g++ Compiler knowledge
First, compile and install opencv3.01. Prepare the Environment

Directly compile the installation OpenCV is usually error, there are many dependent tools need to install first. Mainly: CMake, build-essential, Pkg-config, Python-dev, Python-numpy and so on, depending on their own circumstances.

sudo Install build-essential cmake libopencv-dev libgtk2. 0 pkg-config Python-dev python-numpy
2. Download opencv3.0 Source code

Go directly to opencv.org (GitHub) to download the Linux source package:

wget https://github.com/itseez/opencv/archive/3.0.0-beta.zip
3. Unzip the organization, compile, install

Unzip the file, create a new folder for the compilation results, and then install (select Install under/usr/local)

$Unzipopencv-3.0.0-beta.Zip$ cd OpenCV-3.0.0-Beta $mkdirRelease $ cd release $ cmake-D cmake_build_type=release-d cmake_install_prefix=/usr/local-d with_tbb=on-d build_new_python_support=on-d WITH_ V4l=on
-D with_qt=on-d With_opengl=on.//note CMakeList.txt in the previous Layer folder$ Make-j $ (NPROC)//make-j Multi-core processor (default make only one core, very slow), $ (NPROC) returns the number of cores of its own machine$ Make Install //Install the compiled results under/usr/local lib/and include/
4. Environment configuration

Editable text configuration section:/etc/ld.so.conf.d/add opencv.conf file, record library installation location; update configuration

$ cd/etc/ldsudovi  opencv.config  //  Insert "/usr/local/lib "    : Qsudo ldconfig

Some places say, need to configure/ETC/BASH.BASHRC in Pkg_config_path environment variable, seemingly do not need.

(It seems that the above opencv.conf are not configured.) As long as make install will be under/usr/local/lib/pkgconfig to generate OPENCV.PR, link configuration).

Check that the Include, link configuration is correct:

pkg-config OpenCV--cflags---i/usr/local/include/opencv-i/usr/local/include  /usr/local/lib /libopencv_calib3d.so/usr/local/lib/libopencv_core.so/usr/local/lib/libopencv_features2d.so/usr/local/lib/ libopencv_flann.so/usr/local/lib/libopencv_highgui.so/usr/local/lib/libopencv_imgcodecs.so/usr/local/lib/ LIBOPENCV_IMGPROC.SO/USR/LOCAL/L ib/libopencv_ml.so/usr/local/lib/libopencv_objdetect.so/usr/local/lib/ Libopencv_photo.so/usr/local/lib/libopencv_shape.so/usr/local/lib/libopencv_stitch ing.so/usr/local/lib/ Libopencv_superres.so/usr/local/lib/libopencv_ts.a/usr/local/lib/libopencv_video.so/usr/local/lib/libopencv_ VIDEOIO.SO/USR/LOCAL/L ib/libopencv_videostab.so
Second, use OpenCV library 1. Command line Form

Write C or C + + programs directly, and then generate executable programs with the gcc,g++ compiler, respectively.

1) C Program version:

#include intMainintargcChar**argv) {Iplimage* img = cvloadimage (argv[1],cv_load_image_color); Cvnamedwindow ("Image_show", cv_window_autosize); Cvshowimage ("Image_show", IMG); Cvwaitkey (0); Cvreleaseimage (&img); Cvdestroywindow ("Image_show"); return 0; }

Compile process:

gcc test.c-o test 'pkg-config opencv--cflags--libs '

2) C + + program version:

#include <opencv2/opencv.hpp>using namespaceCV; intMainintargcChar**argv)    {Mat image; Image= Imread (argv[1],1 ); if(ARGC! =2|| !image.data) {printf ("No image data \ n" ); return-1; } Namedwindow ("Display Image", window_autosize); Imshow ("Display Image", image); Waitkey (0); return 0; }

Compile process:

$ g++ first. CPP -o first 'pkg-config opencv--cflags--libs '     //INCLUDE, link parameter must be in the back
2. CMake operation form

CMake is to organize the dependencies and raw materials required by the program, generate makefile, and then compile and build the executable program. The most important thing is to write the CMakeList.txt file. The above-mentioned C + + program, for example, CMakeList.txt:

2.8 Project (first) find_package (OpenCV REQUIRED) add_executable (first frist. CPP ) target_link_libraries (First  ${opencv_libs})

Then, CMake, then make:

 Make $. /first
3. IDE Development tools

Using the OpenCV library in IDE tools (such as Vs,eclipse), as in the above two approaches, is to configure the include and Lib sections as well.

Specific Ubuntu under the Eclipse method, continue below.

Iii. C + + development environment under eclipse 1. Install Eclipse

Ubuntu installation is simple, directly in the Software center. or direct command line Apt-get install

2. Configuring the C + + development environment

Open Eclipse, and under the Help menu, choose Install New software. In the Install dialog box that opens, select the Indigo Update site-http://download.eclipse.org/releases/indigo/source from the work with drop-down menu. After the network refreshes:

1) Select the Mylyn Context connector:c\c++ development component in collaboration, then install and restart eclipse;

2) Continue back to the Install dialog box and select C\c++ related components in programming language, such as development tools,development Tools SDK,CDT Visual C + + support.

Once you have installed the above components, you can create a new C + + project in Eclipse.

3. OPENCV Practice

1) Create a new empty C + + project and add the source Folder,source file, and copy the above C + + read graph code. At this point will certainly prompt a lot of problems, compilation must be wrong.

2) The next step is to configure the Include files and link libraries. Right-click the project in Project Explorer, open properties, click the c\c++ build option, and then tap set setting.

A) set include include. Add the include path:/usr/local/include,/usr/local/include/opencv,/usr/local/include/in the includes below the GCC C + + compiler OpenCV (depending on your code choice include, insurance, three are set up).

b) Set up the link library. In GCC C + + linker below the libraries, first add search path:/usr/local/lib; then add Opencv_core, Opencv_highgui, opencv_ in libraries Imgproc, Opencv_imgcodes (seems to be a new more out of one, do not add an error).

3) configuration is complete, project--Build all. In addition, if you use the IDE's properties to add program parameters, the file path name is best to use absolute path (its current path should be your project level directory, according to this set relative path also).

Reference:

[1] Rodrigo Berriel ' s website:http://rodrigoberriel.com/2014/10/installing-opencv-3-0-0-on-ubuntu-14-04/

[2] Using OpenCV with eclipse:http://docs.opencv.org/doc/tutorials/introduction/linux_eclipse/linux_eclipse.html

ubuntu14.04 under Configuration using openCV3.0

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.