OpenCV笔记 1

Structure      Contains  Represents
CvPoint      int x, y  Point in image
CvPoint2D32f   float x, y  Points in R 2
CvPoint3D32f   float x, y, z  Points in R 3
CvSize       int width, height  Size of image
CvRect       int x, y, width, height  Portion of image
CvScalar      double val[4]  RGBA value

cvScalar() , takes one, two, three, or four arguments and assigns those arguments to the corresponding elements of val[] .  set四个值

cvRealScalar() ; it takes one argument, which it assigns to val[0] while setting the other entries to 0.            set第一个值,其余为0

cvScalarAll() , which takes a single argument but sets all four elements of val[] to that same argument.            全set成同一个值

For all intents andpurposes, an IplImage can be thought of as being derived from CvMat . Therefore, it is best to understand the (would-be) base class before attempting to understand the added complexities of the derived class. A third class, called CvArr , can be thought of as an abstract base class from which CvMat is itself derived. You will oft en see CvArr (or, more accurately, CvArr* ) in function prototypes. When it appears, it is acceptable to pass CvMat* or IplImage* to the routine.

32-bit floats ( CV_32FC1 ),

unsigned integer 8-bit triplets ( CV_8UC3 )

typedef struct CvMat {
    int type;
    int step;
    int* refcount;

    // for internal use only
    union {
        uchar* ptr;
        short* s;
        int*  i;
        float* fl;
        double* db;
    } data;
    union {
        int rows;
        int height;
     };
    union {
        int cols;
        int width;
     };
} CvMat;                        

cvCreateMatHeader() creates the CvMat structure without allocating memory for the data.
cvCreateData() handles the data allocation.

cvCreateMat()  =  cvCreateMatHeader() + cvCreateData() .

cvCloneMat(CvMat*) creates a new matrix from an existing one.*

cvReleaseMat(CvMat**)  release.

* cvCloneMat() and other OpenCV functions containing the word “clone” not only create a new header that
is identical to the input header, they also allocate a separate data area and copy the data from the source to
the new object.

* For the regular two-dimensional matrices discussed here, dimension zero (0) is always the “width” and dimension one (1) is always the height.

二维矩阵中,维度0通常是宽,维度1通常是高。

矩阵某个位置的元素:the location of any given point is given by the formula:

δ = ( row ) ⋅ N cols ⋅ N channels + ( col ) ⋅ N channels + ( channel)  通道

IplImage header structure

typedef struct _IplImage {
int nSize;
int ID;
int nChannels;
int alphaChannel;
int depth;
char colorModel[4];
char channelSeq[4];
int dataOrder;
int origin;
int align;
int width;
int height;
struct _IplROI* roi;
struct _IplImage* maskROI;
void* imageId;
struct _IplTileInfo* tileInfo;
int imageSize;
char* imageData;
int widthStep;
int BorderMode[4];
int BorderConst[4];
char* imageDataOrigin;
} IplImage;

Th e possible values for nChannels are 1, 2, 3, or 4.

origin : IPL_ORIGIN_TL or IPL_ORIGIN_BL (the origin of coordinates being located in either the upper-left or lower-left corners of the image, respectively.)

dataOrder: IPL_DATA_ORDER_PIXEL or IPL_DATA_ORDER_PLANE .(whether the data should be packed with multiple channels one aft er the other for each pixel (interleaved, the usual case), or rather all of the channels clustered into image planes with the planes placed one aft er another.

ROI:感兴趣的区域

COI:感兴趣的通道 channel of interest

时间: 2024-10-10 01:44:51

OpenCV笔记 1的相关文章

【OpenCV笔记】使用VS2012和OpenCV2.4.9搭建配置OpenCV开发环境

使用MS Visual C++来创建OpenCV工程,由于不同的VS版本在配置时有所差别,现特把配置过程总结下来,以方便自己和其他朋友使用. 1.软件准备 安装Visual Studio2012和OpenCV2.4.9 这里就不再对软件的安装和环境变量的设置进行说明了,其他类似的文章的设置都大抵相似,本文重点介绍一下VS2012环境的配置. 2.配置VS2012环境 (1)新建工程 你可以创建简单的控制台应用或者拥有图形用户界面的复杂应用,此处我们选择最简单常用的控制台应用. 理解解决方案(So

OpenCV笔记(十二)—自定义线性滤波器

在<OpenCV笔记(七)>中,写了四种线性滤波的方法:箱式滤波器.高斯滤波器.中值滤波器和双边滤波器. 在OpenCV中,我们可以使用filter2D函数自定义kernel进行线性滤波. void filter2D(InputArray src, OutputArray dst, int ddepth, InputArray kernel, Point anchor=Point(-1, -1), double delta=0, int borderType=BORDER_DEFAULT) 参

OpenCV笔记大集锦(转载)

整理了我所了解的有关OpenCV的学习笔记.原理分析.使用例程等相关的博文.排序不分先后,随机整理的.如果有好的资源,也欢迎介绍和分享. 1:OpenCV学习笔记 作者:CSDN数量:55篇博文网址:http://blog.csdn.NET/column/details/opencv-manual.html 2:部分OpenCV的函数解读和原理解读 作者:梦想腾飞数量:20篇博文网址:http://blog.csdn.Net/xidianzhimeng/article/category/1593

OpenCV笔记(十八)——使用霍夫变换检测圆圈

这些笔记的最初,我是以接近于源码分析的形式来梳理自己学习OpenCV的过程. 然而写下来,一是执行力,二是时间的问题,确实越写越马虎了.用我老师的话:观其大略了. 但是,暂时就这么写着吧. 在笔记<十七>中,我们简单地谈到了霍夫变换检测直线的原理,就是判断相邻像素点的值(x, y)对应的r-theta曲线是否能够相交,如果有足够多的相邻的像素点的曲线相交,我们就认为这些相邻的像素点构成一条直线. 圆圈亦然,只是把直线的方程替换成了圆的方程.除了极坐标的r,多了两个变量:Xcenter和Ycen

OpenCV基本架构[OpenCV 笔记0]

最近正在系统学习OpenCV,将不定期发布笔记,主要按照毛星云的<OpenCV3编程入门>的顺序学习,会参考官方教程和文档.学习工具是Xcode+CMake,会对书中一部分内容更正,并加入cmakelist的内容. 书中大部分内容来自OpenCV文档,其实比较推荐官方文档和教程 OpenCV2.4.13: http://docs.opencv.org/2.4/index.html OpenCV安装路径下的include文件夹包含opencv和opencv2两个文件夹.opencv文件夹包含Op

OpenCV笔记(十五)——使用Laplace算子进行图像的边缘检测

在笔记十四中,我们使用了Sobel算子对图像进行边缘检测,理论依据是像素变化最快的地方最有可能是边缘处,所以使用sobel算子对图像做微分,得到的结果图像当中灰度较大的区域,即为边缘处. 在这里,我们使用Laplace算子来做边缘检测,也是类似的道理,只不过换成了二阶微分,在一阶微分的极大值的地方,二阶微分为零.我们以二阶微分为零的区域作为边缘.当然了一阶微分极小值的地方,即图像变化很慢很慢的地方,二阶微分也可能为零.所以我们还需要进行额外的滤波. 在理论上是这样,但是在实现上,OpenCV使用

查找并绘制轮廓[OpenCV 笔记XX]

好久没有更新了,原谅自己放了个假最近又在赶进度,所以...更新的内容是很靠后的第八章,因为最近工作要用就先跳了,后面会更新笔记编号...加油加油! 在二值图像中寻找轮廓 void cv::findContours ( InputOutputArray image, OutputArrayOfArrays contours, OutputArray hierarchy, int mode, int method, Point offset = Point() ) image: 输入图像,需为8位单

OpenCV笔记1

所用头文件 #include <opencv2/opencv.hpp> #include <iostream> #include <fstream> 显示图片 void DrawImage() { string filepath = "/home/yang/Datasets/lfpw/testset/Path_Images.txt"; ifstream fin; fin.open(filepath.c_str()); //string类型转为字符串类

输出图像到文件 imwrite()[OpenCV 笔记7]

bool imwrite(const string& filename, InputArray img, const vector<int>& params=vector<int>()); filename 待写入的文件名.保存图像的格式由扩展名决定. img 一般为一个Mat类型的图像 params 特定格式保存的参数编码: JPEG:params表示0到100的图片质量(CV_IMWRITE_JPEG_QUALITY),默认值为95: PNG:params表示压

Opencv 笔记 opencv tutorial 2.1节 mat

前言:opencv中,mat类型非常基础和重要.以下是opencv tutorial 2.1章节的中英文整理. Mat 简介 IplImage c 结构 需要管理内存 mat是c++中的类class 自动内存分配 Mat  包括: header A pointer to the matrix containing the pixel values  (can take dimentionlity 根据存储方法) 头大小不变  矩阵大小变 复制数据的速度由矩阵大小决定 将图像传给函数是常见做法 图