在mfc c++ 以及opencv 编写程序当中,很多常用的类型转换,现在总结一下。(注意加相应的头文件,这里不罗嗦)

提纲:

1. Mat ---> Iplimage

2. Iplimage  --->  CvvImage

3. Mat  ---> vector<Point2f> or vector<Point3f>

4. vector<Point2f> or vector<Point3f>  --->  vector<vector<Point2f>> or vector<vector<Point3f>>

5. vector<vector<Point2f>> or vector<vector<Point3f>>  ---> Mat

6. vector<Point2f> or vector<Point3f>  --->  Mat

图像类

1. Mat ---> Iplimage :直接赋值

  1. Mat img;
  2. Iplimage myImg = img;

2. Iplimage  --->  CvvImage :用“Copyof ”

  1. CvvImage cImg;
  2. Iplimage myimg;
  3. cImg.Copyof(myimg, -1);

数据类

3. Mat  ---> vector<Point2f> or vector<Point3f> :用“Mat_<Point2f>“ ,“Mat_<Point3f>”

  1. Mat m;
  2. vector<Point3f> p;
  3. p = Mat_<Point3f>(m);

4. vector<Point2f> or vector<Point3f>  --->  vector<vector<Point2f>> or vector<vector<Point3f>> :用“pushback”

  1. vector<Point3f> p1,p2,p3;
  2. vector<vector<Point3f>> pp;
  3. pp.pushback(p1);
  4. pp.pushback(p2);
  5. pp.pushback(p3);

5. vector<vector<Point2f>> or vector<vector<Point3f>>  ---> Mat

  1. vector<vector<Point3f>> p;
  2. Mat pm((int)p.size(), p[0].size(), CV_32FC3);
  3. for( int i = 0; i < (int)p.size(); i++ )
  4. {
  5. Mat r = pm.row(i).reshape(3, pm.cols);
  6. Mat pm1(p[i]);
  7. pm1.copyTo(r);
  8. }

6. vector<Point2f> or vector<Point3f>  --->  Mat :用“Mat(Point3f)"

  1. vector<Point3f> p;
  2. Mat m = Mat(p);

[转](https://blog.csdn.net/foreverhehe716/article/details/6749175)

Mat,Iplimage,vector,vector_vector_Point2f等类型之间的相互转换相关推荐

  1. JAVA常用类型之间的相互转换

    JAVA常用类型之间的相互转换 String与int String与float String与double hexString与byte数组 json与map JSONArray与List<'m ...

  2. 类型之间的相互转换php,php学习之数据类型之间的转换介绍

    复制代码 代码如下: /*数据类型之间相互转换 * 一种是强制转换 * setType(变量,类型); //int,integer,float,double等等. * 这个函数将原变量的类型改变,用v ...

  3. c++中几种常见的类型转换。int与string的转换,float与string的转换以及string和long类型之间的相互转换。to_string函数的实现和应用。...

    1.string转换为int a.采用标准库中atoi函数,对于float和龙类型也都有相应的标准库函数,比如浮点型atof(),long型atol(). 他的主要功能是将一个字符串转化为一个数字,在 ...

  4. java int和String类型之间的相互转换

    String --> int 第一种方法:int i = Integer.parseInt(s); 第二种方法:int i = Integer.valueOf(s).intValue(); 两种 ...

  5. 26.JavaScript对象和基础类型之间的转换、hint、Symbol.toPrimitive、toString、valueOf

    文章目录 对象-基础类型转换 写在前面 对象类型转换规则 对象类型转换的结果 Hint String Number Default 转换需要的三个对象方法 Symbol.toPrimitive() t ...

  6. opencv中Mat与IplImage,CVMat类型之间转换

    opencv中对图像的处理是最基本的操作,一般的图像类型为IplImage类型,但是当我们对图像进行处理的时候,多数都是对像素矩阵进行处理,所以这三个类型之间的转换会对我们的工作带来便利. Mat类型 ...

  7. CvMat与LIplmage之间的相互转换__cvConvert()

    cvConvert cvConvert函数用于图像和矩阵之间的相互转换 为什么要用cvConvert 把IplImage转为矩阵? 因为IplImage里的数据,你只能用uchar的形式存放,当你需要 ...

  8. C++ 字符串和数字之间的相互转换

    能完成字符串和数字转换的方法多种多样: 1.使用string自带函数 数字转字符串:to_string() 字符串转数字:stoi().stol().stof().stod()等等 例: int i ...

  9. UTF8与UniCode之间的相互转换

    UTF8与UniCode之间的相互转换 这里不对两种编码进行官方的解释,如有不懂的可以自行百度.这里只对相互转换进行讨论. UniCode UTF8 00000000 - 0000007F 0xxxx ...

最新文章

  1. 虚拟机win7装oracle,win7系统安装Oracle VM VirtualBox虚拟机的操作方法
  2. Ubuntu安装ftp服务器
  3. 【 MATLAB 】DFT性质讨论(一)线性、循环反转、共轭与实序列的对称性的MATLAB实现
  4. latex的资料ftp
  5. java和python混合编程_浅谈C++与Java混合编程
  6. Codeforces-712C-Memory and De-Evolution
  7. LeetCode之Power of Two
  8. 理科都要学大学计算机吗,女生不适合学理科专业?报考这些理科专业,一毕业就会遭到疯抢!...
  9. Hexo + github 打造个人博客
  10. python高手养成_不要总抱怨它慢了 突破性能瓶颈 找到Python序列筛选数据的最优解...
  11. 【Day 1】机器阅读理解——机器阅读理解简介
  12. 【C/C++】C++重复率最高、最经典面试题/笔试题(程序题篇)【持续更新】
  13. [工具] Sublime Text 使用指南
  14. 3分钟下载好网易云付费音乐
  15. linux系统双显示器怎么设置复制,Redhat 5.6 双显示器 xorg.conf 设置
  16. 请来围观:WPF开发的微信客户端!!!
  17. mysql 除号_MySql的运算符-阿里云开发者社区
  18. borders.GetItem()方法 获取斜线Border (VC在Excel中画斜线格)
  19. SpringBoot使用SpringDataJPA通过方法名查询
  20. java实现DSA签名、验签

热门文章

  1. Kotlin中var和val的区别
  2. (转)面试必备技能:JDK动态代理给Spring事务埋下的坑!
  3. jquery 实现Json节点的增删改查
  4. 玩转Spring Cloud之配置中心(config server config client)
  5. 读书笔记2013第13本:《怎样解题》
  6. [转][小结][三种方法]实现WPF不规则窗体
  7. 哈佛管理论丛:谁背上了令人讨厌的猴子
  8. usaco ★Longest Prefix 最长前缀
  9. vc 只有顶级窗口可以弹出窗口_如果你刚换了新电脑,这几个地方记得设置一下,电脑可以多用几年...
  10. 泰安服务器维护公司,神云 泰安服务器