Struck 跟踪算法(二)
以下開始读详细源代码
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 跟踪算法(二)的更多相关文章
- Video Target Tracking Based on Online Learning—TLD单目标跟踪算法详解
视频目标跟踪问题分析 视频跟踪技术的主要目的是从复杂多变的的背景环境中准确提取相关的目标特征,准确地识别出跟踪目标,并且对目标的位置和姿态等信息精确地定位,为后续目标物体行为分析提供足 ...
- KCF跟踪算法 入门详解
一.算法介绍 KCF全称为Kernel Correlation Filter 核相关滤波算法.是在2014年由Joao F. Henriques, Rui Caseiro, Pedro Martins ...
- TLD(Tracking-Learning-Detection)一种目标跟踪算法
原文:http://blog.csdn.net/mysniper11/article/details/8726649 视频介绍网址:http://www.cvchina.info/2011/04/05 ...
- 基于MeanShift的目标跟踪算法及实现
这次将介绍基于MeanShift的目标跟踪算法,首先谈谈简介,然后给出算法实现流程,最后实现了一个单目标跟踪的MeanShift算法[matlab/c两个版本] csdn贴公式比较烦,原谅我直接截图了 ...
- 视觉目标跟踪算法——SRDCF算法解读
首先看下MD大神2015年ICCV论文:Martin Danelljan, Gustav Häger, Fahad Khan, Michael Felsberg. "Learning Spa ...
- TLD目标跟踪算法
1. 简介 TLD目标跟踪算法是Tracking-Learning-Detection算法的简称.这个视频跟踪算法框架由英国萨里大学的一个捷克籍博士生Zdenek Kalal提出.TLD将传统的视频跟 ...
- matlab工具箱之人眼检测+meanshift跟踪算法--人眼跟踪
Viola-Jones 人眼检测算法+meanshift跟踪算法 这次的代码是对视频中的人眼部分进行检测加跟踪,检测用的是matlab自带的人眼检测工具箱 下面是matlab官网介绍这个算法的一些东西 ...
- 比微软kinect更强的视频跟踪算法--TLD跟踪算法介绍
转自:http://blog.csdn.net/carson2005/article/details/7647500 TLD(Tracking-Learning-Detection)是英国萨里大学的一 ...
- Unity人工智能学习—确定性AI算法之追踪算法二
转自:http://blog.csdn.net/zhangxiao13627093203/article/details/47658673 上一篇讲到了追踪算法的比较简单的形式,看上去比较假,因为AI ...
随机推荐
- wince程序调用另外一个wince exe程序?
记住:要释放句柄 清空内存(当前程序) 在虚拟机下测试如图: 在reyo.ini文件中配置另一wince执行程序的路径,如果不配置程序会报错: 如果配置的程序不存在报错: 没有问题就调用所在位置的wi ...
- ios成长之每日一遍(day 5)
iOS 屏幕方向那点事儿http://zhenby.com/blog/2013/08/20/talk-ios-orientation/ 针对当前的屏幕方向进行对应的代码布局 BIDViewContro ...
- [转]小心PHP的类定义顺序与继承的问题
FROM : http://www.pakey.net/blog/php-class-shunxu.html 以下代码的运行环境均为PHP5.3.11先来看一段代码 <?php class A ...
- NVelocity语法常用指令
对变量的引用:$ [ ! ][ { ][ a..z, A..Z ][ a..z, A..Z, 0..9, -, _ ][ } ]. 在NVelocity中,对变量的引用都是以$开头加上变量名称.当使用 ...
- 怎么选择软件许可证,Apache, MIT, BSD, GPL, Mozilla, LGPL
- [leetcode]Pascal's Triangle II @ Python
原题地址:https://oj.leetcode.com/problems/pascals-triangle-ii/ 题意: Given an index k, return the kth row ...
- CSS-文本垂直居中
文本水平居中可以将text-align设置为center即可,垂直居中的话如果是单纯的设置vertical-align是没办法单独设置成功的,垂直居中的文字分为单行文本和多行文本,主要是两种不同的实现 ...
- Distinct Subsequences leetcode java
题目: Given a string S and a string T, count the number of distinct subsequences of T in S. A subseque ...
- 不得不知的ES6十大特性
ES6(ECMAScript2015)的出现,无疑给前端开发人员带来了新的惊喜,它包含了一些很棒的新特性,可以更加方便的实现很多复杂的操作,提高开发人员的效率. 本文主要针对ES6做一个简要介绍. 主 ...
- python用post访问restful服务接口
具体代码如下: import requests import json data={"]} url="http://XXXXX" data_json = json.dum ...