Ask Your Question

Neha's profile - activity

2018-12-01 00:59:05 -0600 received badge  Popular Question (source)
2013-05-11 02:18:17 -0600 asked a question Eigenface face recognition using opencv2.4.3

I have implemented the eigenface recognition algorithm using opencv 2.4.3 as given in the "face recognition through opencv" tutorial.Although there are no errors in the code and it works fine-detects face,but it fails to perform recognition properly i.e. it shows prediction=-1 even for images in the database.I had initially used AT & T database available online and later made database of my own images but still in both cases it fails proper recognition.What can be the reason for this?can the clarity of my own image database be the reason for this? please guide.

2013-02-12 07:37:57 -0600 commented answer face recognition using opencv2.4.3

thanks for your reply.but in property pages->common properties->framework and references option was there.there wasn't any Common Properties ->general->command line link. however in configuration properties under C/C++;Linker; Manifest tool; XML document generator; Browse information; Custom build set->General all the above titles have command line option witnin them so where should i make command line related changes and what should i add .also on debugging the command prompt is not stable it comes and goes could you provide a solution for this.please guide..thank you

2013-02-12 07:31:35 -0600 commented answer face recognition using opencv2.4.3

Thanks Mathieu,i changed the file name from C:\att to C:\catt... and the beep has gone also i gave file names in "...."(string) however the command prompt doesnt remain still,i.e. it comes and goes.please suggest the reason for this.also could you please ellaborate the 1st,3rd and 5th points in your previous reply.thank you

2013-02-11 10:08:23 -0600 asked a question face recognition using opencv2.4.3

I'm new to opencv and visual studio and still learning its basics.I'm also doing face recognition project using opencv2.4.3 and visual studio 2010.I have read the tutorial on Face recognition in videos using opencv and implemented the code.the code is as follows with name main.cpp

#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 != 4) {
        cout << "usage: " << argv[0] << " C:\opencv243\data\haarcascades\haarcascade_frontalface_default.xml C:\att\att1.txt 0" << endl;
        cout << "\t C:\opencv243\data\haarcascades\haarcascade_frontalface_default.xml -- Path to the Haar Cascade for face detection." << endl;
        cout << "\t C:\att\att1.txt -- Path to the CSV file with the face database." << endl;
        cout << "\t 0 -- The webcam device id to grab frames from." << endl;
        exit(1);
    }
    // Get the path to your CSV:
    string fn_haar = C:\opencv243\data\haarcascades\haarcascade_frontalface_default.xml ;
    string fn_csv = C:\att\att1.txt ;
    int deviceId = 0
    // 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(deviceId);
    // Check if we can use this device at all:
    if(!cap.isOpened()) {
        cerr << "Capture Device ID " << deviceId << "cannot be opened." << endl;
        return -1;
    }
    // Holds the current frame from the Video device:
    Mat frame;
    for(;;) {
        cap >> frame;
        // Clone the current frame:
        Mat original = frame.clone();
        // Convert the current frame to grayscale:
        Mat gray;
        cvtColor(original, gray, CV_BGR2GRAY);
        // Find the ...
(more)