OpenCV下载编译安装
Download url:
cd ~/Workshop
tar xvf OpenCV-2.3.0rc.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
sudo make install
在ubuntu系统中你也可以通过新立得去安装opencv,非常方便,不过它的头文件默认路径是/usr/include,库的默认路径是/usr/lib/,由于版本差异,相应地库名也不一样了。
OpenCV配置
让系统知道opencv库的路径以便在QT中使用
方法一:
sudo vi /etc/ld.so.conf.d/opencv.conf
增加/usr/local/lib
sudo ldconfig
方法二:
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
通过OpenCV显示图片
/*displayImage/image.cpp*/
#include
#include
using namespace cv;
int main( int argc, char** argv )
{
Mat image;
image = imread( argv[1], 1 );
if( argc != 2 || !image.data )
{
printf( "No image data \n" );
return -1;
}
namedWindow( "Display Image", CV_WINDOW_AUTOSIZE );
imshow( "Display Image", image );
waitKey(0);
return 0;
}
qmake -project
vi displayImage.pro
修改
INCLUDEPATH += /usr/local/include/opencv
LIBS += /usr/local/lib/libopencv_core.so \
/usr/local/lib/libopencv_highgui.so \
/usr/local/lib/libopencv_ml.so
qmake
make
./displayImage test.jpg
Reference
1、
阅读(2658) | 评论(0) | 转发(0) |