资源简介
dlib提供的工具,用来制作数据集。打标签,最后会生成一个xml文件,可以在程序中调用。用于训练模型。
代码片段和文件信息
// Copyright (C) 2015 Davis E. King (davis@dlib.net)
// License: Boost Software License See LICENSE.txt for the full license.
#include “cluster.h“
#include
#include
#include
#include
#include
#include
#include
#include
// ----------------------------------------------------------------------------------------
using namespace std;
using namespace dlib;
// ----------------------------------------------------------------------------
struct assignment
{
unsigned long c;
double dist;
unsigned long idx;
bool operator<(const assignment& item) const
{ return dist < item.dist; }
};
std::vector angular_cluster (
std::vector > feats
const unsigned long num_clusters
)
{
DLIB_CASSERT(feats.size() != 0 “The dataset can‘t be empty“);
for (unsigned long i = 0; i < feats.size(); ++i)
{
DLIB_CASSERT(feats[i].size() == feats[0].size() “All feature vectors must have the same length.“);
}
// find the centroid of feats
matrix m;
for (unsigned long i = 0; i < feats.size(); ++i)
m += feats[i];
m /= feats.size();
// Now center feats and then project onto the unit sphere. The reason for projecting
// onto the unit sphere is so pick_initial_centers() works in a sensible way.
for (unsigned long i = 0; i < feats.size(); ++i)
{
feats[i] -= m;
double len = length(feats[i]);
if (len != 0)
feats[i] /= len;
}
// now do angular clustering of the points
std::vector > centers;
pick_initial_centers(num_clusters centers feats linear_kernel >() 0.05);
find_clusters_using_angular_kmeans(feats centers);
// and then report the resulting assignments
std::vector assignments;
for (unsigned long i = 0; i < feats.size(); ++i)
{
assignment temp;
temp.c = nearest_center(centers feats[i]);
temp.dist = length(feats[i] - centers[temp.c]);
temp.idx = i;
assignments.push_back(temp);
}
return assignments;
}
// ----------------------------------------------------------------------------------------
bool compare_first (
const std::pairtadata::image>& a
const std::pairtadata::image>& b
)
{
return a.first < b.first;
}
// ----------------------------------------------------------------------------------------
double mean_aspect_ratio (
const image_dataset_metadata::dataset& data
)
{
double sum = 0;
double cnt = 0;
for (unsigned long i = 0; i < data.images.size(); ++i)
{
for (unsigned long j = 0; j < data.images[i].boxes.size(); ++j)
{
rectangle rect = data.images[i].boxes[j].rect;
if (rect.area()
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
目录 0 2017-11-03 20:16 imglab\
文件 1037 2017-11-03 20:16 imglab\CMakeLists.txt
文件 1814 2017-11-03 20:16 imglab\README.txt
文件 554 2017-11-03 20:16 imglab\convert_imglab_paths_to_relative
文件 756 2017-11-03 20:16 imglab\copy_imglab_dataset
目录 0 2017-11-03 20:16 imglab\src\
文件 9033 2017-11-03 20:16 imglab\src\cluster.cpp
文件 323 2017-11-03 20:16 imglab\src\cluster.h
文件 1015 2017-11-03 20:16 imglab\src\common.cpp
文件 974 2017-11-03 20:16 imglab\src\common.h
文件 4269 2017-11-03 20:16 imglab\src\convert_idl.cpp
文件 358 2017-11-03 20:16 imglab\src\convert_idl.h
文件 5453 2017-11-03 20:16 imglab\src\convert_pascal_v1.cpp
文件 381 2017-11-03 20:16 imglab\src\convert_pascal_v1.h
文件 6997 2017-11-03 20:16 imglab\src\convert_pascal_xm
文件 384 2017-11-03 20:16 imglab\src\convert_pascal_xm
文件 48444 2017-11-03 20:16 imglab\src\main.cpp
文件 21340 2017-11-03 20:16 imglab\src\me
文件 3118 2017-11-03 20:16 imglab\src\me
- 上一篇:智能病床呼叫系统综合(完成仿真).zip
- 下一篇:R语言微博爬虫RWEIBO
评论
共有 条评论