Ask Your Question
-1

Human Detection and tracking opencv c++

asked 2017-12-05 15:09:35 -0600

Faj gravatar image

updated 2017-12-05 15:35:46 -0600

Please, can somebody help me to execute Human Detection and tracking on my computer using opencv C++ and i ready to pay ($) for this program

edit retag flag offensive close merge delete

Comments

please, send your email to explain the details.

Faj gravatar imageFaj ( 2017-12-05 15:13:03 -0600 )edit
2

Usually a good test is if the mouse moves or the keyboard is pressed. Typically that means you have detected a human on your computer. It sometimes has false-alarms on cats.

Seriously though, we're here to help with OpenCV questions, which this is not. If you want hire someone, we don't mind too much, but you're going to have to get specific. What are your requirements, what scenario, what accuracy. And especially, how much money.

Tetragramm gravatar imageTetragramm ( 2017-12-05 18:15:32 -0600 )edit

I have to refrain myself from generating a let me google that for you - link ...

StevenPuttemans gravatar imageStevenPuttemans ( 2017-12-06 04:35:36 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
2

answered 2017-12-08 04:34:35 -0600

updated 2017-12-08 04:35:15 -0600

You are lucky that I am currently teaching a class on this and just made a sample... but you will need to adapt it to your needs and make it more robust for your case

#include <iostream>
#include <opencv2/opencv.hpp>

using namespace std;
using namespace cv;
using namespace cv::ml;

int main( int argc, const char** argv )
{
    /// Use the cmdlineparser to process input arguments
    CommandLineParser parser(argc, argv,
        "{ help h            |      | show this message }"
        "{ video v           |      | (required) path to video }"
    );

    /// If help is entered
    if (parser.has("help")){
        parser.printMessage();
        return 0;
    }

    /// Parse arguments
    string video_location(parser.get<string>("video"));
    if (video_location.empty()){
        parser.printMessage();
        return -1;
    }

    /// Create a videoreader interface
    VideoCapture cap(video_location);
    Mat current_frame;

    /// Set up the pedestrian detector --> let us take the default one
    HOGDescriptor hog;
    hog.setSVMDetector(HOGDescriptor::getDefaultPeopleDetector());

    /// Set up tracking vector
    vector<Point> track;

    while(true){
        /// Grab a single frame from the video
        cap >> current_frame;

        /// Check if the frame has content
        if(current_frame.empty()){
            cerr << "Video has ended or bad frame was read. Quitting." << endl;
            return 0;
        }

        /// run the detector with default parameters. to get a higher hit-rate
        /// (and more false alarms, respectively), decrease the hitThreshold and
        /// groupThreshold (set groupThreshold to 0 to turn off the grouping completely).

        ///image, vector of rectangles, hit threshold, win stride, padding, scale, group th
        Mat img = current_frame.clone();
        resize(img,img,Size(img.cols*2, img.rows*2));

        vector<Rect> found;
        vector<double> weights;

        hog.detectMultiScale(img, found, weights);

        /// draw detections and store location
        for( size_t i = 0; i < found.size(); i++ )
        {
            Rect r = found[i];
            rectangle(img, found[i], cv::Scalar(0,0,255), 3);
            stringstream temp;
            temp << weights[i];
            putText(img, temp.str(),Point(found[i].x,found[i].y+50), FONT_HERSHEY_SIMPLEX, 1, Scalar(0,0,255));
            track.push_back(Point(found[i].x+found[i].width/2,found[i].y+found[i].height/2));
        }

        /// plot the track so far
        for(size_t i = 1; i < track.size(); i++){
            line(img, track[i-1], track[i], Scalar(255,255,0), 2);
        }

        /// Show
        imshow("detected person", img);
        waitKey(1);
    }

    return 0;
}
edit flag offensive delete link more

Comments

1

thank you very much

Faj gravatar imageFaj ( 2018-01-03 13:13:23 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-12-05 15:09:35 -0600

Seen: 12,264 times

Last updated: Dec 08 '17