Ask Your Question

Shoule101's profile - activity

2019-01-08 04:31:51 -0600 received badge  Notable Question (source)
2017-09-30 11:52:22 -0600 received badge  Popular Question (source)
2013-02-22 11:13:35 -0600 commented question facerec_demo model->predict exception thrown

Thanks, for your help @berak

2013-02-22 11:13:17 -0600 commented question facerec_demo model->predict exception thrown

Ive figured it out. Turns out I need to check my spelling better aha.

2013-02-22 10:07:02 -0600 commented answer Cascade Classifier example not working

Ive placed them in the directory and still it loads not load.

2013-02-22 10:05:57 -0600 commented question facerec_demo model->predict exception thrown

Ok now Ive figured out that the Cascade Classifier is not loading the xml file. and Ive placed it in the directory of the project and tried giving it the full path. Nothing is working. Please help

2013-02-22 09:52:53 -0600 commented question Visual Studio 2012 and OpenCV 2.4.4

Ive successfully used the prebuilt libraries with VS 2012

2013-02-22 09:41:17 -0600 received badge  Editor (source)
2013-02-22 09:37:16 -0600 commented question facerec_demo model->predict exception thrown

Hello again, Ive come back to this and now there is a different problem similar to the one Ive had before with the haarcascade face recognizer. When the code gets to the line of trying to detect the faces. haar_cascade.detectMultiScale(gray, faces); it finds nothing and the for loop doesnt execute. because the faces vector is empty. Ive made sure the file is loaded as well. There is an update showing my code in my question.

2013-02-22 09:32:14 -0600 commented answer Cascade Classifier example not working

Hi, I've made sure that the xml files are in the right place. Ive tried using the full path. Placing them in the directory of the project but nothing works.

2013-02-20 11:41:07 -0600 asked a question facerec_demo model->predict exception thrown

Hello, I am trying to use the facerec_demo.cpp file to start off with face recognition using a video feed. This demo does extactly that.

So I can get it to compile properly inputting all the command arguments and it runs except when it reaches the predict function of the code.

int prediction = model->predict(face_resized);

I know its throwing the exception here because I inset a breakpoint at this location the exception happens when this line executes.

Does any one have any ideas as to why this may be happening?

UPDATE: CODE

#include "opencv2/core/core.hpp"
#include "opencv2/contrib/contrib.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include "opencv2/objdetect/objdetect.hpp"

#include <iostream>
#include <fstream>
#include <sstream>

using namespace cv;
using namespace std;

static void read_csv(const string& filename, vector<Mat>& images, vector<int>& labels, char separator = ';') {
    std::ifstream file(filename.c_str(), ifstream::in);
    if (!file) {
        string error_message = "No valid input file was given, please check the given filename.";
        CV_Error(CV_StsBadArg, error_message);
    }
    string line, path, classlabel;
    while (getline(file, line)) {
        stringstream liness(line);
        getline(liness, path, separator);
        getline(liness, classlabel);
        if(!path.empty() && !classlabel.empty()) {
            images.push_back(imread(path, 0));
            labels.push_back(atoi(classlabel.c_str()));
        }
    }
}

int main(int argc, const char *argv[]) {
    // Check for valid command line arguments, print usage
    // if no arguments were given.
    if (argc != 2) {
        cout << "usage: " << argv[0] << " </path/to/haar_cascade> </path/to/csv.ext> </path/to/device id>" << endl;
     //   cout << "\t </path/to/haar_cascade> -- Path to the Haar Cascade for face detection." << endl;
        cout << "\t </path/to/csv.ext> -- Path to the CSV file with the face database." << endl;
      //  cout << "\t <device id> -- The webcam device id to grab frames from." << endl;
        system("pause");
        exit(1);
    }
    // Get the path to your CSV:
    //string fn_haar = string(argv[1]);

    string fn_haar = "C:\\opencv\\data\\haarcascades\\haarscascade_frontalface_default.xml";

    string fn_csv = string(argv[1]);
    //int deviceId = atoi(argv[3]);

    // These vectors hold the images and corresponding labels:
    vector<Mat> images;
    vector<int> labels;
    // Read in the data (fails if no valid input filename is given, but you'll get an error message):
    try {
        read_csv(fn_csv, images, labels);
    } catch (cv::Exception& e) {
        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
        // nothing more we can do
        exit(1);
    }
    // Get the height from the first image. We'll need this
    // later in code to reshape the images to their original
    // size AND we need to reshape incoming faces to this size:
    int im_width = images[0].cols;
    int im_height = images[0].rows;
    // Create a FaceRecognizer and train it on the given images:
    Ptr<FaceRecognizer> model = createFisherFaceRecognizer();
    model->train(images, labels);
    // That's it for learning the Face Recognition model. You now
    // need to create the classifier for the task of Face Detection.
    // We are going to use the haar cascade you have specified in the
    // command line arguments:
    //
    CascadeClassifier haar_cascade;
    haar_cascade.load(fn_haar);
    // Get a handle to the Video device:
    VideoCapture cap("C:\\ImageFolder\\Video2.mpg");
    // Check if we can use this device at all ...
(more)
2013-02-15 10:26:09 -0600 asked a question Cascade Classifier example not working

Hi all, Im new to Opencv and was trying to run the object detection tutorial using cascade classifier. link here to tutorial link text

I can get the project to compile and run perfectly except it does not show the circles when going into the detectAndDisplay function.

When I use breakpoints to find out why. It shows that the vector<rect> faces is empty. So the for loops never execute and they dont draw the circles around a face.

I wonder if there is something missing here? Im trying to figure out how use detectMultiScale() but cant find examples.

Any help would be much appreciated. Sonny