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:
code
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