Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

if your images are numbered, you can use

cv::VideoCapture cap("/path/to/files/%d.png");
while(cap.isOpened()) {
     Mat img;
    if (! cap.read(img)) break; // end of sequence
    // ... process img
}

then, if your images can be sorted lexically (aaa.png, aab.png), you can use:

vector<string> files; cv::glob( "/path/to/files/*.png", files); for (size_t i=0; i<files.size(); i++)="" {="" mat="" img="imread(files[i]);" }<="" p="">

if your images are numbered, numbered (001.png, 002.png,..), you can use

cv::VideoCapture cap("/path/to/files/%d.png");
while(cap.isOpened()) {
     Mat img;
    if (! cap.read(img)) break; // end of sequence
    // ... process img
}

then, if your images can be sorted lexically (aaa.png, aab.png), aab.png,..), you can also use:

vector<string>

vector<String> files;
cv::glob( "/path/to/files/*.png", files);
for (size_t i=0; i<files.size(); i++)="" {="" mat="" img="imread(files[i]);" }<="" p="">

i++) { Mat img = imread(files[i]); }

if your images are numbered (001.png, 002.png,..), you can use

cv::VideoCapture cap("/path/to/files/%d.png");
while(cap.isOpened()) {
     Mat img;
    if (! cap.read(img)) break; // end of sequence
    // ... process img
cv::imahow("img", img);
    if (cv::waitKey() > 0)
          break;
}

if your images can be sorted lexically (aaa.png, aab.png,..), you can also use:

vector<String> files;
cv::glob( "/path/to/files/*.png", files);
for (size_t i=0; i<files.size(); i++) {
    Mat img = imread(files[i]);
}

if your images are numbered (001.png, 002.png,..), you can use

cv::VideoCapture cap("/path/to/files/%d.png");
while(cap.isOpened()) {
    Mat img;
    if (! cap.read(img)) break; // end of sequence
    cv::imahow("img", img);
    if (cv::waitKey() (cv::waitKey(1000) > 0)
0 //1000 millis == 2 second
          break;
}

if your images can be sorted lexically (aaa.png, aab.png,..), you can also use:

vector<String> files;
cv::glob( "/path/to/files/*.png", files);
for (size_t i=0; i<files.size(); i++) {
    Mat img = imread(files[i]);
}

if your images are numbered (001.png, 002.png,..), you can use

cv::VideoCapture cap("/path/to/files/%d.png");
while(cap.isOpened()) {
    Mat img;
    if (! cap.read(img)) break; // end of sequence
    cv::imahow("img", img);
    if (cv::waitKey(1000) > 0 //1000 // 1000 millis == 2 1 second
          break;
}

if your images can be sorted lexically (aaa.png, aab.png,..), you can also use:

vector<String> files;
cv::glob( "/path/to/files/*.png", files);
for (size_t i=0; i<files.size(); i++) {
    Mat img = imread(files[i]);
}

if your images are numbered (001.png, 002.png,..), you can use

cv::VideoCapture cap("/path/to/files/%d.png");
while(cap.isOpened()) {
    Mat img;
    if (! cap.read(img))  break; // end of sequence
    cv::imahow("img", img);
    if (cv::waitKey(1000) > 0 0) // 1000 millis == 1 second
         break;
}

if your images can be sorted lexically (aaa.png, aab.png,..), you can also use:

vector<String> files;
cv::glob( "/path/to/files/*.png", files);
for (size_t i=0; i<files.size(); i++) {
    Mat img = imread(files[i]);
}

if your images are numbered (001.png, 002.png,..), you can use

cv::VideoCapture cap("/path/to/files/%d.png");
while(cap.isOpened()) {
    Mat img;
    if (! cap.read(img)) 
        break; // end of sequence
    cv::imahow("img", cv::imshow("img", img);
    if (cv::waitKey(1000) > 0) // 1000 millis == 1 second
        break;
}

if your images can be sorted lexically (aaa.png, aab.png,..), you can also use:

vector<String> files;
cv::glob( "/path/to/files/*.png", files);
for (size_t i=0; i<files.size(); i++) {
    Mat img = imread(files[i]);
}