采用matlab2012a, vs2013和2013编译器:
(1)resize.cc features.cc :
实现round函数 : inline int round(float a){return ((int)(a + 0.5f));}
同时:#define bzero(a, b) memset(a, 0, b)
基本的c++编程错:
alphainfo *ofs = new alphainfo[len]; // c++不支持变量类型的数组大小定义
............
delete []ofs;
ofs = NULL;
(2)fv_cache: sigaction // 注释fv_cache.cc中所有相关代码;
fv_compile.m:
% if ispc
% error('This code is not supported on Windows.');
% end // 注释掉 compile.m中对应语句类似处理
model.h:#define INFINITY INT_MAX
obj_fun.cc:
基本的c++错:
double *hnrms2 = new double[M.num_components];
..........
delete []hnrms2;
hnrms2 = NULL;
double *pc = new double[M.num_components];
...................
delete []pc;
pc = NULL;
(3) gdetect
bounded_dt.cc, dt.cc:typedef int int32_t;
#define INFINITY INT_MAX
fconvsse.cc, fcon_var_dim_MT.cc:
将gdetect_dp.m中进行如下修改与注释:
%if size(pyra.feat{level},3) == 32
% Faster SSE version (fconvsse.cc) that can only handle 32-dim features
% r = fconv(pyra.feat{level}, filters, 1, length(filters));
% else
% More general convolution code to handle non-32-dim features
% e.g., the HOG-PCA features used by the star-cascade
r = fconv_var_dim(pyra.feat{level}, filters, 1, length(filters)); // 直接调用fconv_var_dim.mex64
% end
如需用fconvsse.cc,则部分更改如下:
#include "pthread.h"
#pragma comment(lib, "pthreadVC.lib") // 支持windows下的pthread线程库
....................
//_m_empty(); // 注释掉,该函数清楚寄存器
float *F = (float *)_aligned_malloc(dims[0]*dims[1]*NUM_FEATURES*sizeof(float), 16); // _aligned_malloc为系统api
(4)star-cascade
cascade.cc :#define INFINITY INT_MAX
cascade_compile.m
% if ispc
% error('This code is not supported on Windows.'); // 注释掉,判断平台类型
% end
timer.h:
#include
#include
#include
// 定义timer结构体
class timer {
struct timeval {
long tv_sec;
long tv_usec;
};
// 定义gettimeofday函数
private:
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);
}
(5) eval函数:
try
eval(mexcmd);
catch e
end
(6)utils
procid.m:
i = strfind(d, '\');
(7)compile.m:
% if ispc
% error('This code is not supported on Windows.');
% end
try///////////////////////////////////////
if nargin < 3
% Build feature vector cache code
fv_compile(opt, verb);
% Build the star-cascade code
cascade_compile(opt, verb);
eval([mexcmd ' features/resize.cc']);
eval([mexcmd ' features/features.cc']);
eval([mexcmd ' gdetect/dt.cc']);
eval([mexcmd ' gdetect/bounded_dt.cc']);
eval([mexcmd ' gdetect/get_detection_trees.cc']);
eval([mexcmd ' gdetect/compute_overlap.cc']);
% Convolution routine
% Use one of the following depending on your setup
% (0) is fastest, (2) is slowest
% 0) multithreaded convolution using SSE
%eval([mexcmd ' gdetect/fconv.cc']);
% 1) multithreaded convolution
%eval([mexcmd ' gdetect/fconv_var_dim_MT.cc -o fconv']);
% 2) basic convolution, very compatible
% eval([mexcmd ' gdetect/fconv_var_dim.cc']);
% Convolution routine that can handle feature dimenions other than 32
% 0) multithreaded convolution
%eval([mexcmd ' gdetect/fconv_var_dim_MT.cc']);
% 1) single-threaded convolution
eval([mexcmd ' gdetect/fconv_var_dim.cc']);//////////////////////////////////////////////////////////////////////单线程,非sse版本
else
eval([mexcmd ' ' mex_file]);
end
catch e ////////////////////////////////////////////////////////////////////////////////////////
warning(e.identifier, 'dddd');
end//////////////////////////////////////////////////////////////
(8)demo.m:
%compile;
(9)pascal.m
diary(conf.training.log([cls '-' timestamp])); // 注释掉,报错
(10)voc_config.m
BASE_DIR = 'f:/code';
conf = cv(conf, 'pascal.dev_kit', [conf.paths.base_dir '/VOCdevkit/']); // 注意配置这几句, VOCdevkit路径
(11)出现系统奔溃问题:
解决方法:resize()函数改成imresize()函数
(12)出现features函数参数数据不匹配的问题
解决方法:重新编译,运行compile,知道编译通过
(13)出现找不到头文件问题:
解决方法:将#include 改成#include
(14)第五版本的模型与其它版本模型差距较大,如需转换成VS可识别文件,建议使用第五版本。
参考链接:地址