Ask Your Question

vinay's profile - activity

2015-03-01 02:07:28 -0600 asked a question opencv 2.4.9 prebuilt binaries with cuda 6.5 support

where can I get opencv 2.4.9 prebuilt binaries with cuda 6.5 and visual studio 2012 support.. It's very urgent... Please respond...

2015-01-07 11:07:04 -0600 asked a question Building opencv with cuda support

I am using opencv2.4.9 with visual studio 2012. I am trying to build opencv2.4.9 with cuda6.5 support using CMAKE. But everytime I am some error.. Please tell me the correct procedure if anybody knows it..

2015-01-06 23:08:53 -0600 commented question Debug assertion failed. Expression: vector subscript out of range

Thanks for your reply berak, I checked it and you are right that images is empty.. I tried giving absolute path to fn_csv. But still showing that "images is empty" and "debug assertion failed. Expression: vector subscript out of range"

2015-01-06 11:34:23 -0600 asked a question Debug assertion failed. Expression: vector subscript out of range

I am trying to recognize face through ipcam using eigenface recognizer in Visual studio.. But I am getting the error

int main(int argc, const char *argv[]) {

string fn_haar = "C:\\haar\\haarcascade_frontalface_default.xml";
string fn_csv = "csv.ext";
const std::string videoStreamAddress =    // Ipaddress of the camera

vector<Mat> images;
vector<int> labels;

try {
    read_csv(fn_csv, images, labels);
} catch (cv::Exception& e) {
    cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
    exit(1);
}

int im_width = images[0].cols;
int im_height = images[0].rows;

Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
model->train(images, labels);

CascadeClassifier haar_cascade;
haar_cascade.load(fn_haar);

VideoCapture cap;

if(!cap.open(videoStreamAddress)) {
    cerr << "IPcam cannot be opened." << endl;
    return -1;
}

Mat frame;
for(;;) {
    cap >> frame;
    Mat original = frame.clone();
    Mat gray;
    cvtColor(original, gray, CV_BGR2GRAY);
    vector< Rect_<int> > faces;
    haar_cascade.detectMultiScale(gray, faces);

    for(int i = 0; i < faces.size(); i++) {

        Rect face_i = faces[i];
        Mat face = gray(face_i);

        Mat face_resized;
        cv::resize(face, face_resized, Size(im_width, im_height), 1.0, 1.0, INTER_CUBIC);
2015-01-06 01:41:04 -0600 asked a question Error: debug assertion failed. vector subscript out of range line 1140
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()));
        }
    }
}

string g_listname_t[]= 
{
    "Mathew Perry"
};

int main(int argc, const char *argv[]) {

    string fn_haar = "C:\\haar\\haarcascade_frontalface_default.xml";
    string fn_csv = "csv.ext";
    const std::string videoStreamAddress =  // the url of the camera
    // These vectors hold the images and corresponding labels:
    vector<Mat> images;
    vector<int> labels;

    try {
        read_csv(fn_csv, images, labels);
    } catch (cv::Exception& e) {
        cerr << "Error opening file \"" << fn_csv << "\". Reason: " << e.msg << endl;
        exit(1);
    }

    int im_width = images[0].cols;
    int im_height = images[0].rows;

    Ptr<FaceRecognizer> model = createEigenFaceRecognizer();
    model->train(images, labels);

    CascadeClassifier haar_cascade;
    haar_cascade.load(fn_haar);

    VideoCapture cap;

    if(!cap.open(videoStreamAddress)) {
        cerr << "IPcam cannot be opened." << endl;
        return -1;
    }

    Mat frame;
    for(;;) {
        cap >> frame;
        Mat original = frame.clone();
        Mat gray;
        cvtColor(original, gray, CV_BGR2GRAY);
        vector< Rect_<int> > faces;
        haar_cascade.detectMultiScale(gray, faces);

        for(int i = 0; i < faces.size(); i++) {

            Rect face_i = faces[i];
            Mat face = gray(face_i);

            Mat face_resized;
            cv::resize(face, face_resized, Size(im_width, im_height), 1.0, 1.0, INTER_CUBIC);

            int prediction = model->predict(face_resized);

            rectangle(original, face_i, CV_RGB(0, 255,0), 1);

            string box_text;
            box_text = format( "Prediction = " );

            if ( prediction >= 0 && prediction <=1 )
            {
                box_text.append( g_listname_t[prediction] );
            }
            else box_text.append( "Unknown" );

            int pos_x = std::max(face_i.tl().x - 10, 0);
            int pos_y = std::max(face_i.tl().y - 10, 0);

            putText(original, box_text, Point(pos_x, pos_y), FONT_HERSHEY_PLAIN, 1.0, CV_RGB(0,255,0), 2.0);
            waitKey(1000);
        }

        imshow("face_recognizer", original);

        char key = (char) waitKey(20);

        if(key == 27)
            break;
    }
    return 0;
}