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

asked 2017-03-26 10:52:16 -0600

Nihar Rao gravatar image

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

berak gravatar image

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.

edit retag flag offensive close merge delete

Comments

Please select all code and clic in 10101 button to format your code

LBerger gravatar imageLBerger ( 2017-03-26 12:17:20 -0600 )edit