Install opencv2.3 on Ubuntu 11.04 The Installation failed several times, but opencv was successfully installed. Now I will share with you my summary and make progress together! Note the following.Step 1: Install necessary dependency packages Sudo apt-Get install build-essential libgtk2.0-dev libjpeg62-dev libtiff4-dev libjasper-dev libopenexr-dev cmake Python-dev Python-numpy libtbb-dev libeigen2-dev yasm libfaac-dev libopencore-amrnb-lidev bopencore -amrwb-dev libtheora-dev libvorbis-dev libxvidcore-Dev// Ensure that the computer is connected to the Internet. Some problems may occur when the computer is installed, which leads to errors in this step. In fact, the solution is very simple, that is to break down the installation command into one installation, which will succeed. Why? I checked it online mainly because of version issues. The old package must be uninstalled when the new package is installed. However, the next package may need to be installed when the new package is uninstalled. Therefore, dependencies are generated (I personally understand, I don't know if it is correct)Step 2: Install FFMPEG1Cd ~// Enter the user's home directory (that is:Home/your computer name/) 2Wget http://ffmpeg.org/releases/ffmpeg-0.7-rc1.tar.gz// Download the ffmpeg-0.7-rc1.tar.gz installation package from the Internet. The speed is faster, so that step 1 can be omitted and directly go to step 2.3Tar-xvzf ffmpeg-0.7-rc1.tar.gz// Note: The FFMPEG package will be found in "home/your computer name/download/" when you download the package in step 1, Copy it to"Home/your computer name/"; it will also be downloaded firstPut the FFMPEG package in the main directory 4CD ffmpeg-0.7-rc15. /Configure -- enable-GPL -- enable-version3 -- enable-nonfree -- enable-postproc -- enable-libfaac -- enable-libopencore-amrnb -- enable-libopencore-amrwb -- enable-libtheora -- enable -- enable-libxvid -- enable-x11grab -- enable-swscale -- enable-shared6Make// Compile, at this time the virtual terminal path is: Home/your computer name/ffmpeg-0.7-rc1/7Sudo make install// InstallStep 3: Install opencv 2.31Cd ~2Wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.3/OpenCV-2.3.0.tar.bz2// The method is the same as step Step 23 tar-xvf OpenCV-2.3.0.tar.bz24 CD OpenCV-2.3.0/5 mkdir release // Create a folderRelease6 CD release7 cmake-D cmake_build_type = release-D cmake_install_prefix =/usr/local-D placement = on-D with_tbb = on-D with_v4l = OFF-D install_c_examples = on-D release = On-D build_examples = on .. 8Make// Compile, at this time the virtual terminal path is: Home/your computer name/OpenCV-2.3.0/Release/9Sudo make installStep 4: add the library path1Sudo gedit/etc/lD. So. conf. d/opencv. conf// The path of the virtual terminal is the user's main directory.Add:/usr/local/libThen save2Sudo ldconfigUpdate System Library3Sudo gedit/etc/environment (or sudo gedit/etc/bash. bashrc) sets the environment variable //The path of the virtual terminal is the user's main directory.Add pkg_config_path = $ pkg_config_path:/usr/local/lib/pkgconfig The opencv settings are complete.Step 5: Test1Cd ~ /OpenCV-2.3.0/samples/CEnter the sample in the opencv source code directory.2Chmod + x build_all.sh3./Build_all.sh4./Facedetect -- cascade = "/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" -- scale = 1.5 lena.jpgNote: 1. Note that letters and punctuation marks are entered in English; otherwise, an error occurs.2. In this installation method, install opencv in the user's home directory and enter the command on the virtual terminal. 3. Note the path.A simple example of hellocv. cpp:
#include "opencv2/imgproc/imgproc.hpp"#include "opencv2/highgui/highgui.hpp" using namespace cv;using namespace std; int main(int argc, char* argv[]){ Mat img = imread("lena.jpg"); if(!img.data) return -1; namedWindow("Lena", CV_WINDOW_AUTOSIZE); imshow("Lena", img); waitKey(); return 0;}
Put a lena.jpg image in the "hellocv.cpp" directory.
Run the following command:
g++ `pkg-config --cflags opencv` `pkg-config --libs opencv` hellocv.cpp -o hellocv