DPM算法是用来做目标识别的。一份matlab的源码可以从这里下到:http://cs.brown.edu/~pff/latent-release3/
作者给出的源码是在mac环境下使用matlab编译和运行的。
而大多数人的工作环境还是在windows下运行matlab,关键是源码中的cc文件,即c++的源文件,是使用 visual studio c++编译的,由于不同的编译器对于C的标准支持不一样,比如math.h中,有的就不包含round和trunc函数,这就需要hack一下。
本人已对此源码进行修改,在matlab R2014a下已经可以使用。源码已经上传到http://download.csdn.net/download/qiuchangyong/9971551,欢迎有问题,相互探讨。
该代码需要首先编译,因为matlab调用c++代码需要一个mexw文件,可能会遇到下面的错误:
>> compile
Error: Could not detect a compiler on local system
which can compile the specified input file(s)
Error using mex (line 206)
Unable to complete successfully.
Error in compile (line 1)
mex -O resize.cc
以上是因为没有设置mex造成的,需要使用本机的msvc编译工具,以我的开发环境为例,具体如下:
>> mex -setup
Welcome to mex -setup. This utility will help you set up
a default compiler. For a list of supported compilers, see
http://www.mathworks.com/support/compilers/R2011b/win64.html
Please choose your compiler for building MEX-files:
Would you like mex to locate installed compilers [y]/n? y
Select a compiler:
[1] Microsoft Software Development Kit (SDK) 7.1 in c:\Program Files (x86)\Microsoft Visual Studio 10.0
[2] Microsoft Visual C++ 2010 in c:\Program Files (x86)\Microsoft Visual Studio 10.0
[0] None
Compiler: 2
Please verify your choices:
Compiler: Microsoft Visual C++ 2010
Location: c:\Program Files (x86)\Microsoft Visual Studio 10.0
Are these correct [y]/n? y
***************************************************************************
Warning: MEX-files generated using Microsoft Visual C++ 2010 require
that Microsoft Visual Studio 2010 run-time libraries be
available on the computer they are run on.
If you plan to redistribute your MEX-files to other MATLAB
users, be sure that they have the run-time libraries.
***************************************************************************
Trying to update options file: C:\Users\Daniel\AppData\Roaming\MathWorks\MATLAB\R2011b\mexopts.bat
From template: C:\PROGRA~1\MATLAB\R2011b\bin\win64\mexopts\msvc100opts.bat
Done . . .
**************************************************************************
Warning: The MATLAB C and Fortran API has changed to support MATLAB
variables with more than 2^32-1 elements. In the near future
you will be required to update your code to utilize the new
API. You can find more information about this at:
http://www.mathworks.com/support/solutions/en/data/1-5C27B9/?solution=1-5C27B9
Building with the -largeArrayDims option enables the new API.
**************************************************************************
这样就可以compile了