OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 11 Feb 2014 05:36:30 -0600why is cv::invert so incredibly slow?http://answers.opencv.org/question/28169/why-is-cvinvert-so-incredibly-slow/hi,
why is cv::invert so incredibly slow?
inverting a 465x465 matrix using svd takes 2minutes.
without svd it still takes ~2sec
octave is much faster
i try to invert a 48984x465 matrix (SVD) and it takes a lot of time (it does not even completed yet) to invert.
using octaves pinv finishes in <20sec;
calculating `inv(R'*R)*R'` in octave takes <10sec
in opencv (without SVD) it also took much more time than my patience allowed me to wait.
I use 2.4.1
has anyone a hint?
edit: the second test (inv(R'*R)*R') was done in debug. obviously it should finish in same time as the first one)
**Edit2:**
i did some tests with the 2.4.8 ocv version:
inverting 465 x 465 matrix without SVD took 0.5s<br>
inverting 465 x 465 matrix with SVD took 5s<br>
inverting 48984 x 465 matrix with SVD took 10min<br>
inverting 48984 x 465 matrix without SVD (inv(R'*R)*R') took 18s (only measured the inv(R'*R) part)
indeed there is a speed up in later opencv versions.
octave timings:
tic; inv(rand(465,465)); toc -> Elapsed time is 0.0780001 seconds.<br>
tic; pinv(rand(465,465)); toc -> Elapsed time is 1.232 seconds.<br>
tic; pinv(rand(48984,465)); toc -> Elapsed time is 15.023 seconds.<br>
R = rand(48984,465); tic;inv(R'*R);toc --> Elapsed time is 0.889 seconds.
In comparistion to octave that afaik also uses SVD to calculate pseudoinverses opencv implementation seems to be very slow. But also the normal inversion does not compare very well.vlad_tepeschTue, 11 Feb 2014 05:36:30 -0600http://answers.opencv.org/question/28169/