Ask Your Question
2

Read from folder

asked 2016-03-24 00:38:28 -0600

Nbb gravatar image

Hello,

I am trying to read a sequence of files from a folder. I am using glob but the problem is that it is not reading 1, 2, 3, 4 etc. It is reading 1, 101, 102... 108, 11, 111, 112....

Can someone help me fix this please

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-03-24 01:07:27 -0600

berak gravatar image

if your files are really numbered consecutively (and if those are in fact images), you could try via VideoCapture, like:

VideoCapture cap("file%d.png"); // think printf()
while(1) {
      Mat im;
      if (! cap.read(im))
           break;
}

in the long run, if you want your files to be lexically ordered, you have to take care to get the names right, like file00001.png and file2016-03-24.jpg

edit flag offensive delete link more

Comments

Hello thanks ! I made sure the format of the numbers were in the form 0001 instead of 1

Nbb gravatar imageNbb ( 2016-03-26 04:29:08 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-24 00:38:28 -0600

Seen: 568 times

Last updated: Mar 24 '16