Matlab在C ++中仍然比opencv慢吗 [英] Is Matlab still slower than opencv in C++

查看:102
本文介绍了Matlab在C ++中仍然比opencv慢吗的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据此链接和此

According to this link and this one, it is said that opencv is much faster than matlab. First link is written in March 2012, second one is a bit later than that.

在第一个链接中,它说:用OpenCV编写的程序比用Matlab编写的类似程序运行得快得多." 并对Matlab: 2/10OpenCV: 9/10

In the first link, it says, "Programs written in OpenCV run much faster than similar programs written in Matlab." and rates Matlab: 2/10 and OpenCV: 9/10

考虑一下,我有两个 float矩阵,其大小为 1024 * 1024 ( mat1 mat2 ).我想关联这些矩阵.

Consider, I have two float Matrix whose size are 1024*1024(mat1 and mat2). I want to correlate this matrices.

在matlab中,

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

在opencv中,c ++

In opencv, c++

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

据我所知,c和c ++的速度大致相同.

As far as I know, c and c++ are in approximately same speed.

所以,我想知道为什么在进行互相关时,matlab比opencv/c ++更快. 是因为我正在比较错误的东西(即使结果相同)还是matlab的互相关实现比opencv实现快一倍?

So, I wonder, why matlab is faster than opencv/c++ while doing cross correlation. Is it because I am comparing wrong things (even though the results are same) or is the cross correlation implementation of matlab is double faster than opencv implementation?

请注意,我正在使用Matlab 2013aVisual Studio 2010.

Note that, I'm using Matlab 2013a and Visual Studio 2010.

谢谢

推荐答案

Matlab内置函数带有mkl和opencv的dont.因此,如果两个函数中都存在两个完全等效的函数,则matlab可能比opencv快(很多).我试图在一个大矩阵上做伪逆,并且用matlab击败所有东西(openblas,Armadillo,自集成mkl等)至少2次.然后我只是停止弄清楚原因,而只是将数据加载到matlab中,然后让它做事情. opencv是迄今为止最慢的.在opencv中的10000x10000矩阵上尝试矩阵乘法.我的笔记本电脑花了10分钟. Matlab用了1分钟.

Matlab built in functions comes with mkl and opencv's dont. So if two exactly equivalent functions are present in both, matlab is likely to be faster(much) than opencv. I have tried to do pseudo inverse on a large matrix and matlab beat everything(openblas,Armadillo,self integrated mkl etc) by at least 2 times. Then I just stopped figuring out why and just load the data into matlab and let it do the thing. opencv is by far the slowest. Try matrix multiplication on a 10000x10000 matrix in opencv. it took 10 minutes on my laptop. Matlab took 1 minute.

这篇关于Matlab在C ++中仍然比opencv慢吗的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆