Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

if i understood you right, you have a 2d Mat, where the 1st column contains "file numbers"

[ 1, 0, 14;
  3, 0, 10;
  4, 2, 15]

// extract column:
Mat col = m.col(0);
// read files:
vector<Mat> images;
for (int i=0; i<col.rows; i++)
{
    Mat im = imread(format("%d.jpg", i));
    if (im.empty()) .... BARK !
    images.push_back(im);
}

if i understood you right, you have a 2d Mat, where the 1st column contains "file numbers"

[ 1, 0, 14;
  3, 0, 10;
  4, 2, 15]

// extract column:
Mat col = m.col(0);
// read files:
vector<Mat> images;
for (int i=0; i<col.rows; i++)
{
    // assuming CV_8U for m.type() here !!
    Mat im = imread(format("%d.jpg", i));
col.at<uchar>(i)));
    if (im.empty()) .... BARK !
    images.push_back(im);
}

if i understood you right, you have a 2d Mat, where the 1st column contains "file numbers"

[ 1, 0, 14;
  3, 0, 10;
  4, 2, 15]

// extract column:
Mat col = m.col(0);
// read files:
vector<Mat> images;
for (int i=0; i<col.rows; i++)
{
    // assuming CV_8U for m.type() here !!
    String filename = format("%d.jpg", col.at<uchar>(i));
    Mat im = imread(format("%d.jpg", col.at<uchar>(i)));
imread(filename);
    if (im.empty()) .... BARK !
    images.push_back(im);
}