以下開始读详细源代码

config.h文件

/*
* Struck: Structured Output Tracking with Kernels
*
* Code to accompany the paper:
* Struck: Structured Output Tracking with Kernels
* Sam Hare, Amir Saffari, Philip H. S. Torr
* International Conference on Computer Vision (ICCV), 2011
*
* Copyright (C) 2011 Sam Hare, Oxford Brookes University, Oxford, UK
*
* This file is part of Struck.
*
* Struck is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Struck is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Struck. If not, see <http://www.gnu.org/licenses/>.
*
*/ #ifndef CONFIG_H
#define CONFIG_H #include <vector>
#include <string>
#include <ostream> #define VERBOSE (0) class Config
{
public:
Config() { SetDefaults(); }
Config(const std::string& path);
//选择提取特征的方式 Haar特征,Raw特征,Histogram特征
enum FeatureType
{
kFeatureTypeHaar,
kFeatureTypeRaw,
kFeatureTypeHistogram
};
//SVM四种核函数
enum KernelType
{
kKernelTypeLinear,
kKernelTypeGaussian,
kKernelTypeIntersection,
kKernelTypeChi2
}; struct FeatureKernelPair
{
FeatureType feature;
KernelType kernel;
std::vector<double> params;
}; bool quietMode;
bool debugMode; std::string sequenceBasePath; //图像序列路径
std::string sequenceName;//图像序列目录名
std::string resultsPath; //结果路径 int frameWidth;//图像宽度
int frameHeight;//图像高度 int seed;
int searchRadius; //搜索半径
double svmC;
int svmBudgetSize; //svm大小
std::vector<FeatureKernelPair> features; friend std::ostream& operator<< (std::ostream& out, const Config& conf); private:
void SetDefaults();
static std::string FeatureName(FeatureType f);
static std::string KernelName(KernelType k);
}; #endif
/*
* Struck: Structured Output Tracking with Kernels
*
* Code to accompany the paper:
* Struck: Structured Output Tracking with Kernels
* Sam Hare, Amir Saffari, Philip H. S. Torr
* International Conference on Computer Vision (ICCV), 2011
*
* Copyright (C) 2011 Sam Hare, Oxford Brookes University, Oxford, UK
*
* This file is part of Struck.
*
* Struck is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* Struck is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Struck. If not, see <http://www.gnu.org/licenses/>.
*
*/ #include "Config.h" #include <fstream>
#include <iostream>
#include <sstream> using namespace std; Config::Config(const std::string& path)
{
SetDefaults(); ifstream f(path.c_str());
if (!f)
{
cout << "error: could not load config file: " << path << endl;
return;
} string line, name, tmp;
while (getline(f, line))
{
istringstream iss(line);
iss >> name >> tmp; // skip invalid lines and comments
if (iss.fail() || tmp != "=" || name[0] == '#') continue; if (name == "seed") iss >> seed;
else if (name == "quietMode") iss >> quietMode;
else if (name == "debugMode") iss >> debugMode;
else if (name == "sequenceBasePath") iss >> sequenceBasePath;
else if (name == "sequenceName") iss >> sequenceName;
else if (name == "resultsPath") iss >> resultsPath;
else if (name == "frameWidth") iss >> frameWidth;
else if (name == "frameHeight") iss >> frameHeight;
else if (name == "seed") iss >> seed;
else if (name == "searchRadius") iss >> searchRadius;
else if (name == "svmC") iss >> svmC;
else if (name == "svmBudgetSize") iss >> svmBudgetSize;
else if (name == "feature")
{
string featureName, kernelName;
double param;
iss >> featureName >> kernelName >> param; FeatureKernelPair fkp; if (featureName == FeatureName(kFeatureTypeHaar)) fkp.feature = kFeatureTypeHaar;
else if (featureName == FeatureName(kFeatureTypeRaw)) fkp.feature = kFeatureTypeRaw;
else if (featureName == FeatureName(kFeatureTypeHistogram)) fkp.feature = kFeatureTypeHistogram;
else
{
cout << "error: unrecognised feature: " << featureName << endl;
continue;
} if (kernelName == KernelName(kKernelTypeLinear)) fkp.kernel = kKernelTypeLinear;
else if (kernelName == KernelName(kKernelTypeIntersection)) fkp.kernel = kKernelTypeIntersection;
else if (kernelName == KernelName(kKernelTypeChi2)) fkp.kernel = kKernelTypeChi2;
else if (kernelName == KernelName(kKernelTypeGaussian))
{
if (iss.fail())
{
cout << "error: gaussian kernel requires a parameter (sigma)" << endl;
continue;
}
fkp.kernel = kKernelTypeGaussian;
fkp.params.push_back(param);
}
else
{
cout << "error: unrecognised kernel: " << kernelName << endl;
continue;
} features.push_back(fkp);
}
}
}
//默认參数设置
void Config::SetDefaults()
{ quietMode = false;
debugMode = false; sequenceBasePath = "";
sequenceName = "";
resultsPath = ""; frameWidth = 320;
frameHeight = 240; seed = 0;
searchRadius = 30;
svmC = 1.0;
svmBudgetSize = 0; features.clear();
} std::string Config::FeatureName(FeatureType f)
{
switch (f)
{
case kFeatureTypeRaw:
return "raw";
case kFeatureTypeHaar:
return "haar";
case kFeatureTypeHistogram:
return "histogram";
default:
return "";
}
} std::string Config::KernelName(KernelType k)
{
switch (k)
{
case kKernelTypeLinear:
return "linear";
case kKernelTypeGaussian:
return "gaussian";
case kKernelTypeIntersection:
return "intersection";
case kKernelTypeChi2:
return "chi2";
default:
return "";
}
} ostream& operator<< (ostream& out, const Config& conf)
{
out << "config:" << endl;
out << " quietMode = " << conf.quietMode << endl;
out << " debugMode = " << conf.debugMode << endl;
out << " sequenceBasePath = " << conf.sequenceBasePath << endl;
out << " sequenceName = " << conf.sequenceName << endl;
out << " resultsPath = " << conf.resultsPath << endl;
out << " frameWidth = " << conf.frameWidth << endl;
out << " frameHeight = " << conf.frameHeight << endl;
out << " seed = " << conf.seed << endl;
out << " searchRadius = " << conf.searchRadius << endl;
out << " svmC = " << conf.svmC << endl;
out << " svmBudgetSize = " << conf.svmBudgetSize << endl; for (int i = 0; i < (int)conf.features.size(); ++i)
{
out << " feature " << i << endl;
out << " feature: " << Config::FeatureName(conf.features[i].feature) << endl;
out << " kernel: " << Config::KernelName(conf.features[i].kernel) <<endl;
if (conf.features[i].params.size() > 0)
{
out << " params: ";
for (int j = 0; j < (int)conf.features[i].params.size(); ++j)
{
out << " " << conf.features[i].params[j];
}
out << endl;
}
} return out;
}

以上是初始化文件源代码

兴许、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、、

Struck 跟踪算法(二)的更多相关文章

  1. Video Target Tracking Based on Online Learning—TLD单目标跟踪算法详解

    视频目标跟踪问题分析         视频跟踪技术的主要目的是从复杂多变的的背景环境中准确提取相关的目标特征,准确地识别出跟踪目标,并且对目标的位置和姿态等信息精确地定位,为后续目标物体行为分析提供足 ...

  2. KCF跟踪算法 入门详解

    一.算法介绍 KCF全称为Kernel Correlation Filter 核相关滤波算法.是在2014年由Joao F. Henriques, Rui Caseiro, Pedro Martins ...

  3. TLD(Tracking-Learning-Detection)一种目标跟踪算法

    原文:http://blog.csdn.net/mysniper11/article/details/8726649 视频介绍网址:http://www.cvchina.info/2011/04/05 ...

  4. 基于MeanShift的目标跟踪算法及实现

    这次将介绍基于MeanShift的目标跟踪算法,首先谈谈简介,然后给出算法实现流程,最后实现了一个单目标跟踪的MeanShift算法[matlab/c两个版本] csdn贴公式比较烦,原谅我直接截图了 ...

  5. 视觉目标跟踪算法——SRDCF算法解读

    首先看下MD大神2015年ICCV论文:Martin Danelljan, Gustav Häger, Fahad Khan, Michael Felsberg. "Learning Spa ...

  6. TLD目标跟踪算法

    1. 简介 TLD目标跟踪算法是Tracking-Learning-Detection算法的简称.这个视频跟踪算法框架由英国萨里大学的一个捷克籍博士生Zdenek Kalal提出.TLD将传统的视频跟 ...

  7. matlab工具箱之人眼检测+meanshift跟踪算法--人眼跟踪

    Viola-Jones 人眼检测算法+meanshift跟踪算法 这次的代码是对视频中的人眼部分进行检测加跟踪,检测用的是matlab自带的人眼检测工具箱 下面是matlab官网介绍这个算法的一些东西 ...

  8. 比微软kinect更强的视频跟踪算法--TLD跟踪算法介绍

    转自:http://blog.csdn.net/carson2005/article/details/7647500 TLD(Tracking-Learning-Detection)是英国萨里大学的一 ...

  9. Unity人工智能学习—确定性AI算法之追踪算法二

    转自:http://blog.csdn.net/zhangxiao13627093203/article/details/47658673 上一篇讲到了追踪算法的比较简单的形式,看上去比较假,因为AI ...

随机推荐

  1. Windows 下安装NPM

    第一步: 下载node.js的windows版 当前最新版本是https://nodejs.org/dist/   第二步:设置环境变量 把node.exe所在目录加入到PATH环境变量中. 配置成功 ...

  2. java.io.IOException: Attempted read from closed stream解决

    在HttpClient请求的时候,返回结果解析时出现java.io.IOException: Attempted read from closed stream. 异常,解决 原因是EntityUti ...

  3. java高分局之jstat命令使用(转)

    转自:http://blog.csdn.net/h_025/article/details/52813817 java高分局之jstat命令使用 jstat命令可以查看堆内存各部分的使用量,以及加载类 ...

  4. SVN更新的问题

    更新的时候一直遇到"Base checksum mismatch on"或者"Checksum mismatch while updating",其它文件可以提 ...

  5. Java中CAS详解

    在JDK 5之前Java语言是靠synchronized关键字保证同步的,这会导致有锁 锁机制存在以下问题: (1)在多线程竞争下,加锁.释放锁会导致比较多的上下文切换和调度延时,引起性能问题. (2 ...

  6. MySQL中的IFNULL,IF,NULLIF函数

    MySQL中的IFNULL函数和IF函数 MySQL中的IFNULL函数类似于Oracle中的NVL函数,其表达式为:IFNULL(expr1,expr2),含义是:如果第一个参数不为空,则返回第一个 ...

  7. 使用模拟对象(Mock Object)技术进行测试驱动开发

    敏捷开发 敏捷软件开发又称敏捷开发,是一种从上世纪 90 年代开始引起开发人员注意的新型软件开发方法.和传统瀑布式开发方法对比,敏捷开发强调的是在几周或者几个月很短的时间周期,完成相对较小功能,并交付 ...

  8. you have mixed tabs and spaces fix this

    http://blog.csdn.net/tonyyan19781/article/details/60882443 Vs2013 IDE下,编辑C++的工程源码,在打开文件的时候,会出现 " ...

  9. [转]QT QDateTime类、QTimer类

    QDateTime类,头文件#include <QDateTime> 可以使用QDateTime类来获得系统时间.通过QDateTime::currentDateTime()来获取本地系统 ...

  10. asp.net获取当前网址url【转】

    设当前页完整地址是:http://www.jb51.net/aaa/bbb.aspx?id=5&name=kelli "http://"是协议名 "www.jb5 ...