00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020 #ifndef VSVIEW_H
00021 #define VSVIEW_H
00022
00023 #include <videosource.h>
00024 #include <cv.h>
00025 #include <qapplication.h>
00026
00027 #include <QKeyEvent>
00028 #include <QTimerEvent>
00029 #include <QTime>
00030
00031 #include "glbox.h"
00032 #include "ipltexture.h"
00033 #include <polyora/polyora.h>
00034
00035 class VSView : public GLBox {
00036 Q_OBJECT
00037
00038 public:
00039 VSView(QWidget *parent, const char *name, VideoSource *vs);
00040 ~VSView();
00041 VideoSource *vs;
00042
00043 void saveCurrentFrame(const char *filename);
00044
00045 public slots:
00046 void timerEvent( QTimerEvent *);
00047 void keyPressEvent(QKeyEvent *k);
00048 void mousePressEvent ( QMouseEvent * event );
00049 void mouseReleaseEvent ( QMouseEvent * event );
00050 void mouseDoubleClickEvent ( QMouseEvent * event );
00051 void paintGL();
00052 void show_help();
00053
00054 private:
00055
00056 int timer;
00057 bool filter;
00058 bool viewScores;
00059
00060 public:
00061 bool record;
00062 bool record_pts;
00063 bool record_movie;
00064 bool auto_index;
00065 bool dark;
00066
00067 private:
00068
00069 int nbLev;
00070 int viewlevel;
00071
00072 IplImage *im;
00073
00074 kpt_tracker *tracker;
00075 visual_database database;
00076 incremental_query *query;
00077
00078 visual_object::correspondence_vector corresp;
00079
00080
00081 QTime qtime;
00082 int frameCnt;
00083 int frameno;
00084
00085 FILE *descrf;
00086
00087 public:
00088 const char *tree_fn, *clusters_fn, *descriptors_fn;
00089 const char *visual_db_fn;
00090 float threshold;
00091 int query_flags;
00092 private:
00093
00094 std::list<IplTexture> icon_texture_used, icon_texture_available;
00095
00096 IplTexture entry_tex;
00097 IplTexture add_frame_tex;
00098 QTime add_frame_time;
00099
00100 visual_object *entry;
00101 int nb_missing_frames;
00102 pyr_keypoint *selected_kpt;
00103
00104 void save_descriptors(pyr_frame *frame);
00105 bool selectKeypoint (QMouseEvent *event);
00106 void cmp_affinity();
00107 void print_affinity();
00108 void show_track(pyr_keypoint *k);
00109 void show_tracks();
00110 void write_descriptor(pyr_keypoint *k, long ptr);
00111 void save_tracks();
00112 void createTracker();
00113 void draw_matches(pyr_frame *frame);
00114 void draw_keypoints(pyr_frame *frame);
00115 void draw_all_tracks(pyr_frame *frame);
00116 void draw_selected_track();
00117 void draw_icon(point2d *c, const CvArr *image, float w, float h, float max_width, int margin_x=0, int margin_y=0);
00118 void draw_entry_image();
00119 void drawAnnotations(float dx, float dy);
00120 void addAnnotation(float x, float y);
00121 void add_current_frame_to_db(const char *name, int flags);
00122
00123 enum view_mode_t { VIEW_AUTO, VIEW_KEYPOINTS, VIEW_TRACKS, VIEW_ANNOTATIONS };
00124 view_mode_t view_mode;
00125
00126
00127 enum instr_t { INSTR_ECHO, INSTR_ADD, INSTR_ADDH, INSTR_ADDF, INSTR_CHECK };
00128 struct script_instruction {
00129 instr_t instr;
00130 std::string arg;
00131 };
00132
00133 typedef std::list< script_instruction > instr_list;
00134 typedef std::map<int, instr_list > script_map;
00135 script_map script;
00136 int gt_success, gt_fail, false_pos, false_neg, true_neg;
00137 QTime total_time;
00138 std::string ground_truth;
00139
00140 typedef std::map<unsigned, std::pair<double, unsigned> > fps_stat_map;
00141 fps_stat_map fps_stat;
00142 void update_fps_stat(float fr_ms, pyr_frame *pframe);
00143
00144 public:
00145 bool load_script(const char *fn);
00146 void summary();
00147 protected:
00148 void script_exec(int id);
00149 void segment_scene();
00150 int nlost;
00151 QWidget *help_window;
00152 public:
00153 bool use_pipeline;
00154 };
00155
00156 #endif
00157