Can we use this method to read images for training using FaceRecognizer class?
here is the code
int train_ellen(vector<Mat>& images)
{
Mat image=imread("ellen1.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if(image.empty)
{images.push_back(image);
labels.push_back(0);
}
else
return 0;
image=imread("ellen2.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if(image.data)
{
images.push_back(image);
labels.push_back(1);}
else
return 0;
image=imread("ellen3.jpg", CV_LOAD_IMAGE_GRAYSCALE);
if(image.data)
{images.push_back(image); labels.push_back(2);}
else
return 0;
for(int i=0; i < images.size(); i++)
{
resize(images[i],images[0],images[0].size(),1.0,1.0, INTER_NEAREST );
}
model->train(images, labels);
return 1;
}
all three images are in the project folder.
Please select all code and clic in 10101 button to format your code