为了细致掌握程明明CVPR 2014 oral文章:BING: Binarized Normed Gradients for Objectness Estimation at 300fps的代码,的好好学习opencv库啊,从基础走起。

(1)CV_Assert函数作用:

CV_Assert()若括号里的表达式值为false。则返回一个错误信息。

(2)Mat使用方法

1、使用准备:

 using  namespace  cv;



2、Mat的声明



Mat m=Mat(rows, cols, type);

Mat m=Mat(Size(width,height), type);

Mat A=Mat(3,4,CV_32FC1);

Mat B=Mat(4,3,CV_32FC1);



3、Mat赋值



vector<Point3f>v;//suppose it is already full

Mat m1=Mat(v,true);//boolean value true is necessary in order to copy data from v to m1

CvMat *p1;

Mat m2=Mat(p1);



4、Mat之间运算



MatC=2*A*B;



Mat C=C.inv();//Now C is its own inverse matrix



Mat D=A.t();//D is the transposed matrix of A



Mat a=Mat(4,1, CV_32FC3);//a is 4x1, 3 channels



Mat b=a.reshape(1);//b is 4x3, 1 channel





5、单通道Mat元素读写



Mat a=Mat(4,3, CV_32FC1);

floatelem_a=a.at<float>(i,j);//access element aij, with i from 0 to rows-1 and j from 0 to cols-1

Point p=Point(x,y);

floatelem_a=a.at<float>(p);//Warning: y ranges from 0 to rows-1 and x from 0 to cols-1





6、多通道Mat元素读写



template<typename _Tp> _Tp& at(int y,int x);              // cxcore.hpp (868)

template<typename _Tp>const _Tp& at(int y,int x)const;    // cxcore.hpp (870)

template<typename _Tp> _Tp& at(Point pt); // cxcore.hpp (869)

template<typename _Tp>const _Tp& at(Point pt)const;       // cxcore.hpp (871)

// defineded in cxmat.hpp (454-468)

typedefVec<float,2>Vec2f;// cxcore.hpp (254)



// we can access the element like this :

Mat m(Size(3,3), CV_32FC2 );

Vec2f& elem = m.at<Vec2f>( row , col );// or m.at<Vec2f>( Point(col,row) );

elem[0]=1212.0f;

elem[1]=326.0f;

float c1 = m.at<Vec2f>( row , col )[0];// or m.at<Vec2f>( Point(col,row) );

float c2 = m.at<Vec2f>( row , col )[1];

m.at<Vec2f>( row, col )[0]=1986.0f;

m.at<Vec2f>( row, col )[1]=326.0f;





7.选取Mat上指定区域方法





Mat src; Rect rect;

Mat dst = src(rect); 或者Mat dst(src,rect);



注意:cv::Mat A;



A.row(i) = A.row(j); // 错误

A.row(i) = A.row(j) + 0; // 正确

opencv基础笔记(1)的更多相关文章

  1. OpenCV 基础笔记

    本文大部分内容来源于入门者的Python快速教程 - 番外篇之Python-OpenCV 本篇将介绍和深度学习数据处理阶段最相关的基础使用,并完成4个有趣实用的小例子: 延时摄影小程序 视频中截屏采样 ...

  2. opencv学习笔记(三)基本数据类型

    opencv学习笔记(三)基本数据类型 类:DataType 将C++数据类型转换为对应的opencv数据类型 OpenCV原始数据类型的特征模版.OpenCV的原始数据类型包括unsigned ch ...

  3. paper 93:OpenCV学习笔记大集锦

    整理了我所了解的有关OpenCV的学习笔记.原理分析.使用例程等相关的博文.排序不分先后,随机整理的.如果有好的资源,也欢迎介绍和分享. 1:OpenCV学习笔记 作者:CSDN数量:55篇博文网址: ...

  4. (转) OpenCV学习笔记大集锦 与 图像视觉博客资源2之MIT斯坦福CMU

          首页 视界智尚 算法技术 每日技术 来打我呀 注册     OpenCV学习笔记大集锦 整理了我所了解的有关OpenCV的学习笔记.原理分析.使用例程等相关的博文.排序不分先后,随机整理的 ...

  5. OpenCV学习笔记(27)KAZE 算法原理与源码分析(一)非线性扩散滤波

    http://blog.csdn.net/chenyusiyuan/article/details/8710462 OpenCV学习笔记(27)KAZE 算法原理与源码分析(一)非线性扩散滤波 201 ...

  6. OpenCV 学习笔记 02 使用opencv处理图像

    1 不同色彩空间的转换 opencv 中有数百种关于不同色彩空间的转换方法,但常用的有三种色彩空间:灰度.BRG.HSV(Hue-Saturation-Value) 灰度 - 灰度色彩空间是通过去除彩 ...

  7. opencv 学习笔记集锦

    整理了我所了解的有关OpenCV的学习笔记.原理分析.使用例程等相关的博文.排序不分先后,随机整理的.如果有好的资源,也欢迎介绍和分享. 1:OpenCV学习笔记 作者:CSDN数量:55篇博文网址: ...

  8. OpenCV学习笔记 笔记汇总

    转载来源:https://www.cnblogs.com/tonyc/p/6407318.html 今后开始学习OpenCV   1:OpenCV学习笔记 作者:CSDN数量:55篇博文网址:http ...

  9. OpenCV开发笔记(六十五):红胖子8分钟带你深入了解ORB特征点(图文并茂+浅显易懂+程序源码)

    若该文为原创文章,未经允许不得转载原博主博客地址:https://blog.csdn.net/qq21497936原博主博客导航:https://blog.csdn.net/qq21497936/ar ...

随机推荐

  1. CAD参数绘制角度标注(com接口)

    主要用到函数说明: _DMxDrawX::DrawDimAngular 绘制一个角度标注.详细说明如下: 参数 说明 DOUBLE dAngleVertexX 角度标注的顶点的X值 DOUBLE dA ...

  2. vue-router 基本使用(vue工程化)

    (1)概念: 路由,其实就是指向的意思,当我点击页面上的home按钮时,页面中就要显示home的内容,如果点击页面上的about 按钮,页面中就要显示about 的内容.Home按钮  => h ...

  3. clipboard 实现复制

    html <textarea id="bar" cols="62" rows="5" autocomplete="off&q ...

  4. c++基础_特殊回文数

    #include <iostream> using namespace std; int main(){ int n; cin>>n; ;i<;i++){ int tem ...

  5. ubuntu 安装python 编程环境

    1. 安装python sudo add-apt-repository ppa:fkrull/deadsnakessudo apt-get updatesudo apt-get install pyt ...

  6. 修改 root密码

    sudo su #切换到root账户sudo passwd root  #输入密码

  7. ORM之单表增删改查

    ORM之单表增删改查 在函数前,先导入要操作的数据库表模块,model from model所在的路径文件夹 import model   在views文件中,加的路径: #就一个app01功能的文件 ...

  8. stark组件之注册与路由系统(三)

    在文章stark组件前戏中已经提到过,django的注册功能是通过AdminSite的单例进行组册的,所以在这里也可以进行单例模式. class AdminSite(object): def __in ...

  9. loadrunner 添加负载机

    1.打开Controller 2. 添加负载 3. 配置参数 4.完成

  10. Cropping multiple images the same way

    The tools we’ll be using are =GIMP= and =mogrify= (from the ImageMagick suite), so make sure that yo ...