Ask Your Question
2

Why cv::CascadeClassifier works slover in 320 version?

asked 2016-12-28 05:45:11 -0600

pi-null-mezon gravatar image

I have found in one of my projects, that cv::Cascadeclassifier from the new 320 opencv becomes to work slower compare to 310. Why so? I am manually build both versions with pretty same settings.

After some researches I have also found that if object size becomes smaller than in new version speed of detection increases whereas in the old version speed decreases. It seems that scaling method has been changed from the downscale sceme to upscale. Am I right? Did someone else notice that?

edit retag flag offensive close merge delete

Comments

Is it this files ? If yes you can read look for change in history

LBerger gravatar imageLBerger ( 2016-12-28 07:43:05 -0600 )edit

Unfortunatelly I cannot find anything relevant.

pi-null-mezon gravatar imagepi-null-mezon ( 2016-12-28 09:57:39 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
3

answered 2016-12-29 02:23:11 -0600

pi-null-mezon gravatar image

updated 2016-12-29 02:24:09 -0600

After some researches I have finally found the main difference that produces speed down in 320 version of CascadeClassifier::detectMultiscale(...) compare to 310 version. It is because, if your code works with cv::Mat, as mine did, then in new version all evaluations goes to CPU, wherease in previous version evaluations goes to GPU. To prove that I have made this sketches:

Opencv310 detectMultiscale on cv::Mat Opencv310 detectMultiscale on cv::Mat

Opencv320 detectMultiscale on cv::Mat Opencv320 detectMultiscale on cv::Mat

Let's change cv::Mat to cv::UMat.

Opencv320 detectMultiscale on cv::UMat Opencv320 detectMultiscale on cv::UMat

So, as you can see in all three builds Opencl was enabled, but if the old version of the API makes convertion to UMat internally (in detectMultiscale), the new one does not make it, therefore now you should do it manually.

edit flag offensive delete link more

Comments

Sorry I don't understand your result and opencv 3.2.

Can you test this program and give result ? (you have path to image but use same image aloel.jpg)

Platform Name: NVIDIA CUDA
 GPU device
Without opencl umat      with opencl umat        with opencl mat         without opencl mat for cvtColor(0),Blur(1),Canny(2)
getNumberOfCPUs =12      getNumThreads = 13
cvtColor = (3.07857 +/-0.363327)false           (2.92269 +/-0.261379)true               (1.0828 +/-0.0288621)false              (1.05741 +/-0.00739166true
gaussianblur = (25.4579 +/-8.53762)false                (24.2753 +/-1.70079)true                (24.5353 +/-3.48677)false               (25.8735 +/-22.2089)true
LBerger gravatar imageLBerger ( 2016-12-29 10:11:53 -0600 )edit

and check if I didn't make any mistake

LBerger gravatar imageLBerger ( 2016-12-29 10:14:29 -0600 )edit

You have mistake in stdev evaluation. After some modifications I have finally got:

Platform Name: NVIDIA CUDA
 GPU device
CPU info: getNumberOfCPUs =4     getNumThreads = 8
****************************
cvtColor
****************************
UMat without opencl:    0.713295 +/-0.057172
UMat+opencl:            0.706549 +/-0.0419475
Mat without opencl:     0.23625 +/-0.0212271
Mat+opencl:             0.233919 +/-0.0231672

****************************
GaussianBlur
****************************
UMat without opencl:    27.0156 +/-0.6127 ms
UMat+opencl:            27.0232 +/-0.459361 ms
Mat without opencl:     26.8445 +/-0.471617 ms
pi-null-mezon gravatar imagepi-null-mezon ( 2016-12-30 08:41:33 -0600 )edit

Mat+opencl: 26.7322 +/-0.380775 ms

****************************
Canny
****************************
UMat without opencl:    5.59958 +/-0.19882 ms
UMat+opencl:            17.0755 +/-1.77506 ms
Mat without opencl:     5.48947 +/-0.176737 ms
Mat+opencl:             5.54037 +/-0.333726 ms
pi-null-mezon gravatar imagepi-null-mezon ( 2016-12-30 08:43:45 -0600 )edit

too much bug in my program results are wrong...

LBerger gravatar imageLBerger ( 2016-12-30 16:58:14 -0600 )edit

Hey @LBerger, I have found something interesting! In your program, if you will change the sequence of ocl::setUseOpencl(...), than performance boost becomes dramatically. Check it out by change this line to ocl::setUseOpenCL(true);

pi-null-mezon gravatar imagepi-null-mezon ( 2017-01-16 05:04:49 -0600 )edit

yes I know that's differnece between version 1 and version 2 of source program. Now I haven't got time to investigate. I think an isssue is necessary.

LBerger gravatar imageLBerger ( 2017-01-16 06:05:22 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2016-12-28 05:45:11 -0600

Seen: 703 times

Last updated: Dec 29 '16