cd ~
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.3/OpenCV-2.3.0.tar.bz2
tar -xvf OpenCV-2.3.0.tar.bz2
cd OpenCV-2.3.0/
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
make
wget http://downloads.sourceforge.net/project/opencvlibrary/opencv-unix/2.3/OpenCV-2.3.0.tar.bz2
tar -xvf OpenCV-2.3.0.tar.bz2
cd OpenCV-2.3.0/
mkdir release
cd release
cmake -D CMAKE_BUILD_TYPE=RELEASE -D CMAKE_INSTALL_PREFIX=/usr/local -D BUILD_PYTHON_SUPPORT=ON ..
make
su
make install
vim /etc/ld.so.conf.d/opencv.conf
加入
/usr/local/lib
执行
ldconfig
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
cd ~/OpenCV-2.3.0/samples/c
chmod +x build_all.sh
./build_all.sh
./facedetect --cascade="/usr/local/share/opencv/haarcascades/haarcascade_frontalface_alt.xml" --scale=1.5 lena.jpg
这时如果出现一副图片则说明OpenCV安装成功。
随便写一段代码测试
g++ `pkg-config --cflags --libs opencv` code.cpp -o drawing
编译运行成功!