本文共 966 字,大约阅读时间需要 3 分钟。
一、关于在CvMat 、Mat、IplImage之间的转换,参考此链接:
1. http://www.cnblogs.com/Key-Ky/p/4150531.html
2. http://blog.sina.com.cn/s/blog_7462bf390101c88a.html
第二个链接中第二个办法使用会报错,正确方式是:
(此为Mat转IplImage*)
Mat src;
IplImage srcImg =IplImage(src); IplImage* gray = cvCreateImage(cvGetSize(&srcImg), IPL_DEPTH_8U, 1);
二、动态格式化字符串
如果是 basic_string型,使用ostringstream,声明#include <sstream>
vector<std::vector<string> > m_fileNames;
m_fileNames.resize(3);
for (int i = 0; i < 3; ++i) { m_fileNames[i].resize(3); }
for (int i = 0; i < 3; ++i) {
for (int j = 0; j < 3; ++j) { std::string strFilePath = "/home/ctt/Project/Qt/face_lbp_ctt/face_lbp_ctt/Faces/s"; ostringstream stri; //string 格式化字符串 stri.str(""); stri << strFilePath << i+1 << "/" << j+1 << ".BMP"; strFilePath=stri.str(); // cout<<strFilePath<<endl; m_fileNames[i][j] = strFilePath; } }
http://blog.csdn.net/James506/article/details/1548935