@@ -106,14 +106,14 @@ void FR_lfwImp::loadDataset(const string &path)
106
106
ifstream infile ((path + " pairs.txt" ).c_str ());
107
107
string line;
108
108
getline (infile, line); // should be 10 300
109
+ CV_Assert (line==" 10\t 300" );
109
110
unsigned int num = 0 ;
110
111
while (getline (infile, line))
111
112
{
112
113
if (0 == (num % 600 ))
113
114
{
114
115
train.push_back (vector< Ptr<Object> >());
115
116
test.push_back (vector< Ptr<Object> >());
116
- validation.push_back (vector< Ptr<Object> >());
117
117
}
118
118
119
119
vector<string> elems;
@@ -143,10 +143,12 @@ void FR_lfwImp::loadDataset(const string &path)
143
143
144
144
num++;
145
145
}
146
+ infile.close ();
146
147
147
148
// dev train loading to train[0]
148
149
ifstream infile2 ((path + " pairsDevTrain.txt" ).c_str ());
149
150
getline (infile2, line); // should 1100
151
+ CV_Assert (line==" 1100" );
150
152
while (getline (infile2, line))
151
153
{
152
154
vector<string> elems;
@@ -174,6 +176,41 @@ void FR_lfwImp::loadDataset(const string &path)
174
176
175
177
train[0 ].push_back (curr);
176
178
}
179
+ infile2.close ();
180
+
181
+ // dev train loading to validation[0]
182
+ ifstream infile3 ((path + " pairsDevTest.txt" ).c_str ());
183
+ getline (infile3, line); // should 500
184
+ CV_Assert (line==" 500" );
185
+ validation.push_back (vector< Ptr<Object> >());
186
+ while (getline (infile3, line))
187
+ {
188
+ vector<string> elems;
189
+ split (line, elems, ' \t ' );
190
+
191
+ Ptr<FR_lfwObj> curr (new FR_lfwObj);
192
+ string &person1 = elems[0 ];
193
+ unsigned int imageNumber1 = atoi (elems[1 ].c_str ())-1 ;
194
+ curr->image1 = person1 + " /" + faces[person1][imageNumber1];
195
+
196
+ string person2;
197
+ unsigned int imageNumber2;
198
+ if (3 == elems.size ())
199
+ {
200
+ person2 = elems[0 ];
201
+ imageNumber2 = atoi (elems[2 ].c_str ())-1 ;
202
+ curr->same = true ;
203
+ } else
204
+ {
205
+ person2 = elems[2 ];
206
+ imageNumber2 = atoi (elems[3 ].c_str ())-1 ;
207
+ curr->same = false ;
208
+ }
209
+ curr->image2 = person2 + " /" + faces[person2][imageNumber2];
210
+
211
+ validation[0 ].push_back (curr);
212
+ }
213
+ infile3.close ();
177
214
}
178
215
179
216
Ptr<FR_lfw> FR_lfw::create ()
0 commit comments