Ask Your Question

Revision history [back]

May be I miss something in opencv. I didn't find a simple way to access data :

// 4 rows and 3 columns and 10 channels
vector<Mat> ch;
for (int c = 0; c< 10; c++)
{
    ch.push_back(Mat::zeros(4,3,CV_32FC1));
    for (int i=0;i<ch[c].rows;i++)
        for (int j=0;j<ch[c].cols;j++)
            ch[c].at<float>(i,j)=c*(i+j);
}

Mat w;
merge(ch,w);
//  w 4 rows and 3 columns and 10 channel
cout<<"Channels = "<<w.channels()<<"\n";
cout<<"w = "<<w<<"\n";
// I want row 1 column 2 and channel 3
cout<<"w((1,2) channels 3 = "<<w.ptr<float>(1)[2*w.channels()+3]<<endl;