48 #include <boost/format.hpp> 51 using namespace shark;
56 const char *facedirectory =
"Cambridge_FaceDB";
59 cout <<
"Read images ... " << flush;
63 cerr <<
"[PCATutorial] could not open face database directory\n\nThis file is part of the \"Principal Component Analysis\" tutorial.\nThe tutorial requires that you download the Cambridge Face Database\nfrom http://www.cl.cam.ac.uk/research/dtg/attarchive/facedatabase.html\nand adjust the facedirectory path in the source code to the directory\ncontaining the faces in PGM format." << endl;
66 cout <<
"done." << endl;
69 unsigned x = imagesInfo.
element(0).x;
70 unsigned y = imagesInfo.
element(0).y;
72 cout <<
"Eigenvalue decomposition ... " << flush;
74 cout <<
"done." << endl;
76 cout <<
"Writing mean face and eigenvalues... " << flush;
77 ofstream ofs(
"facesEigenvalues.csv");
78 for(
unsigned i=0; i<l; i++)
81 cout <<
"done. " << endl;
83 cout <<
"Encoding ... " << flush;
88 cout <<
"done. " << endl;
90 unsigned sampleImage = 0;
91 cout <<
"Reconstructing face " << sampleImage <<
" ... " << flush;
92 boost::format fmterTrue(
"face%d.pgm");
93 exportPGM((fmterTrue % sampleImage).str().c_str(), images.
element(sampleImage), x, y);
96 boost::format fmterRec(
"facesReconstruction%d-%d.pgm");
97 exportPGM((fmterRec % sampleImage % m).str().c_str(), dec(encodedImages.
element(sampleImage)), x, y);
98 cout <<
"done." << endl;