0

my problem is the following: I have developed a superpixel segmentation algorithm and i want to test how the superpixel behave in stereo imagery. For this i use the Middlebury Stereo Dataset 2006 (http://vision.middlebury.edu/stereo/data/scenes2006/), right now i load one pair of images segment them and then compute my metrics (basically a fancy IOU) on it. This now works properly and now i want to extend it that it not only uses one pair of stereo images but the whole dataset.

Programming language is C++.

Here lies the problem: How would i efficiently load all images? Because the pairs are all in independent folders (for the structure of the folder see below).

My idea would be to have a list of paths to the folders and then import all images from one folder, compute everything and then load the next folder. How would i do that?

Structure of each stereo pair is like that:

Folder with the name of the item (like cat, wood, baby, ...)
    disp1.png
    disp5.png
    view1.png
    view5.png

Right now at the start of the my program i load images like that:

String pathImageLeft = "/Users/Stereo/Left/view1.png";
String pathImageRight = "/Users/Stereo/Right/view5.png";
String pathDisparityLeft = "/Users/Stereo/DisparityMap/disp1.png";
String pathDisparityRight = "/Users/Stereo/DisparityMap/disp5.png";

Thanks for your ideas.

Community
  • 1
  • 1
KalvinB
  • 305
  • 1
  • 3
  • 11
  • Is your question about accessing directories or about accessing the URL? After having written an answer I'm not quite sure anymore. (So, consider it as pre-liminary.) – Scheff's Cat Sep 13 '18 at 11:17
  • It's about accessing them as directories, i have downloaded them all manually, and thanks for your answer! – KalvinB Sep 13 '18 at 14:29

1 Answers1

1

If I understood OP's question right, it can be reduced to

How can I access directories?

From C++17, there is a Filesystem libary available which provides access to directories in a portable way.

Namely, it provides a std::filesystem::directory_entry which

Represents a directory entry. The object stores a path as a member and may also store additional file attributes (hard link count, status, symlink status file size, and last write time) during directory iteration.

and a std::filesystem::directory_iterator

that iterates over the directory_entry elements of a directory (but does not visit the subdirectories). The iteration order is unspecified, except that each directory entry is visited only once. The special pathnames dot and dot-dot are skipped.

The provided links provide sample codes.

Before C++17, you either have to use boost::filesystem (which is actually an anchestor of the std::filesystem) or you have to use the OS specific functions which are usually of limited portability.

Concerning the latter, there are already existing questions in SO:

to list only a few.

Scheff's Cat
  • 19,528
  • 6
  • 28
  • 56