opencv可以用新立得安装
一、eclipse开发
1.新建empty project
2.新建main.cpp
-
#include <cv.h>
-
#include <highgui.h>
-
-
using namespace cv;
-
-
int main(int argc, char* argv[])
-
{
-
Mat image;
-
image = imread("./lbb.jpg");
-
-
if (!image.data)
-
{
-
printf("No image data\n");
-
return -1;
-
}
-
-
namedWindow("Display Image", CV_WINDOW_AUTOSIZE);
-
imshow("Display Image", image);
-
waitKey(0);
-
return 0;
-
}
3.工程右键->properties->c/c++ build->settings->gcc c++ compiler->includes添加opecv头文件路径(可用命令查询pkg-config --cflags opencv)
4. gcc c++ linker->libraries添加opencv_core opencv_highgui opencv_imgproc(多行)
5.确认目录下有lbb.jpg,ctrl_b ctrl_f11
二、不借助IDE
1.在/home 下新建work/opencvTest
2.新建test.cpp内容如上
3.编写CMakeLists.txt,内容如下:
-
project(test)
-
find_package(OpenCV REQUIRED)
-
add_executable(test test)
-
target_link_libraries(test ${OpenCV_LIBS})
-
cmake_minimum_required(VERSION 2.8)
4.
~/work/opencvTest cmake .
5. ~/work/opencvTest make
6.
~/work/opencvTest ./test
阅读(677) | 评论(0) | 转发(0) |