-
-
Notifications
You must be signed in to change notification settings - Fork 56.5k
Open
Labels
Description
Detailed description
As it is already reported previously, SVD of version 2.3 and later is slower than SVD of version 2.2.
#4313
#7563
#7917
Below, I will report the benchmark result.
OpenCV 2.2 use LAPACK, so its SVD was fast, but OpenCV 2.3 use own implementation, and so its SVD is slow. OpenCV's SVD is implemented in lapack.cpp's JacobiSVDImpl_. I looked at this code, but I could not understand. I just guess that the speed of this function becomes slow when there are zero singular values. In order to check my hypothesis, two benchmark tests are done below: One with the matrix filled with the value "one," and the other with the matrix filled with random numbers.
System information (version)
- OpenCV => 3.1 or 2.2
- Operating System / Platform => Windows 64 Bit
- Compiler => Visual Studio 2015
Steps to reproduce
const int ROW = 2000;
const int COL = 2000;
Mat mat = Mat::ones(ROW, COL, CV_64F);
int64 start = getTickCount();
cout << "start = " << start << endl;
SVD svd(mat);
int64 end = getTickCount();
cout << "end = " << end << endl;
int calctime = (int)((end - start) * 1000 / getTickFrequency());
cout << "duration = " << calctime << " [msec]" << endl << endl;
cout << "W = " << endl << svd.w.rowRange(Range(0, 9)) << endl;For random matrix, following code is used for mat.
RNG gen(getTickCount());
Mat mat(ROW, COL, CV_64F);
gen.fill(mat, RNG::UNIFORM, 0.0, 1.0);Benchmark result: random
| Library | Millisecond |
|---|---|
| MATLAB | 3737 |
| Python numpy | 3878 |
| C/C++ OpenCV 2.2 | 27523 |
| Python OpenCV 3.3 | 147870 |
| C/C++ OpenCV 3.1 | 187424 |
| C/C++ NRC 3rd edit. | 437539 |
| C/C++ Eigen | 940722 |
Benchmark result: ones
| Library | Millisecond |
|---|---|
| C/C++ Eigen | 170 |
| C/C++ OpenCV 2.2 | 2501 |
| MATLAB | 18784 |
| Python numpy | 21017 |
| C/C++ NRC 3rd edit. | 542057 |
| Python OpenCV 3.3 | 9003935 |
| C/C++ OpenCV 3.1 | 9004074 |
Reactions are currently unavailable