Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Rendering to slow

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 ?

click to hide/show revision 2
retagged

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

berak gravatar image

Rendering to slow

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 ?