opencv包含如下几个模块,每一个模块中包含一些共享或者静态的库
1.core:核心组件模块
基础结构及操做,动态结构,数组操做,绘图函数、XML/YAML、聚类及实用程序和系统函数宏。
2.Imagpro:图像处理模块
包括线性和非线性图像滤波,几何图像变换(调整大小,仿射和透视扭曲,通用的基于表的从新映射),色彩空间转换,直方图等的图像处理模块。
3.video:视频分析模块,包括运动估计,背景减除和对象跟踪算法。
4.calib3d:基本的多视图几何算法,单个和立体相机校准,物体姿态估计,立体声对应算法和3D重建的元素。
5.features2d:2维特征框架
特征检测与描述,特征检测提取匹配接口,关键点与匹配点绘图及对象分类。
6.objdetect:检测对象和预约义类的实例(例如,面部,眼睛,杯子,人,汽车等)。级联分类器及SVM。
7.highgui:顶层GUI及视频I/O
用户界面,读/写图像及视频,QT新功能。
cv Namespace
全部OpenCV类和函数都被放置在cv命名空间中。 所以,要从代码访问此功能,需使用cv :: specifier或使用命名空间cv;
**我的理解是有了cv能够调用#include中的方法,二者互相关联。
1c++
#include "opencv2/core.hpp" ... cv::Mat H = cv::findHomography(points1, points2, CV_RANSAC, 5); ...
2算法
#include "opencv2/core.hpp" using namespace cv; ... Mat H = findHomography(points1, points2, CV_RANSAC, 5 ); ...
为了防止cv可能与STL或者其余库冲突,咱们用第一种方法。
自动内存管理
opencv自动管理内存问题
首先,函数和方法使用的std :: vector,Mat和其余数据结构具备析构函数,在须要时释放基础内存缓冲区。 这意味着在Mat的状况下,析构函数并不老是释放缓冲区。 他们考虑到可能的数据共享。 析构函数将与矩阵数据缓冲器相关联的引用计数器递减。 当且仅当引用计数器达到0时,即当没有其余结构指向相同的缓冲区时,缓冲区被解除分配。 相似地,当Mat实例被复制时,实际数据不会被真正复制。 相反,引用计数器增长以记住拥有相同数据的另外一个全部者。 还有Mat :: clone方法能够建立矩阵数据的完整副本。 见下面的例子:数组
// create a big 8Mb matrix Mat A(1000, 1000, CV_64F); // create another header for the same matrix; // this is an instant operation, regardless of the matrix size. Mat B = A; // create another header for the 3-rd row of A; no data is copied either Mat C = B.row(3); // now create a separate copy of the matrix Mat D = B.clone(); // copy the 5-th row of B to C, that is, copy the 5-th row of A // to the 3-rd row of A. B.row(5).copyTo(C); // now let A and D share the data; after that the modified version // of A is still referenced by B and C. A = D; // now make B an empty matrix (which references no memory buffers), // but the modified version of A will still be referenced by C, // despite that C is just a single row of the original A B.release(); // finally, make a full copy of C. As a result, the big modified // matrix will be deallocated, since it is not referenced by anyone C = C.clone();
输出数据的自动分配
*灰度图像通道数量为一
限制使用模板数据结构