0

This code is supposed to take a few images and load them, trying 3 different methods in the code and none of them seem to work. The answer here Getting OpenCV Error "Image step is wrong" in Fisherfaces.train() method doesnt work for me because I dont have those libraries.

#include <opencv2/opencv.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <opencv/cvaux.h>
using namespace cv;

int main(int argc, char** argv)
{

    //The code segments commented (not mine) are taken from     http://docs.opencv.org/modules/contrib/doc/facerec/facerec_api.html

    // holds images and labels (not mine)
    cv::vector<cv::Mat> images;
    cv::vector<int> labels;


    //this doesnt assign anything to img
    Mat img = cv::imread("/Users/STUFF/Desktop/Projects/OpenCV_testing/person0/0.jpg", 0);

    //this also does nothing
    IplImage *img=cvLoadImage("Image_Name);
    Mat mat(img);


   // images for first person (not mine) except incresed pathing/
   //repeat for multiple people in future
   images.push_back(cv::imread("/snip", CV_LOAD_IMAGE_GRAYSCALE));
   labels.push_back(0);

   images.push_back(cv::imread("/snip", CV_LOAD_IMAGE_GRAYSCALE));
   labels.push_back(0);

   images.push_back(cv::imread("/snip", CV_LOAD_IMAGE_GRAYSCALE));
   labels.push_back(0);

   // Create a new Fisherfaces model and retain all available Fisherfaces,
   // this is the most common usage of this specific FaceRecognizer:
   //(not mine)
   Ptr<FaceRecognizer> model =  createFisherFaceRecognizer();

   // This is the common interface to train all of the available cv::FaceRecognizer
   // implementations:
   //(not mine)
   model->train(images, labels);

   model->save("/snip.xml");

    return 0;
}

imread isn't doing anything which makes the rest of the code useless. Im really new to openCV and dont really understand the documentation so maybe im implementing some stuff wrong. I would appreciate help with imread and how to read the opencv documentation.

Community
  • 1
  • 1
Sage
  • 13
  • 5

1 Answers1

0

not really an answer ( just since code in comments does not work .. )

but it's always a good idea to check when loading resources:

Mat img = imread(path,flags);
if ( img.empty() ) 
{   
    // either the path was wrong, or it could not decompress it
    cerr << "could not load " << path << endl;
    return -1;
}
berak
  • 39,159
  • 9
  • 91
  • 89