Opencv copies one matrix to the first column of another matrix

I have a vector of pointers that point to an image (size w = 96 h = 100 NoImg = 100) that I received from my camrea and framegrabber. az you see that i create their matrix and start reading the data one pixel at a time. the next step is to create a larger matrix (h = 9600 w = 100), which can contain all the pixel data of one image in the first column and the next image data in the second column, but the time that I reach up to 100 images. I was wondering if there is a sufficient way or a ready-made method in opencv that helps me copy all the image data into one column of another matrix directly? or do I need to read all the pixels one by one, like my code below and write them one by one inside the other? Edit I get the following code

cv::Mat _mainMatrix(_imageSize,_totalImgNO,CV_8UC1);    
//loop for creating a matrix of each image in the memory
for(counter=0;counter<_totalImgNO;counter++){
    unsigned char* _pointer=(unsigned char*)_imgPtrVector.at(counter);
    cv::Mat _matrixImage(cv::Size(width,height), CV_8UC1,_pointer , cv::Mat::AUTO_STEP);         
    channels=_matrixImage.channels();
    nRows=_matrixImage.rows * channels;
    nCols=_matrixImage.cols;
    if (_matrixImage.isContinuous())
    {
        nCols *= nRows;
        nRows = 1;
    }
    for(int i = 0; i < nRows; ++i)
    {
        p = _matrixImage.ptr<uchar>(i);
        for (int  j = 0; j < nCols; ++j)
        {
            if(iRow<_totalImgNO && jCol<_imageSize){                
                _mainMatrix.at<uchar>(iRow,jCol)=p[j];
                iRow++;
            }               
        }
    }
    jCol++;
    iRow=0; 
    _matrixImage.~Mat();            
}
+3
2

, , , reshape.

, :)

Opencv Reshape

+1

OpenCV - STL. , STL.

:

cv::Mat1b bigmat(9600, 100);
for (int i = 0; i < bigmat.cols; ++i) {
    cv::Mat1b column = bigmatrix.col(i);
    cv::Mat1b &source = *(images[i]);
    std::copy(source.begin(), source.end(), column.begin());
}
+2

All Articles