OpenCV官方给出的Linux下安装实在不方便,要root权限,install后还要执行好 ‡ 步操作,实在是烦人,参考了老外的 ‡ 个例子,
在Linux另一种安装使用方法如下。
1、解压OpenCV。
 下载地址:
Â
http://www.fcdpj.com/component/option,com_docman/task,doc_details/gid,185/Itemid,34.html  解压到指定的位置,我解压到了 /home/xxx/opencv
2、配置,编译,安装
  指定OpenCV库安装的位置
 ./configure --prefix=/home/xxx/opencv/sdk
 其他配置选项可以按自己需要增 ˆ
 make
 make install
Â
3、用一个小程序测试
// C++ includes.
| 代码: : |
#include
// OpenCV includes.
#include
#include
int main(int argc, char* argv[])
{
// Make sure the user passed in the right number of arguments.
if (argc != 2)
{
std::cout , JPG, PNG, PBM, PGM, PPM, SR, RAS, TIFF, TIF.
IplImage* image = cvLoadImage(argv[1]);
// Create a window with the given name (displayed at the top of the
// window). Also, we'll make it automatically resize to whatever content
// it displays.
cvNamedWindow("My Window", CV_WINDOW_AUTOSIZE);
// Make the image show up in the named window.
cvShowImage("My Window", image);
// Pause here until the user presses a key.
cvWaitKey(0);
// Destroy the image and window.
cvReleaseImage(&image);
cvDestroyWindow("My Window");
return 0;
}
|
4、使用这里提供的一个非常简单makefile编译
INSTALLLIB = /home/username/opencv/sdk
把Makefile里的INSTALLLIB改成你自己的路径
APP = ftest 改成你自己的文件名
然后
make
make setlib
make 是来编译代码
make setlib是用来设置LD_LIBRARY_PATH,执行一次就可以了。
5、如果一切正常的话,执行./ftest xxx.jpg就可以看到效果了
MD5校验值 : 890043e34cced3f76b728dea0789f05c