CMakeLists.txt编写
最简单的形式如下:
# cmake needs this line
cmake_minimum_required(VERSION 2.8)
# define project name
project(opencvTest)
# fined OpenCV
find_package(OpenCV REQUIRED)
# display message
message(STATUS "OpenCV library status:")
message(STATUS " version: ${OpenCV_VERSION}")
message(STATUS " libraries: ${OpenCV_LIBS}")
message(STATUS " include path: ${OpenCV_INCLUDE_DIRS}")
# Add OpenCV headers location to your include paths
include_directories(${OpenCV_INCLUDE_DIRS})
# Declare the executable target built from your sources
set(SRC_LIST main.cpp)
add_executable(main ${SRC_LIST})
# Link your application with OpenCV libraries
target_link_libraries(main ${OpenCV_LIBS})
头文件包括
#include<opencv2/opencv.hpp>
#include<opencv2/highgui.hpp>
#include <opencv2/highgui/highgui_c.h>
using namespace cv;
// etc
Mat矩阵处理
Mat类,参考博客:链接
图像处理
函数:有 python-opencv 一样的形式imread(path)
imshow(str:winname, image)
waitKey(n_ms)
imwrite(path, image)
视频处理
读取视频:
VideoCapture capture;
capture.open("./video/MaBaoguo.avi");
// frame << capture; // 当作流处理
// capture.read(frame);
// ...
capture.release()
保存视频:
int myFourCC = VideoWriter::fourcc('X', 'V', 'I', 'D'); // .avi
VideoWriter outputVideo("MaBaoguoFiltered.avi", myFourCC, rate, size, true);
// outputVideo << frame; 帧写入
// ...
outputVideo.release()
上一篇:开始学习C
下一篇:函数----C 编程模块