opencv 之Mat, vector<point2f>,Point3d Iplimage 常见类型转换
2018-03-18 19:25
591 查看
在mfc c++ 以及opencv 编写程序当中,很多常用的类型转换,现在总结一下。(注意加相应的头文件,这里不罗嗦)提纲:1. Mat ---> Iplimage2. Iplimage ---> CvvImage3. 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>> ---> Mat6. vector<Point2f> or vector<Point3f> ---> Mat 图像类1. Mat ---> Iplimage :直接赋值 [cpp] view plaincopyMat img;
Iplimage myImg = img;
2. Iplimage ---> CvvImage :用“Copyof ”[cpp] view plaincopyCvvImage cImg;
Iplimage myimg;
cImg.Copyof(myimg, -1);
数据类3. Mat ---> vector<Point2f> or vector<Point3f> :用“Mat_<Point2f>“ ,“Mat_<Point3f>”[cpp] view plaincopyMat m;
vector<Point3f> p;
p = Mat_<Point3f>(m);
4. vector<Point2f> or vector<Point3f> ---> vector<vector<Point2f>> or vector<vector<Point3f>> :用“pushback”[cpp] view plaincopyvector<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[cpp] view plaincopyvector<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)"[cpp] view plaincopyvector<Point3f> p;
Mat m = Mat(p);
转:http://blog.csdn.net/qq_18343569/article/details/48292861
Iplimage myImg = img;
2. Iplimage ---> CvvImage :用“Copyof ”[cpp] view plaincopyCvvImage cImg;
Iplimage myimg;
cImg.Copyof(myimg, -1);
数据类3. Mat ---> vector<Point2f> or vector<Point3f> :用“Mat_<Point2f>“ ,“Mat_<Point3f>”[cpp] view plaincopyMat m;
vector<Point3f> p;
p = Mat_<Point3f>(m);
4. vector<Point2f> or vector<Point3f> ---> vector<vector<Point2f>> or vector<vector<Point3f>> :用“pushback”[cpp] view plaincopyvector<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[cpp] view plaincopyvector<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)"[cpp] view plaincopyvector<Point3f> p;
Mat m = Mat(p);
转:http://blog.csdn.net/qq_18343569/article/details/48292861
相关文章推荐
- Mat, vector<point2f>,Iplimage等等常见类型转换
- Mat, vector<point2f>,Iplimage等等常见类型转换
- Mat, vector<point2f>,Iplimage等等常见类型转换
- (转)Mat, vector<point2f>,Iplimage等等常见类型转换
- Mat, vector<point2f>,Point3d Iplimage等等常见类型转换
- Mat, vector<point2f>,Iplimage等等常见类型转换
- Mat, vector<point2f>,Iplimage等等常见类型转换
- Mat, vector<point2f>,Iplimage等等常见类型转换
- Mat, vector<point2f>,Iplimage等等常见类型转换
- opencv中Mat与IplImage,CVMat类型之间转换
- OpenCV中Mat与IplImage和CvMat类型之间的相互转换
- OpenCV中Mat与IplImage和CvMat类型之间的相互转换
- OpenCV中Mat与IplImage和CvMat类型之间的相互转换
- 在opencv中,关于IplImage和Mat类型之间的转换
- 【OpenCV】opencv中Mat与IplImage,CVMat类型之间转换
- OpenCV中Mat与IplImage和CvMat类型之间的相互转换
- C++ string与vector<float>类型相互转换之stringstream
- Opencv2.X以上Mat类型与IplImage*的转换
- Opencv读取mat和cvMat元素&&Mat与IplImage和CvMat类型之间的相互转换
- OpenCV中Mat与IplImage和CvMat数据类型间的相互转换