在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 :直接赋值

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等等常见类型转换的更多相关文章

  1. 图像处理---《Mat对象 与 IplImage对象》

    图像处理---<认识 Mat对象> Mat对象 与 IplImage对象 (1)Mat对象:OpenCV2.0之后引进的图像数据结构.自动分配内存.不存在内存泄漏的问题,是面向对象的数据结 ...

  2. Mat转化为IplImage类型的方法

    Mat image_mat; IplImage imgTmp = image_mat; IplImage *img = cvCloneImage(&imgTmp);

  3. 关于vector.size()的一些常见错误总结

    1. 问题引入 通过查看[https://www.cplusplus.com/reference/vector/vector/] 的vector.size()说明,即 member type defi ...

  4. STL_string.【转】C++中int、string等常见类型转换

    ZC:#include <sstream> ZC:貌似还有 istringstream 和 ostringstream ... https://www.cnblogs.com/gaobw/ ...

  5. C++中int、string等常见类型转换

    1.int型与string型的互相转换 最佳实践: int型转string型 void int2str(const int &int_temp,string &string_temp) ...

  6. c++ vector二维数组常见写法

    vector<vector <int> > array(3);//定义了行数为3列数不定的二维数组 array.size()//返回二维数组的行数 array[0].size( ...

  7. 【转载】java的常见类型转换

    //Int型数字转换成String int num1=123456; //方法1 String str1=num1+""; System.out.println(str1); // ...

  8. Dart常见类型转换 Int String Double

    int -> string age.toString() string -> int int.parse('100'); String -> double var onePointO ...

  9. opencv 学习入门篇

    unbuntu 安装:http://blog.csdn.net/cocoaqin/article/details/78163171 windows 安装:https://jingyan.baidu.c ...

随机推荐

  1. Realsense深度相机资料

    1.Realsense SDK 2.0 Ubuntu 16.04 安装指导网址 https://github.com/IntelRealSense/librealsense/blob/master/d ...

  2. dpdk中uio技术

    总结一下dpdk的uio技术 一:什么是uio技术 UIO(Userspace I/O)是运行在用户空间的I/O技术,Linux系统中一般的驱动设备都是运行在内核空间,而在用户空间用应用程序调用即可, ...

  3. boost::thread 库的使用

    转载自:http://blog.csdn.net/yockie/article/details/9181939 概要 通过实例介绍boost thread的使用方式,本文主要由线程启动.Interru ...

  4. Luogu 1514 [NOIP2010] 引水入城

    我就是过来开心一下……这道题从开坑以来已经堆积了大半年了……今天才发现广搜一直写挂…… 丢个线段覆盖的模板,设$f_{i}$表示覆盖区间[1, i]的最小代价,$g_{i, j}$表示覆盖区间[i, ...

  5. GPG入门 - 练习笔记

     GPG入门练习笔记  参考阮一峰的GPG入门教程http://www.ruanyifeng.com/blog/2013/07/gpg.html 1.加密     1)刘言机器: 用王老师公钥加密gp ...

  6. Altium designer14裁剪PCB的方法

    很多人都跟我反应说AD14不能定义板框大小,或者说是不知道怎么定义板框的大小, 确实AD14的操作和AD13或者是AD10的版本斗有一些差异, 其实对于熟悉AD的人来说自己玩两天,这些差异就不算什么了 ...

  7. c#操作word类,进行html和word文档的互相转换

    实例引用:http://www.7es.cn/Software_development/171.shtml using Microsoft.Office.Core;using Word = Micro ...

  8. k8s标签

    一.标签是什么 标签是k8s特色的管理方式,便于分类管理资源对象. 一个标签可以对应多个资源,一个资源也可以有多个标签,它们是多对多的关系. 一个资源拥有多个标签,可以实现不同维度的管理. 可以使用标 ...

  9. P2891 [USACO07OPEN]吃饭Dining 最大流

    \(\color{#0066ff}{ 题目描述 }\) 有F种食物和D种饮料,每种食物或饮料只能供一头牛享用,且每头牛只享用一种食物和一种饮料.现在有n头牛,每头牛都有自己喜欢的食物种类列表和饮料种类 ...

  10. BZOJ 3028: 食物

    \(\color{#0066ff}{ 题目描述 }\) 明明这次又要出去旅游了,和上次不同的是,他这次要去宇宙探险!我们暂且不讨论他有多么NC,他又幻想了他应 该带一些什么东西.理所当然的,你当然要帮 ...