OpenCV 3.0 Vs OpenCV 2.4.9 + Sobel Performance
I'm experiencing a very performance differences between 2.4.9 and 3.0.
With the simple Soble function I see OpenCV 3.0 run 10x slower than OpenCV 2.4.9 ... O_O ...
I've build up a Visual Studio 2013 project self contained with my benchmark.
Could anyone try and tell me if It sees the same performance difference and could someone explain me the reason?
The project could be downloaded at: http://www.versionestabile.it/opencv/...
With @Eduardo, @StevenPuttemans we ended up to note that OpenCV 3.0 Sobel First Call has a very big overhead, right near 700msec.
cout << "Hello, World! " << CV_VERSION;
int64 A, B;
A = getTickCount();
string _image_name = "equalizzata300.bmp";
string _image_path = "../img/";
Mat image;
image = imread(_image_path + _image_name, CV_8UC3);
if (!image.data)
{
cout << "Could not open or find the image" << std::endl;
return;
}
int scale = 1;
int delta = 0;
int ddepth = CV_16S;
Mat grad;
int64 a, b;
std::cout << "\n STD SOBEL STARTED 1ST CALL \n";
a = getTickCount();
Sobel(image, grad, ddepth, 1, 1, 5, scale, delta, BORDER_DEFAULT);
b = getTickCount();
convertScaleAbs(grad, grad);
B = getTickCount();
cout << "\n STD SOBEL FINISHED 1ST CALL in " << 1000 * (((double)(b - a)) / getTickFrequency()) << ", total " << 1000 * (((double)(B - A)) / getTickFrequency());
std::cout << "\n STD SOBEL STARTED 2ND CALL \n";
a = getTickCount();
Sobel(image, grad, ddepth, 1, 1, 5, scale, delta, BORDER_DEFAULT);
b = getTickCount();
convertScaleAbs(grad, grad);
B = getTickCount();
cout << "\n STD SOBEL FINISHED 2ND CALL in " << 1000 * (((double)(b - a)) / getTickFrequency()) << ", total " << 1000 * (((double)(B - A)) / getTickFrequency());
namedWindow("Sobel", CV_WINDOW_AUTOSIZE);
imshow("Sobel", grad);
waitKey(0);
The question now is: Does someone know the reason of that? Is that true also for other image processing functions?
61mb for a simple sobel test ? please remove the pdb ndb files from it. or rather even restrict it to the src code. folks won't have your vs version, or opencv on the same path.
much simpler test (running on ubuntu):
2 : 2.97818
3 : 3.16783
There are no pdb files. Only src and dll and lib used :) It's the world300.dll that take the most of the space. Have you looked at the zip?! :/
I've put all the dll I've used right because you could try my dll!
well, above shows a performance loss of 3%, not 10x.
no, i did not look at yor zip, it's too large, and i probably can't use your binaries anyway.
just make a gist with the src code, maybe.
Yep, so if you wanna try the src with the attach image we could check the performance on your system.
My results:
Yes, there is a little decrease on performance but not of a factor 10.
You should try the berak code, in your test code you benchmark only on iteration.
However, I tried your code (VS2010, release, win32 mode) with one iteration:
with 100 iterations on Sobel function:
@Eduardo, that is quite a nice comparison, however this does mean that people who need the process on a single input image will have the downsides of the new backend ...
@Eduardo, thanks to have given it a try. So, like StevenPuttemans says, it seems like OpenCV 3.0 have a first function call overhead.
I've so made a new test with only two calls that seems to enforce that assumption.
I've put the code in the question.
STD SOBEL STARTED 1ST CALL
STD SOBEL FINISHED 1ST CALL in 22.2636, total 45.8063 STD SOBEL STARTED 2ND CALL
STD SOBEL FINISHED 2ND CALL in 23.4234, total 86.663
STD SOBEL STARTED 1ST CALL
STD SOBEL FINISHED 1ST CALL in 426.064, total 438.489 STD SOBEL STARTED 2ND CALL
STD SOBEL FINISHED 2ND CALL in 22.0421, total 469.745
@matman: Good point ! Yes it solved it. With one iteration:
With 100 iterations:
@matman: Yep! It works!
So @matman if you wanna answer this question, I'll mark it like "solved" because in fact it solves it! Thanks to all.
Perhaps that's strange, it's like OpenCV 3.0 setup OpenCL driver (like GPU module) even if I don't ask them to use it.
Thank you all and see you at the next question.