zoukankan      html  css  js  c++  java
  • OpenTLD在VS2012和opencv246编译通过

    最近看到了TLD的跟踪视频,觉得很有意思,刚好最近在看行人检测所以就打算下载源码玩一玩,因为源码是Linux版本的(原作者写的是C++和MATLAB的混合编程)C++源码可以在我的博客TLD(一种目标跟踪算法中)下载到。在编译过程中遇到一些问题,在网上找了些资料后顺利解决了。

    1. 下载源码,然后解压,新建VS工程,配置好opencv,把C++源码下的src,include文件夹下的代码cope到新建工程下并在工程中添加
    2. 将代码中的所有包含目录下的.h文件的<>改成”“  比如#include <tld_utils.h>改成#include "tld_utils.h"
    3. opencv246中需要在TLD.h中添加#include <opencv2/legacy/legacy.hpp> //原作者没有添加这个所以出错,定义了PatchGenerator类
    4. Vs中没有round函数,所以要自己写一个,
      int round(float f)
      { 
      if ((int)f+0.5>f) 
      return (int)f; 
      else 
      return (int)f + 1; 
      }
    5. TLD::clusterBB函数中,vs不支持这种动态数组分配。
       

      float L[c-1]; //Level
      int nodes[c-1][2];
      int belongs[c];
      //改成指针和动态分配内存
      float *L = new float [c-1]; //Level
      int **nodes = new int *[c-1];
      for(int i = 0; i < 2 ;i ++)
      nodes[i] = new int [c-1];
      int *belongs = new int [c];
      //记得在函数末释放分配的内存
      delete [] L;
      L = NULL;
      for (int i = 0; i < 2; ++i)
      {
      delete [] nodes[i];
      nodes[i] = NULL;
      }
      delete []nodes;
      nodes = NULL;
      delete [] belongs;
      belongs = NULL;
    6. 上面完成之后,程序编译可以通过,摄像头也可以打开,但是一选定boundingbox程序就运行不下去了。看了一下代码才发现run_tld.cpp中有一个print_help函数。
      看了之后,明白了原来运行需要传递参数。见下面cmd命令:
      %To run from camera
      ./run_tld -p ../parameters.yml
      %To run from file
      ./run_tld -p ../parameters.yml -s ../datasets/06_car/car.mpg
      %To init bounding box from file
      ./run_tld -p ../parameters.yml -s ../datasets/06_car/car.mpg -b ../datasets/06_car/init.txt
      %To train only in the first frame (no tracking, no learning)
      ./run_tld -p ../parameters.yml -s ../datasets/06_car/car.mpg -b ../datasets/06_car/init.txt -no_tl 
      %To test the final detector (Repeat the video, first time learns, second time detects)
      ./run_tld -p ../parameters.yml -s ../datasets/06_car/car.mpg -b ../datasets/06_car/init.txt -r

      这样就可以运行了

  • 相关阅读:
    【QTP】自动化测试:
    sql基本语句
    【转】ASP.NET网站怎么发布web项目程序和怎么部署
    NHibernate的简单例子
    解决ehcache的UpdateChecker问题
    正则表达式的贪婪与懒惰
    Linux查找文件夹名
    centos安装lxml和pyspider
    如何通过写一个chrome扩展启动本地程序
    网页图片滚动效果
  • 原文地址:https://www.cnblogs.com/lxy2017/p/3931119.html
Copyright © 2011-2022 走看看