Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
7d35e257
Commit
7d35e257
authored
Feb 15, 2014
by
Davis King
Browse files
Added is_track_association_problem()
parent
68f95a19
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
112 additions
and
0 deletions
+112
-0
dlib/svm/svm.h
dlib/svm/svm.h
+57
-0
dlib/svm/svm_abstract.h
dlib/svm/svm_abstract.h
+55
-0
No files found.
dlib/svm/svm.h
View file @
7d35e257
...
@@ -18,6 +18,7 @@
...
@@ -18,6 +18,7 @@
#include "../optimization.h"
#include "../optimization.h"
#include "svm_nu_trainer.h"
#include "svm_nu_trainer.h"
#include <vector>
#include <vector>
#include <set>
namespace
dlib
namespace
dlib
{
{
...
@@ -306,6 +307,62 @@ namespace dlib
...
@@ -306,6 +307,62 @@ namespace dlib
return
false
;
return
false
;
}
}
// ----------------------------------------------------------------------------------------
template
<
typename
detection_type
,
typename
detection_id_type
>
bool
is_track_association_problem
(
const
std
::
vector
<
std
::
vector
<
std
::
pair
<
detection_type
,
detection_id_type
>
>
>&
samples
)
{
if
(
samples
.
size
()
==
0
)
return
false
;
unsigned
long
num_nonzero_elements
=
0
;
for
(
unsigned
long
i
=
0
;
i
<
samples
.
size
();
++
i
)
{
if
(
samples
.
size
()
>
0
)
++
num_nonzero_elements
;
}
if
(
num_nonzero_elements
<
2
)
return
false
;
// now make sure the detection_id_type values are unique within each time step.
for
(
unsigned
long
i
=
0
;
i
<
samples
.
size
();
++
i
)
{
std
::
set
<
detection_id_type
>
vals
;
for
(
unsigned
long
j
=
0
;
j
<
samples
[
i
].
size
();
++
j
)
vals
.
insert
(
samples
[
i
][
j
].
second
);
if
(
vals
.
size
()
!=
samples
[
i
].
size
())
return
false
;
}
// passed all tests so it's good
return
true
;
}
// ----------------------------------------------------------------------------------------
template
<
typename
detection_type
,
typename
detection_id_type
>
bool
is_track_association_problem
(
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
std
::
pair
<
detection_type
,
detection_id_type
>
>
>
>&
samples
)
{
for
(
unsigned
long
i
=
0
;
i
<
samples
.
size
();
++
i
)
{
if
(
!
is_track_association_problem
(
samples
[
i
]))
return
false
;
}
// passed all tests so it's good
return
true
;
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
template
<
template
<
...
...
dlib/svm/svm_abstract.h
View file @
7d35e257
...
@@ -162,6 +162,61 @@ namespace dlib
...
@@ -162,6 +162,61 @@ namespace dlib
- min(samples[i].first.size(), samples[i].second.size()) == N
- min(samples[i].first.size(), samples[i].second.size()) == N
!*/
!*/
// ----------------------------------------------------------------------------------------
template
<
typename
detection_type
,
typename
detection_id_type
>
bool
is_track_association_problem
(
const
std
::
vector
<
std
::
vector
<
std
::
pair
<
detection_type
,
detection_id_type
>
>
>&
samples
);
/*!
ensures
- In this tracking model you get a set of detections at each time step and are
expected to associate each detection with a track or have it spawn a new
track. Therefore, a track association problem is a machine learning problem
where you are given a dataset of example input detections and are expected to
learn to perform the proper detection to track association.
- This function checks if samples can form a valid dataset for this machine
learning problem and returns true if this is the case. This means we should
interpret samples in the following way:
- samples is a track history and for each valid i:
- samples[i] is a set of labeled detections from the i-th time step.
Each detection has been labeled with its "true object identity".
That is, all the detection throughout the history with the same
detection_id_type value are detections from the same object and
therefore should be associated to the same track.
Putting this all together, samples is a valid track association learning
problem if and only if the following are all true:
- samples.size() > 0
- There are at least two values, i and j such that:
- i != j
- samples[i].size() > 0
- samples[j].size() > 0
Or in other words, there needs to be some detections in samples somewhere
or it is impossible to learn anything.
- for all valid i:
- for all valid j and k where j!=k:
- samples[i][j].second != samples[i][k].second
(i.e. the detection_id_type values must be unique within each
time step. Or in other words, you can't have two detections on
the same object in a single time step.)
!*/
template
<
typename
detection_type
,
typename
detection_id_type
>
bool
is_track_association_problem
(
const
std
::
vector
<
std
::
vector
<
std
::
vector
<
std
::
pair
<
detection_type
,
detection_id_type
>
>
>
>&
samples
);
/*!
ensures
- returns true if is_track_association_problem(samples[i]) == true for all
valid i and false otherwise.
!*/
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment