Ask Your Question
0

Rendering to slow

asked 2018-05-11 06:43:12 -0600

flaviu2 gravatar image

updated 2018-05-11 06:55:02 -0600

berak gravatar image

Hi. I have tried a people detector from here:

People detector

beside it doesn't detect very well the people inside of video, the program takes 99% CPU load … why ? It is normal ?

Here is the sample code:

    VideoCapture cap;
cap.open(_T("C:\\Flaviu\\Cat Calls Walking in Street.avi"));
Detector detector;
Mat frame;
for(;;)
{
    cap >> frame;
    if (frame.empty())
    {
        cout << "Finished reading: empty frame" << endl;
        break;
    }
    int64 t = getTickCount();
    vector<Rect> found = detector.detect(frame);    // <------------- this line takes 99% CPU load !!!
    t = getTickCount() - t;
    // show the window
    {
        ostringstream buf;
        buf << "Mode: " << detector.modeName() << " ||| "
            << "FPS: " << fixed << (getTickFrequency() / (double)t);
        putText(frame, buf.str(), Point(10, 30), FONT_HERSHEY_PLAIN, 2.0, Scalar(0, 0, 255), 2, LINE_AA);
    }
    for (vector<Rect>::iterator i = found.begin(); i != found.end(); ++i)
    {
        Rect &r = *i;
        detector.adjustRect(r);
        rectangle(frame, r.tl(), r.br(), cv::Scalar(0, 255, 0), 2);
    }//*/
    imshow("People detector", frame);
    // interact with user
    const char key = (char)waitKey(30);
    if (key == 27 || key == 'q') // ESC
    {
        cout << "Exit requested" << endl;
        break;
    }
    else if (key == ' ')
    {
        detector.toggleMode();
    }
}

I have done soething wrong here ?

edit retag flag offensive close merge delete

Comments

nothing wrong here, HOG is a real hog ...

do you have CUDA ? try the cuda one, then.

berak gravatar imageberak ( 2018-05-11 06:54:27 -0600 )edit

No, I don't have CUDA … hmm .. so, if I haven't, it isn't possible to run a decent OpenCV app, with some filters ?

flaviu2 gravatar imageflaviu2 ( 2018-05-11 06:59:42 -0600 )edit

1 answer

Sort by » oldest newest most voted
0

answered 2018-05-11 07:15:22 -0600

berak gravatar image

updated 2018-05-11 14:21:16 -0600

again, the hog detection will be the main bottleneck, not the rendering.

it will run faster on cropped or resized images, but remember, the minimum size it can detect is 64x128, so not much room to move here.

backgound subtration, and only trying to detect persons, if there's sufficient movement (also: only try hog on the cropped area of the movement), might be another idea.

you could also try the SSD object detection from the dnn module, it has persons, too (and you'd get at least 3 or 4 fps)

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2018-05-11 06:43:12 -0600

Seen: 354 times

Last updated: May 11 '18