libeblearngui
|
00001 /*************************************************************************** 00002 * Copyright (C) 2009 by Pierre Sermanet * 00003 * pierre.sermanet@gmail.com * 00004 * All rights reserved. 00005 * 00006 * Redistribution and use in source and binary forms, with or without 00007 * modification, are permitted provided that the following conditions are met: 00008 * * Redistributions of source code must retain the above copyright 00009 * notice, this list of conditions and the following disclaimer. 00010 * * Redistributions in binary form must reproduce the above copyright 00011 * notice, this list of conditions and the following disclaimer in the 00012 * documentation and/or other materials provided with the distribution. 00013 * * Redistribution under a license not approved by the Open Source 00014 * Initiative (http://www.opensource.org) must display the 00015 * following acknowledgement in all advertising material: 00016 * This product includes software developed at the Courant 00017 * Institute of Mathematical Sciences (http://cims.nyu.edu). 00018 * * The names of the authors may not be used to endorse or promote products 00019 * derived from this software without specific prior written permission. 00020 * 00021 * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED 00022 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 00023 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 00024 * DISCLAIMED. IN NO EVENT SHALL ThE AUTHORS BE LIABLE FOR ANY 00025 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 00026 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 00027 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 00028 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 00029 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 00030 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 00031 ***************************************************************************/ 00032 00033 #ifndef DETECTOR_GUI_H_ 00034 #define DETECTOR_GUI_H_ 00035 00036 #include "libidxgui.h" 00037 #include "libeblearn.h" 00038 #include "detector.h" 00039 #include "ebl_arch_gui.h" 00040 #include "utils.h" 00041 00042 #include <deque> 00043 00044 using namespace std; 00045 00046 namespace ebl { 00047 00049 //EXPORT extern ubyte color_list[12][3]; 00050 00051 EXPORT void draw_bbox_parts(bbox_parts &bb, vector<string> &labels, uint h0, 00052 uint w0, double dzoom); 00055 EXPORT void draw_bbox(bbox &bb, vector<string> &labels, uint h0, uint w0, 00056 double dzoom, float transparency, bool scaled = true, 00057 uint color_offset = 0, bool show_class = true, 00058 bool show_conf = true); 00059 00061 // detector_gui 00062 00064 template <typename T, class Tstate = fstate_idx<T> > 00065 class EXPORT detector_gui { 00066 public: 00080 detector_gui(uint draw_extracted = 0, 00081 bool show_detqueue = false, uint step = 1, uint qheight = 5, 00082 uint qwidth = 5, bool show_detqueue2 = false, uint step2 = 1, 00083 uint qheight2 = 5, uint qwidth2 = 5, bool show_class = true, 00084 bool show_conf = true); 00085 00087 virtual ~detector_gui(); 00088 00094 template <typename Tin> 00095 bboxes& display(detector<T,Tstate> &cl, idx<Tin> &img, 00096 double threshold, const char *frame_name = NULL, 00097 uint h0 = 0, uint w0 = 0, double dzoom = 1.0, T vmin = 0, 00098 T vmax = 0, int wid = -1, const char *wname = NULL, 00099 float transparency = 1.0); 00100 00101 template <typename Tin> 00102 void display_groundtruth(detector<T,Tstate> &cl, idx<Tin> &img, 00103 bboxes &groundtruth, bboxes &filtered, 00104 bboxes &nonfiltered, bboxes &pos, bboxes &neg, 00105 svector<midx<T> > &pp_pos, 00106 svector<midx<T> > &pp_neg, 00107 uint h0 = 0, uint w0 = 0, double dzoom = 1.0, 00108 T vmin = 0, T vmax = 0, int wid = -1); 00109 00115 template <typename Tin> 00116 static void display_minimal(idx<Tin> &img, bboxes& vb, 00117 vector<string> &labels, 00118 uint &h0, uint &w0, 00119 double dzoom = 1.0, T vmin = 0, T vmax = 0, 00120 int wid = -1, bool show_parts = false, 00121 float transparency = 1.0, 00122 bool show_class = true, 00123 bool show_conf = true, 00124 bboxes *bb2 = NULL); 00125 00131 template <typename Tin> 00132 bboxes& display_input(detector<T,Tstate> &cl, idx<Tin> &img, 00133 double threshold, 00134 const char *frame_name = NULL, 00135 uint h0 = 0, uint w0 = 0, 00136 double dzoom = 1.0, T vmin = 0, 00137 T vmax = 0, 00138 int wid = -1, const char *wname = NULL, 00139 float transparency = 1.0); 00140 00141 void display_preprocessed(svector<midx<T> > &pp, bboxes &bbs, 00142 vector<string> &labels, uint &h0, uint &w0, 00143 double dzoom = 1.0, T vmin = 0, T vmax = 0, 00144 uint wmax = 3000); 00145 00152 template <typename Tin> 00153 bboxes& display_inputs_outputs(detector<T,Tstate> &cl, idx<Tin> &img, 00154 double threshold, 00155 const char *frame_name = NULL, 00156 uint h0 = 0, uint w0 = 0, 00157 double dzoom = 1.0, T vmin = 0, 00158 T vmax = 0, int wid = -1, 00159 const char *wname = NULL, 00160 T in_vmin = 0, T in_vmax = 255, 00161 float transparency = 1.0, 00162 uint wmax = 3000); 00163 00164 void display_inputs(detector<T,Tstate> &cl, uint &h0, uint &w0, 00165 bboxes &bb, double dzoom = 1.0, T vmin = 0, T vmax = 0, 00166 float transparency = 1.0); 00167 void display_outputs(detector<T,Tstate> &cl, uint &h0, uint &w0, 00168 bboxes &bb, double dzoom = 1.0, T vmin = 0, T vmax = 0, 00169 float transparency = 1.0); 00170 00177 template <typename Tin> 00178 bboxes& display_all(detector<T,Tstate> &cl, idx<Tin> &img, 00179 double threshold, const char *frame_name = NULL, 00180 uint h0 = 0, uint w0 = 0, double dzoom = 1.0, 00181 T vmin = 0, T vmax = 0, 00182 int wid = -1,const char *wname = NULL); 00183 00188 template <typename Tin> 00189 void display_current(detector<T,Tstate> &cl, 00190 idx<Tin> &sample, 00191 int wid = -1, 00192 const char *wname = NULL, double dzoom = 1.0); 00193 00194 void set_mask_class(const char *name, T threshold); 00195 00197 // private methods 00198 private: 00199 00200 void update_and_display_queue(deque<idx<T> > &queue, uint step, 00201 uint qheight, uint qwidth, 00202 vector<idx<T> > &new_detections, 00203 uint detcnt, uint &h0, uint &w0, 00204 double dzoom); 00205 00207 // members 00208 private: 00209 int display_wid; 00210 int display_wid_fprop; 00211 int display_wid_gt; 00212 uint draw_extracted; 00213 bool show_detqueue; 00214 bool show_detqueue2; 00215 uint step; 00216 uint step2; 00217 uint qheight; 00218 uint qwidth; 00219 uint qheight2; 00220 uint qwidth2; 00221 deque<idx<T> > detqueue; 00222 deque<idx<T> > detqueue2; 00223 uint detcnt; 00224 string mask_class; 00225 T mask_threshold; 00226 bool show_class; 00227 bool show_conf; 00228 }; 00229 00230 } // end namespace ebl 00231 00232 #include "detector_gui.hpp" 00233 00234 #endif /* DETECTOR_GUI_H_ */