在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. ROS探索总结(二)——ROS总体框架

    个人分类: ROS 所属专栏: ROS探索总结   一.  总体结构        根据ROS系统代码的维护者和分布来标示,主要有两大部分:      (1)main:核心部分,主要由Willow G ...

  2. cocos2d-js 热更新模块 使用AssetsManager

    原帖子地址:http://cn.cocos2d-x.org/tutorial/show?id=1186 在这个文章中原作者已经说的很清楚,我在这个其他改动一些适用我项目中需求 1.满足Web和Nati ...

  3. 什么是FastCGI, PHP-FPM

    CGI,FastCGI都是一套接口标准:是编程语言(比如php,python; python里面也有wsgi)与web服务器(比如Nginx)的通信标准(比如你跟老外交流,那么FastCGI就相当于是 ...

  4. 算法Sedgewick第四版-第1章基础-003一封装日期

    1. package ADT; import algorithms.util.StdOut; /**************************************************** ...

  5. python基本概念——字符串

    1.字符串 一个字符串用什么引号开头,就必须用什么引号结尾.两上三引号之间的一切都作为字符串的内容,对应的单引号与双引号却只能创建单行字符串. 2.转义符 \,行末的单独一个反斜杠表示字符串在下一行继 ...

  6. c# 省市区联动

    http://www.matrixkey.com.cn/blog/article.asp?id=427 建议楼主去这里看看:http://pagetalks.com/2010/03/22/jquery ...

  7. python3中模块初识

    python的模块使用方法 1.用于显示python的环境变量 import sys print(sys.path) 运行路径执行结果如下: ['F:\\codes', 'F:\\codes', 'C ...

  8. [C++11]shared_ptr循环引用导致内存泄露

    1 /* 2 * shared_ptr循环引用导致内存泄露 3 */ 4 5 struct A 6 { 7 shared_ptr<A> ptr; // 改为weak_ptr<A> ...

  9. 图像特征提取之Haar特征

    1.Haar-like特征 Haar-like特征最早是由Papageorgiou等应用于人脸表示,Viola和Jones在此基础上,使用3种类型4种形式的特征. Haar特征分为三类:边缘特征.线性 ...

  10. Educational Codeforces Round 61 (Rated for Div. 2)F(区间DP,思维,枚举)

    #include<bits/stdc++.h>typedef long long ll;const int inf=0x3f3f3f3f;using namespace std;char ...