Ask Your Question
0

How to retrieve a sequence of images from a folder, such that the images will represent a movement?

asked 2016-12-18 05:02:47 -0500

Nuz gravatar image

opencv c++

edit retag flag offensive close merge delete

Comments

Yes..in order

Nuz gravatar imageNuz ( 2016-12-18 05:13:21 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
0

answered 2016-12-18 05:12:35 -0500

berak gravatar image

updated 2016-12-18 11:17:42 -0500

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::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]);
}
edit flag offensive delete link more

Comments

Instead of pressing the next arrow for the images to appear in sequence..is it possible to make each one of the images to appear after 1 second for example, thus representing a movement?

Nuz gravatar imageNuz ( 2016-12-18 06:03:21 -0500 )edit

oh dear, ofc. see update

berak gravatar imageberak ( 2016-12-18 08:43:02 -0500 )edit

Thank you.

Nuz gravatar imageNuz ( 2016-12-18 09:00:24 -0500 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2016-12-18 05:02:47 -0500

Seen: 71 times

Last updated: Dec 18 '16