23 #ifndef PT_SCENE_VIEWER
24 #define PT_SCENE_VIEWER
26 #ifdef KJB_HAVE_OPENGL
40 #include <boost/bind.hpp>
41 #include <boost/optional.hpp>
49 void render_arrow(
const Vector& src,
const Vector&
dest);
52 void render_x(
const Vector& center,
double sz);
66 Render_style(
const Vector& col,
double lw) :
67 color(col), line_width(lw) {}
71 static const Render_style DEFAULT_GROUND_STYLE;
72 static const Render_style DEFAULT_TARGET_STYLE;
73 static const Render_style DEFAULT_DATA_STYLE;
74 static const Vector DEFAULT_TEXT_COLOR;
75 static const size_t DEFAULT_WIDTH = 300;
76 static const size_t DEFAULT_HEIGHT = 300;
85 bool show_window =
true
100 void set_scene(
const Scene& scene);
103 const Scene& scene() {
return *m_scene_p; }
106 void resize(
size_t width,
size_t height);
109 double width()
const;
116 void set_key_callback(
const Func& cb)
121 m_glwin->set_keyboard_callback(cb);
129 IFT(fm_data.size() == scene_length(), Illegal_argument,
130 "Facemark data has incorrect number of frames");
132 m_facemark_data_p = &fm_data;
138 const std::vector<Integral_flow>& flx,
139 const std::vector<Integral_flow>& fly
142 IFT(flx.size() == fly.size() && flx.size() == scene_length() - 1,
143 Illegal_argument,
"Flows have incorrect number of frames");
150 template <
class InputIterator>
151 void set_text_lines(InputIterator first, InputIterator last)
153 m_text_lines.resize(std::distance(first, last));
154 std::copy(first, last, m_text_lines.begin());
158 void add_text_line(
const std::string& str) { m_text_lines.push_back(str); }
161 void clear_text_lines() { m_text_lines.clear(); }
164 template <
class InputIterator>
165 void set_frame_images(InputIterator first, InputIterator last)
167 IFT(std::distance(first, last) == scene_length(),
168 Illegal_argument,
"Incorrect number of frame images.");
170 m_video.load_images(first, last);
172 resize(m_video.get_width(), m_video.get_height());
176 void clear_frame_images()
183 void set_frame(
size_t f);
186 void advance_frame(
size_t df = 1);
189 void rewind_frame(
size_t df = 1);
192 double frame()
const {
return m_frame; }
195 void set_alternative_camera(
const Perspective_camera& cam)
201 void set_overhead_view();
204 void clear_alternative_camera()
206 m_alt_camera = boost::none;
209 void write_images (
const std::vector<std::string>& out_fps);
213 void draw_images(
bool di) { m_draw_images = di; }
216 void draw_ground(
bool dg) { m_draw_ground = dg; }
219 void draw_cylinders(
bool dc) { m_draw_cylinders = dc; }
222 void draw_bodies(
bool db) { m_draw_bodies = db; }
225 void draw_heads(
bool dh) { m_draw_heads = dh; }
228 void draw_faces(
bool df) { m_draw_faces = df; }
231 void draw_bottoms(
bool db) { m_draw_bottoms = db; }
234 void draw_trails(
bool dt) { m_draw_trails = dt; }
237 void draw_full_boxes(
bool dfb) { m_draw_full_boxes = dfb; }
240 void draw_body_boxes(
bool dbb) { m_draw_body_boxes = dbb; }
243 void draw_face_boxes(
bool dfb) { m_draw_face_boxes = dfb; }
246 void draw_face_features(
bool dff) { m_draw_face_features = dff; }
249 void draw_model_vectors(
bool dmv) { m_draw_model_vectors = dmv; }
252 void draw_face_vectors(
bool dfv) { m_draw_face_vectors = dfv; }
255 void draw_data_boxes(
bool ddb) { m_draw_data_boxes = ddb; }
258 void draw_facemarks(
bool dfm) { m_draw_facemarks = dfm; }
261 void draw_flow_vectors(
bool dfv) { m_draw_flow_vectors = dfv; }
264 void draw_flow_face_vectors(
bool dffv) { m_draw_flow_face_vectors = dffv; }
267 void draw_text(
bool dt) { m_draw_text = dt; }
270 void weigh_data_box_color(
bool wbc) { m_weigh_box_color = wbc; }
279 void draw_solid(
bool ds) { m_draw_solid = ds; }
283 void set_target_style
285 const Target& target,
292 void set_target_data_style
294 const Target& target,
301 void set_target_style(
const Vector& color,
double line_width)
303 m_target_style.color = color;
304 m_target_style.line_width = line_width;
308 void clear_target_styles() { m_target_styles.clear(); }
311 void set_data_box_style
313 const Detection_box& dbox,
320 void set_facemark_style
322 const Deva_facemark& fmark,
329 void set_data_style(
const Vector& color,
double line_width)
331 m_data_style.color = color;
332 m_data_style.line_width = line_width;
336 void clear_data_box_styles() { m_data_box_styles.clear(); }
339 void clear_facemark_styles() { m_facemark_styles.clear(); }
342 void set_text_color(
const Vector& color) { m_text_color = color; }
346 void redisplay()
const {
if(m_glwin) m_glwin->redisplay(); }
351 void prepare_for_rendering_2d()
const;
357 void init_lighting()
const;
360 void reshape_scene(
int w,
int h)
const;
363 void render_scene()
const;
366 void render_ground()
const;
369 void render_cylinders()
const;
372 void render_heads()
const;
375 void render_bottoms()
const;
378 void render_trails()
const;
381 void render_model_boxes()
const;
384 void render_face_boxes()
const;
387 void render_model_vectors()
const;
390 void render_data_boxes()
const;
393 void render_facemarks()
const;
396 void render_flow_vectors()
const;
399 void render_text()
const;
402 void render_flow_arrow
405 const Visibility& vis,
406 const Integral_flow& fx,
407 const Integral_flow& fy
411 void set_current_style(
const Target& tg)
const;
414 const Vector& get_target_color(
const Target& target)
const;
417 double get_target_lwidth(
const Target& target)
const;
420 const Vector& get_data_box_color(
const Detection_box& dbox)
const;
423 double get_data_box_lwidth(
const Detection_box& dbox)
const;
426 const Vector& get_facemark_color(
const Deva_facemark& fmark)
const;
429 double get_facemark_lwidth(
const Deva_facemark& fmark)
const;
432 Vector get_text_line_color(
const std::string& str)
const;
435 size_t scene_length()
const
437 return m_scene_p->association.get_data().size();
443 opengl::Glut_window* m_glwin;
445 const Scene* m_scene_p;
447 const std::vector<Integral_flow>* m_flowsx_p;
448 const std::vector<Integral_flow>* m_flowsy_p;
449 std::vector<std::string> m_text_lines;
452 boost::optional<Perspective_camera> m_alt_camera;
457 bool m_draw_cylinders;
463 bool m_draw_full_boxes;
464 bool m_draw_body_boxes;
465 bool m_draw_face_boxes;
466 bool m_draw_face_features;
467 bool m_draw_model_vectors;
468 bool m_draw_face_vectors;
469 bool m_draw_data_boxes;
470 bool m_draw_facemarks;
471 bool m_draw_flow_vectors;
472 bool m_draw_flow_face_vectors;
474 bool m_weigh_box_color;
478 Render_style m_ground_style;
479 Render_style m_target_style;
480 Render_style m_data_style;
482 std::map<const Target*, Render_style> m_target_styles;
483 std::map<const Detection_box*, Render_style> m_data_box_styles;
484 std::map<const Deva_facemark*, Render_style> m_facemark_styles;
height
Definition: APPgetLargeConnectedEdges.m:33
Axis_aligned_rectangle_2d Bbox
Definition: d_bbox.h:29
Offscreen rendering buffer for X11 or Mac OS X.
#define IFT(a, ex, msg)
Definition: l_exception.h:101
std::vector< std::vector< Deva_facemark > > Facemark_data
Definition: pt_data.h:129
#define dest(triedge, pointptr)
Definition: triangle.c:938
Support for error handling exception classes in libKJB.
Definition for the Vector class, a thin wrapper on the KJB Vector struct and its related functionalit...