From 201a5b7daa3e9f4794a5b6126b2fa46c2e94255b Mon Sep 17 00:00:00 2001 From: Hyunjun Kim Date: Tue, 15 Sep 2015 17:59:46 +0900 Subject: [PATCH] added dev_test --- modules/datasets/src/fr_lfw.cpp | 39 ++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) diff --git a/modules/datasets/src/fr_lfw.cpp b/modules/datasets/src/fr_lfw.cpp index 3b768d9dd..217e71114 100644 --- a/modules/datasets/src/fr_lfw.cpp +++ b/modules/datasets/src/fr_lfw.cpp @@ -106,6 +106,7 @@ void FR_lfwImp::loadDataset(const string &path) ifstream infile((path + "pairs.txt").c_str()); string line; getline(infile, line); // should be 10 300 + CV_Assert(line=="10\t300"); unsigned int num = 0; while (getline(infile, line)) { @@ -113,7 +114,6 @@ void FR_lfwImp::loadDataset(const string &path) { train.push_back(vector< Ptr >()); test.push_back(vector< Ptr >()); - validation.push_back(vector< Ptr >()); } vector elems; @@ -143,10 +143,12 @@ void FR_lfwImp::loadDataset(const string &path) num++; } + infile.close(); // dev train loading to train[0] ifstream infile2((path + "pairsDevTrain.txt").c_str()); getline(infile2, line); // should 1100 + CV_Assert(line=="1100"); while (getline(infile2, line)) { vector elems; @@ -174,6 +176,41 @@ void FR_lfwImp::loadDataset(const string &path) train[0].push_back(curr); } + infile2.close(); + + // dev train loading to validation[0] + ifstream infile3((path + "pairsDevTest.txt").c_str()); + getline(infile3, line); // should 500 + CV_Assert(line=="500"); + validation.push_back(vector< Ptr >()); + while (getline(infile3, line)) + { + vector elems; + split(line, elems, '\t'); + + Ptr curr(new FR_lfwObj); + string &person1 = elems[0]; + unsigned int imageNumber1 = atoi(elems[1].c_str())-1; + curr->image1 = person1 + "/" + faces[person1][imageNumber1]; + + string person2; + unsigned int imageNumber2; + if (3 == elems.size()) + { + person2 = elems[0]; + imageNumber2 = atoi(elems[2].c_str())-1; + curr->same = true; + } else + { + person2 = elems[2]; + imageNumber2 = atoi(elems[3].c_str())-1; + curr->same = false; + } + curr->image2 = person2 + "/" + faces[person2][imageNumber2]; + + validation[0].push_back(curr); + } + infile3.close(); } Ptr FR_lfw::create()