在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. __call()和__callStatic()方法

    __call() 当对象访问不存在的方法时,__call()方法会被自动调用__callStatic() 当对象访问不存在的静态方法时,__callStatic()方法会被自动调用 这两个方法在PHP ...

  2. ROS Learning-002 beginner_Tutorials 如何添加ROS环境变量 和 如何更新ROS源代码

    ROS Indigo beginner_Tutorials 之 添加环境变量 和 更新ROS源代码的命令 我使用的虚拟机软件:VMware Workstation 11 使用的Ubuntu系统:Ubu ...

  3. 算法Sedgewick第四版-第1章基础-1.4 Analysis of Algorithms-004计算内存

    1. 2. 3.字符串

  4. 基于GStreamer编写Mp3播放器

    一.简介 作者系统为CentOS6,本文在此基础上对Mp3播放器进行开发,需要使用mp3解码库libmad和gstreamer0.10-plugins-ugly,详细步骤如下.   二.操作步骤 1) ...

  5. 树莓派研究笔记(6)-- Lakka模拟游戏机

    我发现lakka的支持的游戏平台特别多,包括国产的OrangePI,真是太棒了.我们可以用这个来打造一个全功能模拟器平台.(删除线部分为Orange PI 测试成功内容,但在树莓派上无需那些操作) 访 ...

  6. 选择设置好ext3日志模式

    Linux是一种开放的.因Internet而产生的操作系统.Internet的发展.以网络为中心的计算模式如电子商务被迅速接受和普及,都为 Linux提供了更巨大的机会,使之成为企业和部门级的首选平台 ...

  7. 《Effective Java》第9章 异常

    第58条:对可恢复的情况使用受检异常,对编程错误使用运行时异常 Java程序设计语言提供了三种可抛出结构(throwable) ;受检的异常(checked exception)运行时异常(run-t ...

  8. java 包装类的应用

    package integer; public class baozhuang { public static void main(String[] args) { System.out.printl ...

  9. Java泛型读书笔记 (一)

    Java泛型 在Java SE7和之后的版本中,在new一个泛型类实例的时候,可以不传入类型参数,因为Java编译器可以通过赋给的变量类型声明推断出来,如下代码: ArrayList<Strin ...

  10. Unobrusive Ajax使用

    mark一下:[ASP.NET MVC 小牛之路]14 - Unobtrusive Ajax篇文章,果断记下来,网址: http://www.cnblogs.com/willick/p/3418517 ...