(转)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 ...
随机推荐
- Spring 已看 没用
注解 @Autwired 依赖注入 作用: 自动按照类型注入.当使用注解注入属性时,set方法可以省略.它只能注入其他bean类型.当有多个类型匹配时,使用要注入的对象变量名称作为bean的id,在 ...
- rest-framework组件 之 渲染器与版本
浏览目录 渲染器 版本 渲染器 规定页面显示的效果(无用,了解即可). 局部渲染 只返回json数据. 效果: 看另一种情况: 既返回json数据,又嵌套在html中.注意:容易出bug. 效果如下: ...
- Eclipse报错could not write metadata for '/remotesystemstempfiles'
1. windows-Preferences 中,在search中输入remote,取消选中reopen remote systems view to previous state'. 2. win ...
- Python中的切片操作
python中的切片操作功能十分强大,通常我们利用切片来进行提取信息,进行相关的操作,下面就是一些切片的列子. 列如我们从range函数1-100中取7的倍数,函数及结果如下所示: >>& ...
- vimrc配置-新建文件时自动生成文件头
vimrc配置-新建文件时自动生成文件头 auto add file header autocmd BufNewFile *.py 0r /home/zxkletters/.vim/vim_te ...
- c 数组作为返回值注意
static char* Test() { char buf[] ="aa"; printf("%s\n",buf); return buf; } int ma ...
- asp web.config文件里compilation的assemblies add的元素来自哪里
该程序集组合由版本.区域性和公钥标记组成. ASP.NET 首先在应用程序的专用 Bin 目录中搜索程序集 DLL,然后在系统程序集缓存中搜索程序集 DLL. add 元素添加要在动态资源编译期间使用 ...
- String s String s=null和String s="a"区别
原文链接:https://www.cnblogs.com/ipetergo/p/6826909.htmlString s;和String s=null;和String s="a"; ...
- 老男孩Day6作业:计算器
作业需求: 1.实现加减乘除及拓号优先级解析 2.用户输入 1 - 2 * ( (60-30 +(-40/5) * (9-2*5/3 + 7 /3*99/4*2998 +10 * 568/14 )) ...
- 状压DP 【洛谷P3694】 邦邦的大合唱站队
[洛谷P3694] 邦邦的大合唱站队 题目背景 BanG Dream!里的所有偶像乐队要一起大合唱,不过在排队上出了一些问题. 题目描述 N个偶像排成一列,他们来自M个不同的乐队.每个团队至少有一个偶 ...