Ask Your Question
0

looping for trainig data

asked 2013-07-10 10:27:33 -0500

Hi I have 80 testing and training samples to loop in my code. testData_1 to testdata_80

I had defined the path for each training and testing samples as char trainfilename[] = "\t\trainData_1.txt"; char testfilename[] = "t\testData_1.txt";

but now i have 80 of them so i have to loop them so that i could read it one by one.

please note that i cant concatenate all testing samples to one as each testdata1 is of dimension 5180 and each traindata_1 is of 20180

so i was planing to make a loOp like this instead of doing it manually one by one

            strcpy(testdataAll, "D:/data/");            

            strcat(testdataAll, testSet[ctrTestSet]);

            strcat(testdataAll, testfilename);

            for (int pos=0; pos<160; pos++) {

                if (testfilename[pos]=='_' && testfilename[pos+1]=='\0'){

                    strcat(testdataAll, numTrChar);

                    strcat(testdataAll, "_6");

                    break;

                }                   

            }

but i cant get it right? please suggest

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
0

answered 2013-07-10 17:31:35 -0500

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.

edit flag offensive delete link more

Question Tools

Stats

Asked: 2013-07-10 10:27:33 -0500

Seen: 55 times

Last updated: Jul 10 '13