Ask Your Question

stepo's profile - activity

2014-10-07 07:53:43 -0600 commented question Slow OclCascadeClassifier::detectMultiScale()

Exactly the same command, I set scaleFactor = 1.1 and minNeighbors = 3 in detectMultiScale parameters explicitly to be sure. And Btw, if I'm using cv::gpu::CascadeClassifier_GPU (CUDA), I get 80ms processing time.

2014-10-07 06:34:16 -0600 commented question Slow OclCascadeClassifier::detectMultiScale()

Well, it's not normal. I have 640*480 input frame resolution. If I'm running the same code but with CPU-based cv::CascadeClassifier I'm getting processing time 350ms per frame.

2014-10-07 01:54:50 -0600 answered a question How to do face alignment without considering eye position

If you don't want to locate eyes, you can for example use cv::matchTemplate() function. Your reference template will be an average face image. However, do you have any special reason why you don't want to locate eyes? the Haar detectors haarcascade_lefteye_2splits.xml and haarcascade_righteye_2splits.xml from opencv sample cascade classifiers work quite good for me. The further proper alignment based on the detected eyes is really easy.

2014-10-06 12:00:31 -0600 received badge  Editor (source)
2014-10-06 10:33:05 -0600 received badge  Supporter (source)
2014-10-06 08:59:52 -0600 asked a question Slow OclCascadeClassifier::detectMultiScale()

Hi,

I have a simple demo application that detect faces in video using OclCascadeClassifier from OpenCL module. The problem is that the detectMultiScale() is really slow. First, I suspected the oclMat::upload() method, but it seems that the bottle neck is the detections itself.

Here is my code:

#include <opencv2/ocl/ocl.hpp>
#include <opencv2/highgui/highgui.hpp>
#include <QDateTime>
#include <QDebug>

int main()
{
    cv::ocl::OclCascadeClassifier detector;
    detector.load("/usr/share/opencv/haarcascades/haarcascade_frontalface_alt.xml");
    cv::VideoCapture capture(0);
    cv::Mat frame;
    std::vector<cv::Rect> faces;
    cv::ocl::oclMat oclFrame;

    int counter = 0;
    double uploadTime = 0;
    double detectTime = 0;
    int N = 500;
    while (counter < N && capture.read(frame))
    {
        QDateTime beforeUpload = QDateTime::currentDateTime();
        oclFrame.upload(frame);
        QDateTime afterUpload = QDateTime::currentDateTime();

        detector.detectMultiScale(oclFrame, faces);
        QDateTime afteDetect = QDateTime::currentDateTime();

        uploadTime += beforeUpload.msecsTo(afterUpload);
        detectTime += afterUpload.msecsTo(afteDetect);

        for (const auto &r : faces)
            cv::rectangle(frame, r, cv::Scalar(0, 255, 0));

        cv::imshow("test", frame);
        cv::waitKey(1);
        counter++;
    }

    uploadTime /= N;
    detectTime /= N;

    qDebug() << "uploadTime:" << uploadTime;
    qDebug() << "detectTime:" << detectTime;
}

And this is the output:

uploadTime: 0.928
detectTime: 517.494

BTW I have nVidia GeForce GT 640M with proper driver.

Thanks. Stepan