(转)Mat, vector<point2f>,Iplimage等等常见类型转换
在mfc c++ 以及opencv 编写程序当中,很多常用的类型转换,现在总结一下。(注意加相应的头文件,这里不罗嗦)
提纲:
5. vector<vector<Point2f>> or vector<vector<Point3f>> ---> Mat
图像类
1. Mat ---> Iplimage :直接赋值
Mat img;
Iplimage myImg = img;
2. Iplimage ---> CvvImage :用“Copyof ”
CvvImage cImg;
Iplimage myimg;
cImg.Copyof(myimg, -1);
数据类
3. Mat ---> vector<Point2f> or vector<Point3f> :用“Mat_<Point2f>“ ,“Mat_<Point3f>”
Mat m;
vector<Point3f> p;
p = Mat_<Point3f>(m);
4. vector<Point2f> or vector<Point3f> ---> vector<vector<Point2f>> or vector<vector<Point3f>> :用“pushback”
vector<Point3f> p1,p2,p3;
vector<vector<Point3f>> pp;
pp.pushback(p1);
pp.pushback(p2);
pp.pushback(p3);
5. vector<vector<Point2f>> or vector<vector<Point3f>> ---> Mat

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

6. vector<Point2f> or vector<Point3f> ---> Mat :用“Mat(Point3f)"
vector<Point3f> p;
Mat m = Mat(p);
(转)Mat, vector<point2f>,Iplimage等等常见类型转换的更多相关文章
- 图像处理---《Mat对象 与 IplImage对象》
图像处理---<认识 Mat对象> Mat对象 与 IplImage对象 (1)Mat对象:OpenCV2.0之后引进的图像数据结构.自动分配内存.不存在内存泄漏的问题,是面向对象的数据结 ...
- Mat转化为IplImage类型的方法
Mat image_mat; IplImage imgTmp = image_mat; IplImage *img = cvCloneImage(&imgTmp);
- 关于vector.size()的一些常见错误总结
1. 问题引入 通过查看[https://www.cplusplus.com/reference/vector/vector/] 的vector.size()说明,即 member type defi ...
- STL_string.【转】C++中int、string等常见类型转换
ZC:#include <sstream> ZC:貌似还有 istringstream 和 ostringstream ... https://www.cnblogs.com/gaobw/ ...
- C++中int、string等常见类型转换
1.int型与string型的互相转换 最佳实践: int型转string型 void int2str(const int &int_temp,string &string_temp) ...
- c++ vector二维数组常见写法
vector<vector <int> > array(3);//定义了行数为3列数不定的二维数组 array.size()//返回二维数组的行数 array[0].size( ...
- 【转载】java的常见类型转换
//Int型数字转换成String int num1=123456; //方法1 String str1=num1+""; System.out.println(str1); // ...
- Dart常见类型转换 Int String Double
int -> string age.toString() string -> int int.parse('100'); String -> double var onePointO ...
- opencv 学习入门篇
unbuntu 安装:http://blog.csdn.net/cocoaqin/article/details/78163171 windows 安装:https://jingyan.baidu.c ...
随机推荐
- SSM项目连接远程Linux服务器的mysql 启动tomcat卡在了 Initializing Spring root WebApplicationContext
网上查了原因, linux下mysql访问速度缓慢并且ssh连接缓慢的原因 解决办法: 1.linux ssh连接慢 最近发现ssh连接的时候却很慢,ping的速度非常好,让人误以为是ssh连接不上. ...
- C++面向对象类的实例题目四
题目描述: 以面向对象的概念设计一个类,此类包含3个私有数据:unlead.lead(无铅汽油和有铅汽油)以及total(当天总收入,无铅汽油的价格是17元/升,有铅汽油的加个是16元/升),请以构造 ...
- SQl Server 与数据库的第一次相遇
数据库就是 数据库(Database)是按照数据结构来组织.存储和管理数据的仓库,简单说就是存储在硬盘上的文件. 市面上常见数据库有<关系数据库系统>: ORACLE(甲骨文).DB2.S ...
- Configuration File (php.ini) Path Loaded Configuration File 都有加载php.ini文件,有什么不同的地方?
Configuration File (php.ini) Path /usr/local/php7/etc 这个目录下面也有php.ini文件(如果在编译./configure -with- ...
- Posters TopCoder - 1684
传送门 分析 首先我们不难想到1e4^5的暴力枚举,但显然这是不行的,于是我们考虑对于每一张海报肯定有一种最优情况使得它至少有一条边要么靠着板子的边要么靠着之前的某一张海报的边,这样我们便可以将复杂度 ...
- linux ftp、sftp、telnet服务开通、更改Orale最大连接数
1 ftp服务开通 1.1 检测vsftpd是否安装及启动 先用service vsftpd status 来查看ftp是否开启.也可以使用ps -ef | grep ftp 来查看本地是否含有包含f ...
- 多线程学习-基础(六)分析wait()-notify()-notifyAll()
一.理解wait()-notify()-notifyAll()obj.wait()与obj.notify()必须要与synchronized(Obj)一起使用,也就是wait,notify是针对已经获 ...
- ASP.NET网页动态添加数据行
一看到这标题<ASP.NET网页动态添加数据行>,想起来似乎有点难实现.因为网页的周期性原因,往往在PostBack之后,状态难于有所保留.但Insus.NET又想实现这样的效果,用户点击 ...
- JSPatch在MAC下的使用
简单调研JSPatch的使用,之所以在MAC下是因为可以创建一个命令行的应用,简化无关代码.具体做法如下: 第一步,去https://github.com/bang590/JSPatch/tree/m ...
- GIT版本控制系统(二)
貌似第二条有点用,还木有都验证过,贴过来再说~ 转自: http://www.cnblogs.com/lhb25/p/10-useful-advanced-git-commands.html 1. 导 ...