下载opencv-3.2.0安装包
上传到linux 上面
编译opencv-3.2.0 之前 请保证已经安装好 cmake make python gtk+等 相关工具
yum install cmake gcc gcc-c++ gtk+-devel gimp-devel gimp-devel-tools gimp-help-browser zlib-devel libtiff-devel libjpeg-devel libpng-devel gstreamer-devel libavc1394-devel libraw1394-devel libdc1394-devel jasper-devel jasper-utils swig python libtool nasm
运行完之后
进入opencv-3.2.0 目录 执行
cmake .
make
make install
完成安装之后 会自动在/usr/local/lib 下面 包含 opencv相关库文件
开发环境基本上搭建好了
写个测试小程序
#include <opencv2/opencv.hpp> #include <opencv2/highgui/highgui.hpp> #include <opencv2/imgcodecs/imgcodecs.hpp> int main(){ cv::Mat srcImage = cv::imread("1.jpg"); imshow("Original Image", srcImage); cv::waitKey(0); return 0; }
CMakeLists.txt 文件如下
cmake_minimum_required (VERSION 2.8) project (ShowImage) find_package( OpenCV REQUIRED ) include_directories( ${OpenCV_INCLUDE_DIRS} ) # add the executable add_executable (ShowImage ShowImage.cpp) target_link_libraries(ShowImage opencv_core opencv_highgui opencv_imgcodecs)
执行cmake . && make
生成可执行文件
然后拷贝一个1.jpg到本地目录 试试效果
运行./ShowImage
完成!
opencv 目录下 有很多官方的示例 有时间自己去尝试!
下次分享官方示例和一些公用的CmakeLists 公用Makefile