开发者

Reading several images from sub folders.. C++/opencv

I would like to know how to implement a code to read images in folders, for example; I have a folder with name "images" and this folder has sub folders which every sub folder contains many images. I want to read开发者_如何转开发 all these images by using c++/opencv in order to use these images to extract features from them all.


You should use a folder and file enumeration API. Some portable APIs include Boost Filesystem and STLSoft.
This is unrelated to OpenCV.


On Linux, you use the opendir, readdir and closedir functions. See http://pubs.opengroup.org/onlinepubs/007908799/xsh/readdir.html. You need to do this recursively to walk the directory tree.


The simplest way might be for you to use nftw. It will do all the directory traversal for you (with options to control how) and execute your callback function. There is a small code example on the man page.


You can also use filesystem of boost to iterate through folders for reading. Use back_iterator.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜