~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Linux Cross Reference
Tina4/src/tools/edge/stest_tool.c

Version: ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /**@(#)
  2 **/
  3 
  4 #include <tina/sys.h>
  5 #include <tina/sysfuncs.h>
  6 #include <tina/math.h>
  7 #include <tina/mathfuncs.h>
  8 #include <tina/vision.h>
  9 #include <tina/visionfuncs.h>
 10 #include <tina/tv.h>
 11 #include <tina/tvfuncs.h>
 12 #include <tina/draw.h>
 13 #include <tina/drawfuncs.h>
 14 #include <tina/toolsfuncs.h>
 15 #include <tina/tw_Xfuncs.h>
 16 
 17 /* EXTERNS  */
 18 extern void *tw_tool();
 19 extern void *tw_fglobal();
 20 extern void *tw_iglobal();
 21 extern void tw_show_tool();
 22 
 23 static Tv *tvl;
 24 static Tv *tvr;
 25 static Parcam *pcam;
 26 
 27 Bool    matches_not_unique();
 28 
 29 static double (*match_cost_func) ();
 30 static  Bool(*match_func) () = es_match_orandcon;
 31 static  Bool(*wta_compat_func) () = matches_not_unique;
 32 
 33 /** parameter handling **/
 34 
 35 static double lowd = -0.5, upd = 0.5;   /* image disparity */
 36 static float lowdisp, updisp;   /* rectified pixel disparity */
 37 static int vdisp = 0;           /* allowable rasters disparity */
 38 
 39 double  stest_lowdisp(void)
 40 {
 41     return (lowdisp);
 42 }
 43 
 44 double  stest_updisp(void)
 45 {
 46     return (updisp);
 47 }
 48 
 49 static void param_dialog(void)
 50 {
 51     static void *dialog = NULL;
 52 
 53     if (dialog)
 54     {
 55         tw_show_dialog(dialog);
 56         return;
 57     }
 58     dialog = tw_dialog("Segment Params");
 59     (void) tw_fglobal("Low disp  :", &lowd, 16);
 60     tw_newrow();
 61     (void) tw_fglobal("Up disp   :", &upd, 16);
 62     tw_newrow();
 63     (void) tw_iglobal("Vert disp :", &vdisp, 16);
 64     tw_end_dialog();
 65 }
 66 
 67 /* Tv pick function selection */
 68 
 69 static void left_pick_proc(Tv_pick(*func) ( /* ??? */ ))
 70 {
 71     tv_set_pick(left_tv(), (*func) ());
 72 }
 73 
 74 static void right_pick_proc(Tv_pick(*func) ( /* ??? */ ))
 75 {
 76     tv_set_pick(right_tv(), (*func) ());
 77 }
 78 
 79 static void left_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
 80 {
 81     tv_set_mouse(left_tv(), (*func) ());
 82 }
 83 
 84 static void right_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
 85 {
 86     tv_set_mouse(right_tv(), (*func) ());
 87 }
 88 
 89 void match_func_choice_proc(int value)
 90 {
 91     switch (value)
 92     {
 93         case 0:
 94         match_func = NULL;
 95         break;
 96     case 1:
 97         match_func = es_match_abs_orient;
 98         break;
 99     case 2:
100         match_func = es_match_orient;
101         break;
102     case 3:
103         match_func = es_match_orandcon;
104         break;
105     }
106 }
107 
108 void match_cost_choice_proc(int value)
109 {
110     switch (value)
111     {
112         case 0:
113         match_cost_func = NULL;
114         break;
115     case 1:
116         match_cost_func = match_strength;
117         break;
118     case 2:
119         match_cost_func = match_total_string_strength;
120         break;
121     case 3:
122         match_cost_func = match_local_string_strength;
123         break;
124     case 4:
125         match_cost_func = match_local_area_strength;
126         break;
127     }
128 }
129 
130 static void wta_compat_choice_proc(int value)
131 {
132     Bool    matches_not_unique();
133     Bool    matches_not_ordered();
134 
135     switch (value)
136     {
137     case 0:
138         wta_compat_func = matches_not_unique;
139         break;
140     case 1:
141         wta_compat_func = matches_not_ordered;
142         break;
143     }
144 }
145 
146 
147 #if 0
148 static void draw_es_list(Tv * tv, List * list)
149 {
150     for (; list != NULL; list = list->next)
151         tv_edge_string(tv, (Tstring *) list->to);
152 }
153 
154 static void draw_match_list(List * mlist)
155 {
156     List   *lptr;
157 
158     for (lptr = mlist; lptr != NULL; lptr = lptr->next)
159         tv_match(tvl, tvr, (Match *) lptr->to);
160 }
161 
162 #endif
163 
164 static void draw_match_list_col(List * mlist)
165 {
166     List   *lptr;
167     int     col = wheat;
168 
169     for (lptr = mlist; lptr != NULL; lptr = lptr->next)
170     {
171         tv_set_color(tvl, col);
172         tv_set_color(tvr, col);
173         tv_match(tvl, tvr, (Match *) lptr->to);
174         col = (col == baby_pink) ? wheat : col + 1;
175     }
176 }
177 
178 void    stest_order_match(int raster)
179 {
180     Imrect *ler;
181     Imrect *rer;
182     Rindex *lsx;
183     Rindex *rsx;
184     List   *mlist;
185 
186     ler = left_edges();
187     rer = right_edges();
188     if (ler == NULL && rer == NULL)
189         return;
190 
191     lsx = (Rindex *) prop_get(ler->props, SINDEX);
192     rsx = (Rindex *) prop_get(rer->props, SINDEX);
193     if (lsx == NULL && rsx == NULL)
194         return;
195 
196     if (raster < lsx->region->ly || raster > lsx->region->uy ||
197         raster < rsx->region->ly || raster > rsx->region->uy)
198         return;
199 
200     mlist = match_epi_dprog((List *) lsx->index[raster], match_cost_func);
201     tv_repaint(tvl);
202     tv_repaint(tvr);
203     draw_match_list_col(mlist);
204     list_rm_links(mlist);
205 }
206 
207 static void choose_wta_proc(void)
208 {
209     Imrect *left_er = left_edges();
210 
211     choose_wta_matches(left_er, match_cost_func, wta_compat_func);
212     er_apply_through_sindex(left_er, es_select_fix_matches, NULL);
213 }
214 
215 void choose_ordered_proc(void)
216 {
217     Imrect *left_er = left_edges();
218 
219     choose_ordered_matches(left_er, match_cost_func);
220     er_apply_through_sindex(left_er, es_select_fix_matches, NULL);
221 }
222 
223 static void choose_string_proc(void)
224 {
225     Imrect *left_er = left_edges();
226 
227 
228     er_apply_to_all_strings(left_er, es_choose_string_matches, NULL);
229     er_apply_through_sindex(left_er, es_select_fix_matches, NULL);
230 }
231 
232 static void figural_supp_proc(void)
233 {
234     er_apply_to_all_strings(left_edges(), es_figural_supp, (void *) match_cost_func);
235 }
236 
237 void string_supp_proc(void)
238 {
239     Imrect *left_er = left_edges();
240 
241     er_apply_to_all_strings(left_er, es_match_string_init, (void *) match_cost_func);
242     er_apply_to_all_strings(left_er, es_match_string, (void *) match_cost_func);
243     er_apply_to_all_strings(left_er, es_mlist_set_total_string_sup, NULL);
244 }
245 
246 static void ordered_supp_proc(void)
247 {
248     Imrect *left_er = left_edges();
249 
250     support_ordered_matches(left_er, match_cost_func);
251     er_apply_through_sindex(left_er, es_supp_good_matches_only, NULL);
252 }
253 
254 static void st_index_proc(void)
255 {
256     Imrect *left_er;
257     Imrect *right_er;
258     double  Disp, edge_Disp_get();
259     Windex *disp_range;
260 
261     tvl = left_tv();
262     tvr = right_tv();
263 
264     left_er = left_edges();
265     right_er = right_edges();
266 
267     if (left_er == NULL || right_er == NULL)
268         return;
269 
270     er_reference_strings(left_er);
271     er_set_sindex(left_er);
272     er_reference_strings(right_er);
273     er_set_sindex(right_er);
274 
275     Disp = edge_Disp_get();
276     lowdisp = Disp + lowd * left_er->width;
277     updisp = Disp + upd * left_er->width;
278 
279     disp_range = er_disp_range_build(left_er, 16, 16);
280     disp_range_fix_disparity(disp_range, lowdisp, updisp);
281     disp_range_set(disp_range);
282 }
283 
284 static void st_hist_proc(void)
285 {
286     Imrect *left_er;
287     Imrect *right_er;
288     double  Disp, edge_Disp_get();
289     Windex *disp_range;
290 
291     left_er = left_edges();
292     right_er = right_edges();
293 
294     if (left_er == NULL || right_er == NULL)
295         return;
296 
297     Disp = edge_Disp_get();
298     lowdisp = Disp + lowd * left_er->width;
299     updisp = Disp + upd * left_er->width;
300 
301     disp_range = er_disp_hist(left_er, right_er, lowdisp, updisp, match_func);
302     disp_range_set(disp_range);
303 }
304 
305 void st_matches_proc(void)
306 {
307     Imrect *left_er;
308     Imrect *right_er;
309 
310     left_er = left_edges();
311     right_er = right_edges();
312 
313     if (left_er == NULL || right_er == NULL)
314         return;
315 
316 /*
317     pcam = pcam_get();
318 */
319 
320     er_apply_through_sindex(left_er, es_init_mlist, NULL);
321     er_set_matches(left_er, right_er, vdisp, match_func);
322 }
323 
324 void st_support_proc(void)
325 {
326     Imrect *left_er;
327 
328 
329     if ((left_er = left_edges()) == NULL)
330         return;
331 
332     er_apply_through_sindex(left_er, es_add_supp_prop, NULL);   /* add support prop */
333 }
334 
335 void stereo_default_proc(void)
336 {
337     match_func_choice_proc(3);
338     match_cost_choice_proc(1); 
339     st_index_proc(); /* no options */
340     st_hist_proc(); /* match_func */
341     st_matches_proc(); /* match_func */
342     st_support_proc(); /* no options */
343     string_supp_proc(); /* match_cost_func */
344     choose_ordered_proc(); /* match_cost_func */
345 }
346 
347 void    stereo_test_tool(int x, int y)
348 {
349     static void *tv_screen = NULL;
350     Tv_mouse left_order_mouse();
351     Tv_mouse right_order_mouse();
352 
353     if (tv_screen)
354     {
355         tw_show_tool(tv_screen);
356         return;
357     }
358     tv_screen = tw_tool("Stereo Test Tool", x, y);
359 
360     tw_menubar("Pick: ",
361                "left",
362                "null", left_pick_proc, null_pick,
363                NULL,
364                "right",
365                "null", right_pick_proc, null_pick,
366                NULL,
367                NULL);
368 
369     tw_newrow();
370     tw_menubar("Mouse: ",
371                "left",
372                "null", left_mouse_proc, null_mouse,
373                "order", left_mouse_proc, left_order_mouse,
374                NULL,
375                "right",
376                "null", right_mouse_proc, null_mouse,
377                "order", right_mouse_proc, right_order_mouse,
378                NULL,
379                NULL);
380 
381     tw_newrow();
382     tw_choice("Match", match_func_choice_proc, 3,
383               "all mats", "abs or", "orient", "or+con", NULL);
384 
385     tw_newrow();
386     tw_choice("Cost", match_cost_choice_proc, 0,
387               "null", "match", "string", "sub str", "area", NULL);
388 
389     tw_newrow();
390     tw_choice("WTA", wta_compat_choice_proc, 0,
391               "unique", "ordered", NULL);
392 
393     tw_newrow();
394     tw_button("index edges", st_index_proc, NULL);
395     tw_button("disp hist", st_hist_proc, NULL);
396     tw_button("set matches", st_matches_proc, NULL);
397     tw_button("set support", st_support_proc, NULL);
398 
399     tw_newrow();
400     (void) tw_label("Support : ");
401     tw_button("ordered", ordered_supp_proc, NULL);
402     tw_button("string tot", string_supp_proc, NULL);
403     tw_button("figural tot", figural_supp_proc, NULL);
404 
405     tw_newrow();
406     (void) tw_label("Choose  : ");
407     tw_button("wta", choose_wta_proc, NULL);
408     tw_button("DP order", choose_ordered_proc, NULL);
409     tw_button("string tot", choose_string_proc, NULL);
410 
411     tw_newrow();
412     tw_button("params", param_dialog, NULL);
413     tw_button("stereo", stereo_default_proc, NULL);
414 
415     tw_end_tool();
416 }
417 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.