After a long way try to develop C program with OpenCV library on Ubuntu Linux using NetBeans and Eclispe IDE, no succeed at all. There are always some problems occurs and the project cannot move on further so everything has to be move back onto Windows to be developed. But now all these thing can be developed in Linux by using traditional GNU C Compiler (GCC) that most of Linux users know it very well. This is the complete procedure from the beginning(install) till the end(compile-build).
Part A. Install OpenCV 2.0.0
1. Install prerequisites
Enter this line into Linux Terminal:
$sudo apt-get install libavformat-dev libgtk2.0-dev pkg-config cmake libswscale-dev bzip2
;All these packages are the prerequisites for compiling and running OpenCV.
2.Get OpenCV 2.0.0 sourcecode
Obtains the sourcecode of OpenCV by visit Sourceforge or by enter this line to Terminal:
$wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.0/OpenCV-2.0.0.tar.bz2
3. Extract and Compile OpenCV 2.0.0
3.1 Extract by enter
3.2 Enter the directory
3.3 Create a output directory
3.4 COMPILE The OpenCV
This is the important one! For more information please see in Ref1 below.
3.5 Install OpenCV
3.6 Exporting Part
$tar xvjf OpenCV-2.0.0.tar.bz2
3.2 Enter the directory
$ cd OpenCV-2.0.0/
3.3 Create a output directory
$mkdir release; cd release
3.4 COMPILE The OpenCV
This is the important one! For more information please see in Ref1 below.
$cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
3.5 Install OpenCV
$make
$sudo make install
3.6 Exporting Part
$export LD_LIBRARY_PATH=/usr/local/lib/:$LD_LIBRARY_PATH
$sudo ldconfig
Part B Compile application with GCC using G++
This part is amazingly easy as eating an ice-cream!
All we have to do is to get into your project directory in Terminal, then use this command to compile your program!
All we have to do is to get into your project directory in Terminal, then use this command to compile your program!
$g++ `pkg-config opencv --cflags --libs` ProgramName.c -o ProgramName
That’s it! And we can execute our program by using command:
$./ProgramName
That’s all we need to do to use OpenCV 2.0.0 on Linux system.
Part C Program Example
Example code of OpenCV application can be found on Ref1. below.
Example code of OpenCV application can be found on Ref1. below.
0 comments:
แสดงความคิดเห็น