New to openframeworks here. I’m reading the documentation, and I see I can create an array of images but can’t seem to figure out if I can do that we directories or folders.
I have a series of photos all in different folders. When I tap or click, I would like to jump to the next folder to then access all images in the new folder and so own. So far I can load the directory DIR.listDir(“images/img/People”) and then iterate through it and put all images in an array.
I just don’t know how to do it for multiple folders.
I would really appreciate any help with this.
you can do that with directories, it all depends on how you want to use them. Something I’ve done before is adding all of the paths to images into a vector, then you can load them whenever you want to an ofImage, or you can load all the images straight into a vector, all depends on your use case, ie if you are going to have 10 images and use them often, then for simplicity sake you could load them straight away, but if you were going to have 1000 and only see one at a time then you would save the paths and then load up the one you wanted to use.
if you were going to load up only a few images then you would use a for loop like here and then instead of “dir.getPath(i)” you would do:
as long as you have a
that would then work for loading all of the images in that directory to the vector, then you could just repeat the process adding to the
vector<ofImage>images; in another directory
Thank you so much Miles, I will try your suggestion and report back!
also note that you can have a vector of vector of images:
vector < vector < ofImage > > images;
(an array of arrays, ie 2d array)
where each folder (which contains images) is loaded into an a vector (growable array) and all the directories are stored in the 2d array.
then if you had 5 folders and you wanted to access the 3rd image from the 4th folder, you would do:
(note that the numbers are 1 less since we count arrays from 0)
oh yeah, nice one Zach!
yeah it’s a shame that 0th isn’t in normal vocabulary