Ask Your Question

kingpin's profile - activity

2015-06-03 16:29:10 -0600 asked a question Full Body Detection C++

Hello all,

I am using opencv for full body detection and wanted to know what would be good settings/limits for the minSize and maxSize parameters? As of now I have them blank, my code seems to detect people fairly well. I also have the minNeighbors parameter set to 7. Each time I run my code I get about 20% false positives. My hope is that setting the size parameters will reduce the amount of false positives.

2015-02-15 10:46:01 -0600 asked a question Node-Opencv Installation for Windows OS

Hello all,

I am trying to install the node-opencv module to my Windows OS PC. It appears that the installation tutorial posted by Peter Brandon on Github HERE is for Ubuntu only. Does anyone know how I can install it on Windows OS?

Thanks

2015-01-25 11:37:04 -0600 commented question How do you call negative images in face detection?

Thanks, I will change the parameter in my code and see if that helps. But I think it should be possible, others have used negative images of their respective background environment of what not to detect in order to decrease the likelihood of false positives in their code.

2015-01-25 08:18:32 -0600 commented question How do you call negative images in face detection?

I mean how would you reference background images in a face detection program? What function or code can I use to reference them? Yes, I am getting too many false positives.

2015-01-24 20:39:44 -0600 asked a question How do you call negative images in face detection?

Hello all,

I would like to know how would I go about calling negative samples/images in a face detection program. I've only see it used when creating a custom classifier for a foreign object, for example a banana. I am using the face cascade that comes with OpenCV. Can anyone help me?

2015-01-15 23:08:06 -0600 asked a question Face Detection

I have a code that detects faces and saves multiple cropped area images of them to a file path. My code doesn't stop saving images of detected faces until I physically close the program. For every one second a face is detected on a webcam, my code saves 6 images of the face.

Is it possible to have it save just one image per face detected? For example, if there is one face, only one image, if two faces, an image of both faces are saved etc. My code is below. Can anyone help me?

#include "opencv2/objdetect/objdetect.hpp"
#include "opencv2/highgui/highgui.hpp"
#include "opencv2/imgproc/imgproc.hpp"
#include <iostream>
#include <stdio.h>

using namespace std;
using namespace cv;

void detectAndDisplay(Mat frame);

string face_cascade_name = "C:\\opencv\\sources\\data\\haarcascades\\haarcascade_frontalface_alt2.xml";
CascadeClassifier face_cascade;
string window_name = "Window";
int filenumber; 
string filename;


int main(void)
{
    VideoCapture capture(0);

    if (!capture.isOpened())  
        return -1;

    if (!face_cascade.load(face_cascade_name))
    {
        cout << "error" << endl;
        return (-1);
    };

    Mat frame;

    for (;;)
    {
        capture >> frame;

        if (!frame.empty())
        {
            detectAndDisplay(frame);
        }
        else
        {
            cout << "error2" << endl;
            break;
        }

        int c = waitKey(10);

        if (27 == char(c))
        {
            break;
        }
    }

    return 0;
}

void detectAndDisplay(Mat frame)
{
    std::vector<Rect> faces;
    Mat frame_gray;
    Mat crop;
    Mat res;
    Mat gray;
    string text;
    stringstream sstm;

    cvtColor(frame, frame_gray, COLOR_BGR2GRAY);
    equalizeHist(frame_gray, frame_gray);

    face_cascade.detectMultiScale(frame_gray, faces, 1.1, 2, 0 | CASCADE_SCALE_IMAGE, Size(30, 30));

    cv::Rect roi_b;
    cv::Rect roi_c;

    size_t ic = 0; 
    int ac = 0; 

    size_t ib = 0; 
    int ab = 0; 

    for (ic = 0; ic < faces.size(); ic++) 

    {
        roi_c.x = faces[ic].x;
        roi_c.y = faces[ic].y;
        roi_c.width = (faces[ic].width);
        roi_c.height = (faces[ic].height);

        ac = roi_c.width * roi_c.height; 

        roi_b.x = faces[ib].x;
        roi_b.y = faces[ib].y;
        roi_b.width = (faces[ib].width);
        roi_b.height = (faces[ib].height);


        crop = frame(roi_b);
        resize(crop, res, Size(128, 128), 0, 0, INTER_LINEAR); 
        cvtColor(crop, gray, CV_BGR2GRAY); 

        filename = "C:\\Users\\Desktop\\Faces\\face";
        stringstream ssfn;
        ssfn << filename.c_str() << filenumber << ".jpg";
        filename = ssfn.str();
        cv::imwrite(filename, res); 
        filenumber++;


        Point pt1(faces[ic].x, faces[ic].y); 
        Point pt2((faces[ic].x + faces[ic].height), (faces[ic].y + faces[ic].width));
        rectangle(frame, pt1, pt2, Scalar(0, 255, 0), 2, 8, 0);
    }


    sstm << "Crop area size: " << roi_b.width << "x" << roi_b.height << " Filename: " << filename;


    if (!crop.empty())
    {
        imshow("detected", crop);
    }
    else
        destroyWindow("detected");

}
2015-01-12 11:36:57 -0600 asked a question Writing Video to File

Hi im trying to write a video from my webcam to my computer but I keep getting the error that my writer isnt opened. Im using windows 8 64 bit, VS 2013 & OpenCV 2.4.10. Here is the code that I am using:

#include <opencv\highgui.h>
#include <opencv\cv.h>
#include <iostream>

using namespace cv;
using namespace std;

string intToString(int number){


    std::stringstream ss;
    ss << number;
    return ss.str();
}

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

    VideoCapture cap(0); // open the video camera no. 0

    VideoWriter writer;

    if (!cap.isOpened())  // if not success, exit program
    {
        cout << "ERROR INITIALIZING VIDEO CAPTURE" << endl;
        return -1;
    }

    char* windowName = "Webcam Feed";
    namedWindow(windowName, CV_WINDOW_AUTOSIZE); //create a window to display our webcam feed

    string filename = "C:\\thevideo.avi";
    int fcc = CV_FOURCC('D', 'I', 'V', '3');
    double fps = 20;
    cv::Size frameSize(cap.get(CV_CAP_PROP_FRAME_WIDTH), cap.get(CV_CAP_PROP_FRAME_HEIGHT));

    writer = VideoWriter(filename, fcc, fps, frameSize);

    if (!writer.isOpened())
    {

        cout << "the writer isnt opened" << endl;
        getchar();
        return -1;
    }




    while (1) {
        Mat frame;

        bool bSuccess = cap.read(frame); // read a new frame from camera feed

        if (!bSuccess) //test if frame successfully read
        {
            cout << "ERROR READING FRAME FROM CAMERA FEED" << endl;
            break;
        }

        writer.write(frame);

        imshow(windowName, frame); //show the frame in "MyVideo" window

        //listen for 10ms for a key to be pressed
        switch (waitKey(10)){

        case 27:
            //'esc' has been pressed (ASCII value for 'esc' is 27)
            //exit program.
            return 0;

        }


    }

    return 0;

}

Can anyone help me?

2015-01-05 09:07:05 -0600 received badge  Enthusiast
2015-01-04 22:05:22 -0600 received badge  Student (source)
2015-01-04 21:01:37 -0600 asked a question How do you set up/access a wireless ip camera with OpenCV?

Hello all,

I am attempting to apply my code for face detection that I currently have for webcam, to a wireless IP camera. I have seen on this forum someone posted a code for what seemed to be how to access any & all ip cameras with opencv. It did not specify whether or not there were additional opencv libraries or software that one would have to download or if it was only for a specific brand/model of an ip camera in order for it to work.

My first question is are there any additional opencv libraries that I would have to download to access an ip camera with opencv?

Is the code that was posted on here for accessing ip cameras all you need?

My second question is which brand/model ip camera will this work for (i.e. can you all provide any suggestions)?

Thanks

2014-12-30 18:45:18 -0600 commented answer How do you save images of detected objects?

No I already have the code detecting a face, I am just trying to add the logic such that an image of detected faces is saved to the controller as previously stated.What you have given me in regards to actually saving the image is very helpful. Now all I need help with is having the program only take and save images of faces that are detected.

2014-12-30 17:17:07 -0600 commented answer How do you save images of detected objects?

Thanks that should be very helpful. Do you know how I could go about implementing the actual "if then" logic in the code? By that I mean if face detected, then take picture and save to file path?

2014-12-29 20:57:08 -0600 commented answer How do you save images of detected objects?

I'll have to look in into the imwrite function more, thanks. Do you know how to designate the file path to where I want the image saved to in the code?

2014-12-29 19:00:06 -0600 commented answer How do you save images of detected objects?

I am not sure I understand your answer. Could you explain more?

2014-12-29 16:03:04 -0600 asked a question How do you save images of detected objects?

hello all,

i am trying to add "if logic" to the opencv face detection code such that when a face is detected through a camera or webcam, an image of the detected face is save to a pre-determined file path on the controller or computer such as C:\Users\Public\Desktop.

i have looked everywhere for examples of anything that can help but i cant find anything.

if anyone knows any codes, research articles, websites, people i can contact, that would be very helpful.

Thanks