采用matlab2012a, vs2013和2013編譯器:
(1)resize.cc features.cc :
實現(xiàn)round函數(shù) : 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++不支持變量類型的數(shù)組大小定義
............
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(); ? ? ? ?// 注釋掉法褥,該函數(shù)清楚寄存器
float *F = (float *)_aligned_malloc(dims[0]*dims[1]*NUM_FEATURES*sizeof(float), 16); //?_aligned_malloc為系統(tǒng)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函數(shù)
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函數(shù):
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)出現(xiàn)系統(tǒng)奔潰問題:
解決方法:resize()函數(shù)改成imresize()函數(shù)
(12)出現(xiàn)features函數(shù)參數(shù)數(shù)據(jù)不匹配的問題
解決方法:重新編譯,運行compile纸厉,知道編譯通過
(13)出現(xiàn)找不到頭文件問題:
解決方法:將#include 改成#include
(14)第五版本的模型與其它版本模型差距較大系吭,如需轉換成VS可識別文件,建議使用第五版本颗品。
參考鏈接:地址