Ask Your Question

# Revision history [back]

First of all, take care of the path name under Windows:

trainfilename[] = "\t\trainData_1.txt"; // no good
trainfilename[] = "\\t\\trainData_1.txt"; // good!


Because backslashs have to be escape on C/C++.

Second, your question is more about algorithm than OpenCV, but, I think you have to solution:

1. create a text file with all your samples (list directories values and redirect output to a file). Parse this file with getline for example, and load each file like this.
2. use a scanf/printf pattern, like "trainData_%d.txt" and with sprintf create the filename to load. You just have to use a for loop with an index.

If you don't know these functions, Google it.