Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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.

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);} {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); { 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.

click to hide/show revision 3
No.3 Revision

updated 2017-03-27 01:51:35 -0500

berak gravatar image

Can we use this method to read images for training using FaceRecognizer class?

here is the code

int train_ellen(vector<mat>& train_ellen(vector<Mat>& images)
{

{ Mat image=imread("ellen1.jpg", CV_LOAD_IMAGE_GRAYSCALE);

Mat image=imread("ellen1.jpg", CV_LOAD_IMAGE_GRAYSCALE);

if(image.empty) {images.push_back(image);

{images.push_back(image); labels.push_back(0); }
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.