初学opencv的点滴积累

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/chentianting/article/details/70789254

一、关于在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

三、单行赋值给Mat矩阵,即合并n个长度为m的一维向量,最后是n*m。

参考http://blog.csdn.net/yanzi1225627/article/details/7687310




猜你喜欢

转载自blog.csdn.net/chentianting/article/details/70789254