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 ...
随机推荐
- Java常用排序算法及性能测试集合
测试报告: Array length: 20000 bubbleSort : 573 ms bubbleSortAdvanced : 596 ms bubbleSortAdvanced2 : 583 ...
- Java 与 Json的互相转换
这几天一直在做Java解析Json数据的一个项目,因为初识json,所以很多东西都是有着懵懂的认识.这里写下我解析时遇到的问题和收获. 我解析json时用到的是json-lib包.下载地址:http: ...
- Material Designer的低版本兼容实现(四)—— ToolBar
Toolbar其实是一个ActionBar的变体,大大扩展了Actionbar.我们可以像对待一个独立控件一样去使用ToolBar,可以将它放到屏幕的任何位置,不必拘泥于顶部,还可以将它改变高度 ...
- [Web前端] 给li设置float浮动属性之后,无法撑开外层ul的问题。
cp from : https://www.cnblogs.com/cielzhao/p/5781462.html 最近在项目中有好几次遇到这个问题,感觉是浮动引起的,虽然用<div style ...
- Spark迷思
眼下在媒体上有非常大的关于Apache Spark框架的声音,渐渐的它成为了大数据领域的下一个大的东西. 证明这件事的最简单的方式就是看google的趋势图: 上图展示的过去两年Hadoop和Spar ...
- Kafka深度解析(如何在producer中指定partition)(转)
原文链接:Kafka深度解析 背景介绍 Kafka简介 Kafka是一种分布式的,基于发布/订阅的消息系统.主要设计目标如下: 以时间复杂度为O(1)的方式提供消息持久化能力,即使对TB级以上数据也能 ...
- ASP.NET Razor C# 和 VB 代码语法
ylbtech-.NET: ASP.NET Razor C# 和 VB 代码语法 Razor 不是一种编程语言.它是服务器端的标记语言. 1. C# 和 VB 代码语法返回顶部 Razor 同时支持 ...
- SGU536 Berland Chess
棋盘上白子只有一个国王 黑子给出 各子遵从国际象棋的走法 黑子不动,白子不能走进黑子的攻击范围以内 问白字能不能吃掉所有的黑子 直接搜索就好了,各子状态用二进制表示 不过每个子被吃之后攻击范围会改变 ...
- Go语言之进阶篇实现并发聊天功能
1.并发聊天服务器原理分析 2.并发聊天室 功能: 广播消息.广播上线. 查询在线用户.修改用户名.用户主动退出.超时处理 示例: package main import ( "fmt&qu ...
- iOS开发-iOS8地理位置定位
现在的App基本上都有定位功能,旅游网站根据定位推荐旅游景点,新闻App通过地理位置推荐当地新闻,社交类的App通过位置交友,iOS中实现以上功能需要一个核心的框架CoreLocation,框架提供了 ...