A recent "Video Processing and Analysis" course has a big job, which is about the DPM object detection algorithm. There is DPM source code, but the original can only be run on Linux or Mac, and my computer is Windows system, so I searched the internet on how Windows is running, finally through some code changes, you can run on Windows, the following record my modification process.
DPM source program Download: discriminatively trained deformable part Models (Release 5)
I downloaded the voc-release5
version.
voc-release5
The original does not support compiling in a Windows system, but it can be solved with the following code modifications.
Source code Modification steps
1. Modify the features
features.cc
files in the directory: Add the #include
following two lines of code below all (because the definition is missing on the Windows system);
#define bzero(a, b) memset(a, 0, b)
intround(floata) { floattmp=a- (int)a; if(tmp>= 0.5 ) return (int)a+ 1; Else return (int)a; }
2. Modify the features
file in the directory resize.cc
: Add the above two lines of code, and then the 39th line
alphainfo ofs[len];
Switch
struct alphainfo *ofs = (struct alphainfo *)malloc(sizeof(struct alphainfo)*len);
Add a row after line 80th (the function ends)
free(ofs);
3. Modify the fv_cache
file in the directory fv_compile.m
: Comment out the 13th to 15th line of code (that is, allow compilation on the Windows system);
4. Modify the gdetect
bounded_dt.cc
files in the directory: Add the #include
following two lines of code below all (also because the definition is missing on Windows systems);
#define int32_t int
#define INFINITY 1e8
5. Modify the gdetect
dt.cc
files in the directory: Add the #include
following line of code below all (also because the definition is missing on Windows systems);
#define int32_t int
6. Modify the star-cascade
cascade.cc
files in the directory: Add the #include
following line of code below all (also because the definition is missing on Windows systems);
#define INFINITY 1e8
7. Modify the star-cascade
file in the directory cascade_compile.m
: Comment out the 13th to 15th line of code (that is, allow compilation on the Windows system);
8. Modify the star-cascade
file in the directory timer.h
: delete the 6th line of code #include <sys/time.h>
(because this is a Linux system header file, not in the Windows system), add the following lines of code (that is, add the missing header files and functions);
#include <time.h>
#include <windows.h>
int gettimeofday(struct timeval *tp, void *tzp)
{
time_t clock;
struct tm tm;
SYSTEMTIME wtm;
GetLocalTime(&wtm);
tm.tm_year = wtm.wYear - 1900;
tm.tm_mon = wtm.wMonth - 1;
tm.tm_mday = wtm.wDay;
tm.tm_hour = wtm.wHour;
tm.tm_min = wtm.wMinute;
tm.tm_sec = wtm.wSecond;
tm. tm_isdst = -1;
clock = mktime(&tm);
tp->tv_sec = clock;
tp->tv_usec = wtm.wMilliseconds * 1000;
return (0);
}
9. Modify the compile.m
file: Comment out the 13th to 15th line of code (that is, allow compilation on the Windows system), comment out the 64th line and uncomment the 68th line (that is, choose compile fconv_var_dim.cc
instead fconvsse.cc
). Comment out line 72nd and uncomment line 74th (that is, choose compile fconv_var_dim.cc
instead fconv_var_dim_MT.cc
), then change all to -o
-output
;
After the above steps have been modified, run in MATLAB demo.m
(if your MATLAB has not yet configured MEX, you need to configure it in advance, that is, in the MATLAB command Window mex -setup
, select a compiler Can).
Reference
DPM target Recognition under Windows configuration _moran_ Sina Blog
Linux under Gettimeofday function Windows replacement scheme _castleinthesky_ Sina Blog
What does "O" mean in mex-o in MATLAB and why it is wrong? _ Baidu Know
Using Pthread.h header files under VS2008 and VC6.0 | Toddler Garden
Run felzenszwalb under Windows Star-cascade DPM (deformable part Models) target detection matlab Source-Push Cool
Unknown features in GNU C:attribute__ mechanism-JuanA1 's column-blog channel-csdn.net
GCC __attribute ((packed)) | | attribute ((Aligned (4))) 2-green's Column-Blog channel-csdn.net
C-Language byte alignment (for example, 32-bit system) _ Kevin _ Sina Blog
From for notes (Wiz)
DPM algorithm source program VOC-RELEASE5 configuration modification process in Windows