(转)Mat, vectorpoint2f,Iplimage等等常见类型转换
在mfc c++ 以及opencv 編寫(xiě)程序當(dāng)中,很多常用的類型轉(zhuǎn)換,現(xiàn)在總結(jié)一下。(注意加相應(yīng)的頭文件,這里不羅嗦)
提綱:
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);數(shù)據(jù)類
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);轉(zhuǎn)載于:https://www.cnblogs.com/byteHuang/p/7478030.html
總結(jié)
以上是生活随笔為你收集整理的(转)Mat, vectorpoint2f,Iplimage等等常见类型转换的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: 字符串编码与转码
- 下一篇: Libevent源码分析-----连接监