Skip to content
Snippets Groups Projects
Commit f63a6c90 authored by Noah Eigenfeld's avatar Noah Eigenfeld
Browse files

Hard-coded to read the first two subdirectories of a myfaces directory and add...

Hard-coded to read the first two subdirectories of a myfaces directory and add any pictures to the FaceRecognizer
parent 8b16cc74
No related branches found
No related tags found
1 merge request!5Face detection
...@@ -58,13 +58,42 @@ int main() { ...@@ -58,13 +58,42 @@ int main() {
picture_width = frame.rows; picture_width = frame.rows;
picture_height = frame.cols; picture_height = frame.cols;
//Get stored images
vector<Mat> images;
vector<int> labels;
Mat load_image, load_image_grayscale;
string filename = "";
string directory = "./myfaces/";
string subdirectory = "";
for (int j = 0; j < 2; j++) {
subdirectory = to_string(j) + "/";
int i = 0;
while (true) {
filename = to_string(i);
string path = directory + subdirectory + filename + ".png";
cout << "path: " << path << endl;
load_image = imread(path, 1);
if(!load_image.data)
{
printf( " No image data \n " );
break;
}
load_image_grayscale = load_image.clone();
//TODO: The following line isn't working for some reason
cvtColor(load_image, load_image_grayscale, CV_BGR2GRAY);
images.push_back(load_image_grayscale);
labels.push_back(0);
i++;
}
}
//Convert to grayscale //Convert to grayscale
picture_grayscale = picture.clone(); picture_grayscale = picture.clone();
cvtColor(picture, picture_grayscale, CV_BGR2GRAY); cvtColor(picture, picture_grayscale, CV_BGR2GRAY);
// generate eigenface // generate eigenface
vector<Mat> images;
vector<int> labels;
labels.push_back(0); labels.push_back(0);
images.push_back(picture_grayscale); images.push_back(picture_grayscale);
...@@ -88,7 +117,7 @@ int main() { ...@@ -88,7 +117,7 @@ int main() {
break; break;
} else if (key == 115) { } else if (key == 115) {
string name; string name;
string directory = "./images/"; string directory = "./myfaces/";
cout << "Please select a name for the image." << endl; cout << "Please select a name for the image." << endl;
getline(cin, name); getline(cin, name);
directory.append(name); directory.append(name);
......
myfaces/0/0.png

1.25 MiB

myfaces/0/1.png

1.46 MiB

myfaces/0/2.png

1.28 MiB

myfaces/1/0.png

1.24 MiB

myfaces/1/1.png

1.23 MiB

0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment