Is Matlab even slower than opencv in C ++

According to this link and one , it is that opencv is much faster than matlab. The first link was written in March 2012, the second - a little later.

The first link states that "Programs written in OpenCV are much faster than similar programs written in Matlab." and rates Matlab: 2/10andOpenCV: 9/10

I have two Matrix float size 1024 * 1024 ( mat1 and mat2 ). I want to correlate these matrices.

In matlab

corr2(mat1,mat2);     //70-75 ms

In opencv, C ++

Mat result(1,1,CV_32F);
matchTemplate(mat1,mat2,result, CV_TM_CCOEFF_NORMED);      // 145-150 ms

As far as I know, c and C ++ are at about the same speed.

So, I wonder why matlab is faster than opencv / C ++ when doing cross-correlation. Is it because I'm comparing the wrong things (although the results are the same) or is the matlab cross-correlation implementation doubling faster than the opencv implementation?

Please note that I am using Matlab 2013aand Visual Studio 2010.

Thank,

+4
source share
5 answers

Matlab mkl opencv dont. , , , , matlab (), opencv. - , (openblas, Armadillo, self integrated mkl ..) 2 . , Matlab, . opencv, , . 10000x10000 opencv. 10 . 1 .

+2
+2

, Matlab . , , ( mex), .

1024 32 * 32 , , , ( JIT- ).

+1

Matlab , . , .

A = zeros(100,100);
for m = 1:100
    for n = 1:100
        A(m, n) = 1/(m + n - 1);
    end
end

.

Mat A(100, 100, CV_64F);
for (int r = 0; r < A.rows; r++)
  for (int c = 0; c < A.cols; c++) 
    A.at<double>(r, c) = 1 / (r + c - 1);

.

0

( ) matlab , .

Matlab , , Matlab , , .

corr2, normxcorr2

.

0

Source: https://habr.com/ru/post/1548501/


All Articles