在mfc c++ 以及opencv 编写程序当中,很多常用的类型转换
2015-04-06 19:43
483 查看
在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 :直接赋值
2. Iplimage ---> CvvImage :用“Copyof ”
数据类
3. Mat ---> vector<Point2f> or vector<Point3f> :用“Mat_<Point2f>“ ,“Mat_<Point3f>”
4. vector<Point2f> or vector<Point3f> ---> vector<vector<Point2f>> or vector<vector<Point3f>> :用“pushback”
5. vector<vector<Point2f>> or vector<vector<Point3f>> ---> Mat
6. vector<Point2f> or vector<Point3f> ---> Mat :用“Mat(Point3f)"
提纲:
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);
相关文章推荐
- [C++ VC MFC] VC常用数据类型使用转换
- MFC/C++/C中字符类型CString, int, string, char*之间的转换
- 求VC6.0中用MFC编写的SURF算法匹配程序,可以用到opencv
- 用shell编写的简单密码加密程序,涉及到ASCII与字符的相互转换,以及命令结果输出到变量
- MFC/C++/C中字符类型CString, int, string, char*之间的转换
- C++常用数据类型转换详解
- MFC中常用数据类型转换
- CLR 与 C++的常用类型转换笔记
- MFC/C++/C中字符类型CString, int, string, char*之间的转换
- 用shell编写的简单密码加密程序,涉及到ASCII与字符的相互转换,以及命令结果输出到变量
- C++中常用类型转换
- MFC/C++/C中字符类型CString, int, string, char*之间的转换
- MFC/C++/C中字符类型CString, int, string, char*之间的转换
- 总结一下刚刚写的程序中的C++各种类型的转换string,QString,char*, BYTE等等
- 从易到难编写C++程序,(2)个人解答:把键盘输入的16,10,8进制数转换为2进制输出。
- CLR 与 C++的常用类型转换笔记
- 完成一程序演示字符数组、C风格字符串、std::string和MFC中的Cstring类型之间的相互转换
- C++常用的数据类型强制转换方法
- C++常用数据类型转换
- C#调用C++编写的DLL函数, 以及各种类型的参数传递