opencv:创建矩阵或矩阵向量

use*_*002 -1 c++ opencv image-processing matrix

我有以下代码,这是我正在遵循的算法的一部分.如你所见,我需要为10个不同的乐队做一些计算.最终我需要从每个波段重新创建一个图像的矩阵,问题是我不知道如何在while循环上创建/保持10个不同的矩阵,然后在while循环后我可以构造图像一个接一个.如果您有任何想法请告诉我,谢谢

cv::Mat _reconstructionMatrix(height,width,CV_8UC1);
_reconsPointer = _reconstructionMatrix.ptr<uchar>(0);   

    while(_bandIteration<_bandsNumber){                     
if(_mainMatrix.isContinuous())
{
    nCols *= nRows;
    nRows = 1;
}
//for all the pixels 
for(int i = 0; i < nRows; i++)
{           
    p = _mainMatrix.ptr<uchar>(i);
    //in the images
    for (int  j = 0; j < nCols; j++)
    {               
        if(_pCounter<_totalImgNO){              
            ....
        }else{                                                      
            ...

            _reconsPointer[_resultFlag]=_summation; 
            _resultFlag++;

            ...             
        }
    }                   
}           

_bandIteration++;
}
Run Code Online (Sandbox Code Playgroud)

Han*_*rén 6

你的问题有点模糊.但是,如果您只是简单地询问,how to create/hold the 10 different matrix on the while loop?那么您可以正常使用STL向量.

#include<vector>
...   
std::vector<cv::Mat> listOfMatrices;
...       
cv::Mat M = SomehowGetMatrix();
listOfMatrices.push_back(M);
Run Code Online (Sandbox Code Playgroud)

如果这不是您想要的,那么请提供更多详细信息.