KJB
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
pt_file_util.h
Go to the documentation of this file.
1 /* =========================================================================== *
2  |
3  | Copyright (c) 1994-2011 by Kobus Barnard (author)
4  |
5  | Personal and educational use of this code is granted, provided that this
6  | header is kept intact, and that the authorship is not misrepresented, that
7  | its use is acknowledged in publications, and relevant papers are cited.
8  |
9  | For other use contact the author (kobus AT cs DOT arizona DOT edu).
10  |
11  | Please note that the code in this file has not necessarily been adequately
12  | tested. Naturally, there is no guarantee of performance, support, or fitness
13  | for any particular task. Nonetheless, I am interested in hearing about
14  | problems that you encounter.
15  |
16  | Author: Kyle Simek, Ernesto Brau, Jinyan Guan
17  * =========================================================================== */
18 
19 /* $Id: pt_file_util.h 17393 2014-08-23 20:19:14Z predoehl $ */
20 
21 
22 #ifndef PT_FILE_UTIL_H_
23 #define PT_FILE_UTIL_H_
24 
26 #include <boost/format.hpp>
27 #include <boost/lexical_cast.hpp>
28 #include <string>
29 #include <l_cpp/l_filesystem.h>
30 
31 namespace kjb
32 {
33 namespace pt
34 {
35 
40 {
41 public:
44 
46  Input_directory(const std::string& movie_dp) : base_dir_(movie_dp)
47  {}
48 
50  const std::string& get_movie_dp() const { return base_dir_; }
51 
53  std::string get_camera_fp() const
54  {
55  return base_dir_ + "/camera/camera.txt";
56  }
57 
59  std::string get_ransac_camera_fp() const
60  {
61  return base_dir_ + "/camera/ransac_camera.txt";
62  }
63 
65  std::vector<std::string> get_hboxes_fps(Entity_type entity_type) const
66  {
67  const std::string& entity_name = get_entity_type_name(entity_type);
68  return file_names_from_format((base_dir_+ "/detectors/"
69  + entity_name + "/%05d.txt"));
70  }
71 
73  std::vector<std::string> get_hboxes_fps(const std::string& entity_name) const
74  {
75  Entity_type type = boost::lexical_cast<Entity_type>(entity_name);
76  return get_hboxes_fps(type);
77  }
78 
80  std::vector<std::string> get_detection_boxes_fps(Entity_type entity_type) const
81  {
82  const std::string& entity_name = get_entity_type_name(entity_type);
83  return get_detection_boxes_fps(entity_name);
84  }
85 
87  std::vector<std::string> get_detection_boxes_fps(const std::string& entity_name) const
88  {
89  return file_names_from_format((base_dir_+ "/detection_boxes/"
90  + entity_name + "/%05d.txt"));
91  }
92 
94  std::vector<std::string> get_frames_fps() const
95  {
96  return file_names_from_format(base_dir_ + "/frames/%05d.jpg");
97  }
98 
100  std::vector<std::string> get_face_fps() const
101  {
102  return file_names_from_format(base_dir_ + "/features/faces/%05d.txt");
103  }
104 
106  std::vector<std::string> get_face_fps(const std::string& face_subdir) const
107  {
108  return file_names_from_format(base_dir_ + "/features/"
109  + face_subdir + "/%05d.txt");
110  }
111 
113  std::vector<std::vector<std::string> > get_opencv_face_fps() const
114  {
115  std::vector<std::vector<std::string> > face_fps;
116 
117  face_fps.push_back(file_names_from_format(base_dir_ +
118  "/features/face_opencv/frontal_alt/%05d.txt"));
119  face_fps.push_back(file_names_from_format(base_dir_ +
120  "/features/face_opencv/frontal_alt2/%05d.txt"));
121  face_fps.push_back(file_names_from_format(base_dir_ +
122  "/features/face_opencv/frontal_alt_tree/%05d.txt"));
123  face_fps.push_back(file_names_from_format(base_dir_ +
124  "/features/face_opencv/frontal_default/%05d.txt"));
125  face_fps.push_back(file_names_from_format(base_dir_ +
126  "/features/face_opencv/profile/%05d.txt"));
127 
128  return face_fps;
129  }
130 
132  std::vector<std::string> get_optical_flow_fps(size_t frame_rate=1 ) const
133  {
134  //boost::format dp_fmt(base_dir_ + "/features/optical_flow/%02d/");
135  //std::string dp = (dp_fmt % frame_rate).str();
136  std::string dp = base_dir_ + "/features/optical_flow/brox/sparse";
137 
138  return file_names_from_format(dp + "/%05d.txt");
139  }
140 
142  std::vector<std::string> get_histogram_fps
143  (
144  const std::string& entity_name,
145  const std::string& num_bins
146  ) const
147  {
148  return file_names_from_format(base_dir_ + "/features/color_hist/"
149  + entity_name + "/" + num_bins
150  + "/%05d_color_hist.txt");
151  }
152 
153 private:
154  std::string base_dir_;
155 };
156 
161 {
162 public:
165 
167  Output_directory(const std::string& experiment_dp) : base_dir_(experiment_dp)
168  {}
169 
171  const std::string& get_experiment_dp() const { return base_dir_; }
172 
174  std::string get_trajectories_dp() const
175  {
176  return base_dir_ + "/tracks";
177  }
178 
180  std::string get_association_fp() const
181  {
182  return get_trajectories_dp() + "/association.txt";
183  }
184 
186  std::string get_camera_fp() const
187  {
188  return get_trajectories_dp() + "/camera.txt";
189  }
190 
192  std::string get_parameters_fp() const
193  {
194  return get_trajectories_dp() + "/params.txt";
195  }
196 
198  std::string get_best_posteriors_fp() const
199  {
200  return base_dir_ + "/best_posteriors.txt";
201  }
202 
204  std::string get_sample_logs_fp() const
205  {
206  return base_dir_ + "/sample_log.txt";
207  }
208 
210  std::string get_sample_mota_vals_fp() const
211  {
212  return base_dir_ + "/sample_mota_vals.txt";
213  }
214 
216  std::string get_sample_motp_vals_fp() const
217  {
218  return base_dir_ + "/sample_motp_vals.txt";
219  }
220 
222  std::string get_summary_fp() const
223  {
224  return base_dir_ + "/summary.txt";
225  }
226 
228  std::string get_visualization_dp() const
229  {
230  return base_dir_ + "/visualization";
231  }
232 
234  std::string get_visualization_frames_dp() const
235  {
236  return get_visualization_dp() + "/frames";
237  }
238 
240  std::string get_tracks_video_fp() const
241  {
242  return get_visualization_dp() + "/tracks.avi";
243  }
244 
246  std::string get_metadata_fp() const
247  {
248  return base_dir_ + "/metadata.txt";
249  }
250 
252  std::string get_all_samples_dp() const
253  {
254  return base_dir_ + "/samples";
255  }
256 
258  std::string get_proposals_dp() const
259  {
260  return base_dir_ + "/proposals";
261  }
262 
263 private:
264  std::string base_dir_;
265 };
266 
267 }} // namespace kjb::pt
268 
269 #endif /*PT_FILE_UTIL_H_ */
270 
Represents the output directory for the PT tracking project.
Definition: pt_file_util.h:160
std::vector< std::string > file_names_from_format(const std::string &name_format, size_t first, size_t num_files)
Expands the format into a set of (existing) file names.
Definition: l_filesystem.cpp:34
std::string get_camera_fp() const
Returns path to camera file.
Definition: pt_file_util.h:53
std::vector< std::string > get_hboxes_fps(const std::string &entity_name) const
Returns paths to files containing detections of given entity.
Definition: pt_file_util.h:73
std::vector< std::string > get_optical_flow_fps(size_t frame_rate=1) const
Returns paths to images of frames.
Definition: pt_file_util.h:132
std::string get_ransac_camera_fp() const
Returns path to ransac camera file.
Definition: pt_file_util.h:59
std::string get_proposals_dp() const
Returns the path to the proposal history directory.
Definition: pt_file_util.h:258
const std::string & get_entity_type_name(Entity_type type)
Get the name of a entity type.
Definition: tracking_entity.cpp:103
Output_directory(const std::string &experiment_dp)
Creates directory for given video and entity.
Definition: pt_file_util.h:167
std::string get_sample_mota_vals_fp() const
Returns path to file containing all sample MOTA values.
Definition: pt_file_util.h:210
std::vector< std::string > get_face_fps(const std::string &face_subdir) const
Returns paths to detected face files.
Definition: pt_file_util.h:106
std::string get_parameters_fp() const
Returns path to file containing the inferred parameters.
Definition: pt_file_util.h:192
std::vector< std::string > get_histogram_fps(const std::string &entity_name, const std::string &num_bins) const
Returns paths histogram files of given entity and bins.
Definition: pt_file_util.h:143
Represents the input directory for the people tracking project.
Definition: pt_file_util.h:39
std::string get_visualization_dp() const
Returns path to the visualization directory.
Definition: pt_file_util.h:228
const std::string & get_movie_dp() const
Returns movie path.
Definition: pt_file_util.h:50
std::vector< std::string > get_detection_boxes_fps(Entity_type entity_type) const
Returns paths to files containing detections of given entity.
Definition: pt_file_util.h:80
std::string get_camera_fp() const
Returns path to file containing the inferred camera.
Definition: pt_file_util.h:186
Input_directory()
Does nothing. Does not initialize anything!
Definition: pt_file_util.h:43
std::string get_best_posteriors_fp() const
Returns path to file containing best posteriors.
Definition: pt_file_util.h:198
std::string get_tracks_video_fp() const
Returns path to tracks video.
Definition: pt_file_util.h:240
std::vector< std::string > get_hboxes_fps(Entity_type entity_type) const
Returns paths to files containing detections of given entity.
Definition: pt_file_util.h:65
const std::string & get_experiment_dp() const
Returns video directory path.
Definition: pt_file_util.h:171
std::vector< std::vector< std::string > > get_opencv_face_fps() const
Returns paths to detected face files.
Definition: pt_file_util.h:113
std::vector< std::string > get_face_fps() const
Returns paths to detected face files.
Definition: pt_file_util.h:100
std::string get_trajectories_dp() const
Returns path to directory containing tracks.
Definition: pt_file_util.h:174
std::string get_sample_logs_fp() const
Returns path to file containing all sample logs.
Definition: pt_file_util.h:204
std::string get_all_samples_dp() const
Returns the path to the sample history directory.
Definition: pt_file_util.h:252
Output_directory()
Does nothing. Does not initialize anything!
Definition: pt_file_util.h:164
std::string get_metadata_fp() const
Returns path to metadata file.
Definition: pt_file_util.h:246
Entity_type
Definition: tracking_entity.h:40
std::string get_visualization_frames_dp() const
Returns path to visualization frames directory.
Definition: pt_file_util.h:234
std::string get_summary_fp() const
Returns path to summary file.
Definition: pt_file_util.h:222
std::vector< std::string > get_detection_boxes_fps(const std::string &entity_name) const
Returns paths to files containing detections of given entity.
Definition: pt_file_util.h:87
std::string get_sample_motp_vals_fp() const
Returns path to file containing all sample MOTP values.
Definition: pt_file_util.h:216
std::vector< std::string > get_frames_fps() const
Returns paths to images of frames.
Definition: pt_file_util.h:94
std::string get_association_fp() const
Returns path to file containing the inferred association.
Definition: pt_file_util.h:180
Input_directory(const std::string &movie_dp)
Creates input directory in given movie dir path.
Definition: pt_file_util.h:46