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 ...
随机推荐
- 删除数据库字段一样的row, 并增加唯一索引
DELETE FROM `groups` WHERE name IN (select a.name from ( SELECT name FROM `groups` GROUP BY name HAV ...
- java 日历类Calendar用法
如何获取昨天?取昨天的日期,本想的截出来日期减一就好了.又一想不对,如果今天是一号怎么办? 现有两个办法 1: Date as = new Date(new Date().getTime()-24*6 ...
- osx的du以字节计算
https://stackoverflow.com/questions/5794437/difference-in-size-shown-by-du-command-and-get-info-on-m ...
- 简明 MongoDB 入门教程
MongoDB 是免费开源的跨平台 NoSQL 数据库,命名源于英文单词 humongous,意思是「巨大无比」,可见开发组对 MongoDB 的定位.与关系型数据库不同,MongoDB 的数据以类似 ...
- cull/clip distance example
http://www.gamedev.net/topic/578866-d3d10-how-to-increase-maxcount-of-sv_clipdistance/ The D3D#_CL ...
- 遮罩层中的相对定位与绝对定位(Ajax)
前提:公司最近做的一个项目列表,然后点击项目,出现背景遮罩层,弹出的数据框需要异步加载数据数据,让这个数据框居中,搞了两天终于总算达到Boss满意的程度,做了半年C/S,反过来做B/S,顿时感到技术还 ...
- Win32进程创建、进程快照、进程终止用例
进程创建: 1 #include <windows.h> #include <stdio.h> int main() { // 创建打开系统自带记事本进程 STARTUPINF ...
- 【R】函数-数学函数
- VS2010自带的性能分析工具分析.NET程序的性能
这篇博文给大家分享的是,如何使用VS自带的性能分析工具来分析我们编写的.NET程序,一边找出程序性能的瓶颈,改善代码的质量.在实际开发中,性能真的很重要,往往决定一个产品的生死~良好的用户体验的基础之 ...
- 基于浏览器的开源“管理+开发”工具,Pivotal MySQL*Web正式上线!
基于浏览器的开源“管理+开发”工具,Pivotal MySQL*Web正式上线! https://www.sohu.com/a/168292858_747818 https://github.com/ ...