This is specifically for Windows using the command prompt. When doing image processing and classifcations you’ll find yourself with directories full of images. And in some cases if you choose to use a learner you’ll have to load each image in your postives and/or negatives directory.  So you can just list your image names in a file and just load that text file, and in OpenCV if you choose to use a HaarClassifier this is needed.


cd "C:\My Documents\Positive Test Set"
dir /B "*.jpg" > positives.txt

Explanation of the code above:

cd <directory with images>
cd – Change directories, you will want to be in the directory that you want to list the files from.
 
dir /B "*.jpg" > <outputfile>
dir – Displays all files in directory.
/B – Means bare format (no heading information or summary) We don’t care about size, date, time etc… we only want the filename.
“*.jpg” – In this example I only want jpg files.
> – This is a redirection operator ‘>’. Really what its saying is instead of printing the results in the command prompt window send it to a file.
 
The output files contents will look like this


20110507_002544_1024_0193.jpg
20110507_004120_1024_0193.jpg
20110507_005632_1024_0193.jpg
20110507_011120_1024_0193.jpg
20110507_012544_1024_0193.jpg
20110507_014232_1024_0193.jpg
20110507_015956_1024_0193.jpg
20110507_021456_1024_0193.jpg
20110507_022844_1024_0193.jpg
20110507_024144_1024_0193.jpg

 

Tags:

Leave a Reply