forked from Kitware/kwant
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscore_phase1.h
168 lines (135 loc) · 5.84 KB
/
score_phase1.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/*ckwg +5
* Copyright 2010-2016 by Kitware, Inc. All Rights Reserved. Please refer to
* KITWARE_LICENSE.TXT for licensing information, or contact General Counsel,
* Kitware, Inc., 28 Corporate Drive, Clifton Park, NY 12065.
*/
#ifndef INCL_SCORE_PHASE1_H
#define INCL_SCORE_PHASE1_H
#include <vital/vital_config.h>
#include <scoring_framework/score_core_export.h>
#include <vector>
#include <map>
#include <algorithm>
#include <utility>
#include <limits>
#include <scoring_framework/score_core.h>
#include <scoring_framework/phase1_parameters.h>
#include <track_oracle/vibrant_descriptors/descriptor_overlap_type.h>
#include <track_oracle/vibrant_descriptors/descriptor_event_label_type.h>
//
// In phase 1, each ground truth track is compared to each computed track
// independently of all other possible pairings and reduced to a matrix
// of track-to-track score objects. Ideally, all further scoring can
// be based off these objects (plus the optional phase contexts) without
// needing to ever look again at the tracks themselves. If you need to
// look at the tracks, then whatever it was you were looking for should
// probably go in this structure instead.
namespace kwiver {
namespace kwant {
namespace kwto = ::kwiver::track_oracle;
//
// the track2track_score contains the results of compairing a single
// pair of tracks.
//
kwto::frame_handle_list_type
sort_frames_by_field( kwto::track_handle_type track_id, const std::string& name);
struct SCORE_CORE_EXPORT track2track_frame_overlap_record
{
public:
kwto::frame_handle_type truth_frame;
kwto::frame_handle_type computed_frame;
unsigned int fL_frame_num; // frame number of first overlapping frame
unsigned int fR_frame_num; // frame number of second overlapping frame
double truth_area; // area of ground-truth bounding box
double computed_area; // area of computed bounding box
double overlap_area; // area of overlap between the two
double centroid_distance; // distance between centroid of boxes
double center_bottom_distance; // distance between "feet" of boxes
bool in_aoi; // if the result is computed on two boxes with an AOI match (see below)
track2track_frame_overlap_record()
: fL_frame_num(0),
fR_frame_num(0),
truth_area(0.0),
computed_area(0.0),
overlap_area(0.0),
centroid_distance(0.0),
center_bottom_distance(0.0),
in_aoi(true)
{
}
};
struct SCORE_CORE_EXPORT track2track_score
{
public:
unsigned spatial_overlap_total_frames;
ts_frame_range overlap_frame_range;
std::vector< track2track_frame_overlap_record > frame_overlaps;
track2track_score()
: spatial_overlap_total_frames(0),
overlap_frame_range(std::numeric_limits<ts_type>::max(),std::numeric_limits<ts_type>::max())
{
}
// fill in the values given truth track t and computed track c
// returns false if tracks are not in the AOI
bool compute( kwto::track_handle_type t,
kwto::track_handle_type c,
const phase1_parameters& params );
// line up the two frame lists with a tolerance of match_window
// and return a list of aligned frame handles
std::vector< std::pair< kwto::frame_handle_type, kwto::frame_handle_type > >
align_frames( const kwto::frame_handle_list_type& f1,
const kwto::frame_handle_list_type& f2,
double match_window );
// given two frames, return their spatial overlap
track2track_frame_overlap_record compute_spatial_overlap( kwto::frame_handle_type f1,
kwto::frame_handle_type f2,
const phase1_parameters& params );
#ifdef KWANT_ENABLE_MGRS
// given two frames, return their radial overlap (throw if param not set)
track2track_frame_overlap_record compute_radial_overlap( kwto::frame_handle_type f1,
kwto::frame_handle_type f2,
const phase1_parameters& params );
#endif
bool within_window( const kwto::frame_handle_list_type& f1,
const kwto::frame_handle_list_type& f2,
unsigned f1_ptr,
unsigned f2_ptr,
double match_window );
kwto::descriptor_overlap_type create_overlap_descriptor() const;
void add_self_to_event_label_descriptor( kwto::descriptor_event_label_type& delt ) const;
private:
// cached for the descriptor
kwto::track_handle_type cached_truth_track, cached_comp_track;
bool move_a_up_to_b( unsigned& index,
const kwto::frame_handle_list_type& lagging_list,
unsigned fixed_index,
const kwto::frame_handle_list_type& fixed_list,
double match_window );
};
struct SCORE_CORE_EXPORT track2track_phase1
{
public:
// key: (gt_handle, computed_handle) value: resulting t2t_score
std::map< track2track_type, track2track_score > t2t;
track2track_phase1()
{}
explicit track2track_phase1( const phase1_parameters& new_params):
params(new_params)
{}
void compute_all( const kwto::track_handle_list_type& t,
const kwto::track_handle_list_type& c );
void compute_all_detection_mode( const kwto::track_handle_list_type& t,
const kwto::track_handle_list_type& c );
bool compute_single( kwto::track_handle_type t, kwto::track_handle_type c);
void debug_dump( const kwto::track_handle_list_type& gt_list,
const kwto::track_handle_list_type& ct_list,
const std::string& fn_prefix,
ts_type ts_offset ) const;
void debug_dump( std::ostream& os );
std::vector< track2track_type > matching_keys( const track2track_type& probe ) const;
ts_type min_ts() const;
phase1_parameters params;
};
} // ...kwant
} // ...kwiver
#endif