voc-release5 windows下的编译

voc-release5只支持linux,并未对windows下的编译提供支持,现总结如下:


这里采用matlab2012b, vs2010编译器:


(1)resize.cc features.cc : 

(a)实现round函数 

inline int round(float a)

 {
return ((int)(a + 0.5f));
}


(b)同时:

#define bzero(a, b) memset(a, 0, b) 


(c)基本的c++编程错误,改为:

alphainfo *ofs = new alphainfo[len]; // c++不支持变量类型的数组大小定义

............

  delete []ofs;
  ofs = NULL;


(2)fv_cache

(a)  取出signal中断控制相关,与功能无关


sigaction // 这个结构类型在windows下未定义,注释fv_cache.cc中所有相关代码;

(b)fv_compile.m

% if ispc
%   error('This code is not supported on Windows.');
% end                                                                                                  // 注释掉,判断平台类型, compile.m中对应语句类似处理


(c)model.h

#define INFINITY INT_MAX 


(d) 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


(a) bounded_dt.cc, dt.cc

typedef int int32_t;

#define INFINITY INT_MAX


(b) fconvsse.cc, fcon_var_dim_MT.cc均为多线程版本,实现hog特征和filters的卷积,由于windows下api不支持pthread库,所以在compie.m中编译的时候,直接编译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 


或者,下载pthread的windows源码(网上很多相关资料,不赘述),进行64位编译,编译出pthreadVC.lib和pthreadVC.dll使用,这个我没有试验成功,有bug,请感兴趣自行尝试;


同时fconvsse.cc用到了SSE的伪函数API, xmmintrinsic, 是为了利用SIMD指令进行并行计算优化,请参考SSE汇编程序设计,如果需要使用fconvsse.cc的话,需要做部分更改:

#include "pthread.h"
#pragma comment(lib, "pthreadVC.lib") // 支持windows下的pthread线程库

....................

//_m_empty();        // 注释掉,该函数清楚寄存器,可注释; 此函数为mmx指令,mmx在vs2010 64bit不支持, 或者换用intel compiler,intel编译器支持64bit下的mmx指令


 float *F = (float *)_aligned_malloc(dims[0]*dims[1]*NUM_FEATURES*sizeof(float), 16); // _aligned_malloc为系统api



(4)star-cascade

(a) cascade.cc 

#define INFINITY INT_MAX

(b) cascade_compile.m


% if ispc
%   error('This code is not supported on Windows.');                    // 注释掉,判断平台类型
% end


(c) timer.h


#include <time.h>
#include <ctime>
#include <windows.h>

// 定义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函数,为执行matlab的编译函数,


try
    eval(mexcmd);            // 需要添加try catch
catch e
end


(6)utils

(a) procid.m


i = strfind(d, '\');  // 注意windows下的路径分隔符和linux下相反


(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路径



  • 2
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 13
    评论
评论 13
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

seasermy

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值