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

Linux Cross Reference
Tina6/tina-tools/tinatool/tlvision/tlvisEdge_tool.c

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

  1 /**********
  2 *
  3 *
  4  * Copyright (c) 2003, Division of Imaging Science and Biomedical Engineering,
  5  * University of Manchester, UK.  All rights reserved.
  6  * 
  7  * Redistribution and use in source and binary forms, with or without modification, 
  8  * are permitted provided that the following conditions are met:
  9  * 
 10  *   . Redistributions of source code must retain the above copyright notice, 
 11  *     this list of conditions and the following disclaimer.
 12  *    
 13  *   . Redistributions in binary form must reproduce the above copyright notice,
 14  *     this list of conditions and the following disclaimer in the documentation 
 15  *     and/or other materials provided with the distribution.
 16  * 
 17  *   . Neither the name of the University of Manchester nor the names of its
 18  *     contributors may be used to endorse or promote products derived from this 
 19  *     software without specific prior written permission.
 20  * 
 21  * 
 22  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 
 23  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 
 24  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 
 25  * ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE 
 26  * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
 27  * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 
 28  * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
 29  * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 
 30  * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
 31  * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 
 32  * POSSIBILITY OF SUCH DAMAGE.
 33 **********
 34 *
 35 * Program :   TINA
 36 * File    :  $Source: /home/tina/cvs/tina-tools/tinatool/tlvision/tlvisEdge_tool.c,v $
 37 * Date    :  $Date: 2009/03/27 16:01:50 $
 38 * Version :  $Revision: 1.8 $
 39 * CVS Id  :  $Id: tlvisEdge_tool.c,v 1.8 2009/03/27 16:01:50 paul Exp $
 40 *
 41 * Notes   :
 42 *
 43 *
 44 *
 45 *********
 46 */
 47 
 48 #include "tlvisEdge_tool.h"
 49 
 50 #if HAVE_CONFIG_H
 51   #include <config.h>
 52 #endif
 53 
 54 #include <tina/sys/sysDef.h>
 55 #include <tina/sys/sysPro.h>
 56 #include <tina/math/mathDef.h>
 57 #include <tina/math/mathPro.h>
 58 #include <tina/geometry/geomDef.h>
 59 #include <tina/geometry/geomPro.h>
 60 #include <tina/image/imgDef.h>
 61 #include <tina/image/imgPro.h>
 62 #include <tina/vision/visDef.h>
 63 #include <tina/vision/visPro.h>
 64 
 65 #include <tinatool/wdgts/wdgtsDef.h>
 66 #include <tinatool/wdgts/wdgtsPro.h>
 67 #include <tinatool/draw/drawDef.h>
 68 #include <tinatool/draw/drawPro.h>
 69 #include <tinatool/tlbase/tlbasePro.h>
 70 #include <tinatool/tlvision/tlvisCnr_pick.h>
 71 #include <tinatool/tlvision/tlvisEdge_pick.h>
 72 #include <tinatool/tlvision/tlvisEdge_geom_pick.h>
 73 #include <tinatool/tlvision/tlvisEdge_epi_mouse.h>
 74 
 75 
 76 /* Local parameters managed by the edge processing tool */
 77 static double sigma = 1.15, precision = 0.01;
 78 static double low_edge_thres = 3.0, up_edge_thres = 5.0;
 79 static int len_thres = 4;
 80 static double mid_point = 128.0;
 81 static double conf_thres = 0.1;
 82 static double low_fit_thres = 0.5;
 83 static double up_fit_thres = 1.0;
 84 static double rect_scale = 1.0;
 85 static int max_div = 5;         /* max divergence from fit */
 86 static int sample = 12;         /* initial sample frequency */
 87 static int  stereo_method = 0;       /* stereo matching method */
 88 static Bool use_TV_ROIs = false;
 89 static int kernel = 5;
 90 static double noise = 8.0;
 91 static Interp interp = sinc5_interp;
 92 
 93 /* Other local variables */
 94 static Bool edges_rectified = false;
 95 static Bool simple_link = false;
 96 static double Disp = 0;         /* major component of disparity */
 97 static void *rsc;
 98 
 99 
100 #define POLY_PROX 0
101 #define LINEAR_PROX 1
102 #define CONIC_PROX 2
103 #define LINEAR_CONIC_PROX 3
104 #define STEREO_PMF  0
105 #define STEREO_SC   1
106 
107 #define DEFAULT 0
108 #define JOIN    1
109 
110 static int stereo_images = 1;
111 static int feature_type = 0;
112 static int approx_type = LINEAR_CONIC_PROX;
113 static int options = DEFAULT;
114 
115 /* Make the major component of disparity, ie that produced by the
116  * rectification process, available to other modules */
117 double  edge_Disp_get(void)
118 {
119     return (Disp);
120 }
121 
122 /* External check to see if edge rectification has been applied */
123 Bool    edge_edges_rectified_get(void)
124 {
125     return (edges_rectified);
126 }
127 
128 /* External setting of stereo method to SC */
129 int    edge_stereo_method(void)
130 {
131 
132     return stereo_method;
133 }
134 
135 
136 /********** Callback functions **********/
137 
138 static void rank_proc(void)
139 {
140   Imrect *left_im = left_image_get(), *right_im = right_image_get();
141   Tv *tvl = NULL, *tvr = NULL;
142 
143   if ((tvl = left_tv_get()) != NULL && (use_TV_ROIs == true))
144     {
145       left_im = im_subim(left_im, tv_get_im_roi(tvl));
146       left_image_set(left_im);
147     }
148 
149   if ((tvr = right_tv_get()) != NULL && (use_TV_ROIs == true))
150     {
151       right_im = im_subim(right_im, tv_get_im_roi(tvr));
152       right_image_set(right_im);
153     }
154 
155   left_image_set(im_rank(left_image_get(), kernel, noise));
156   right_image_set(im_rank(right_image_get(), kernel, noise));
157 }
158 
159 void stereo_rectify_proc(void)
160 {
161   Imrect *left_im = left_image_get(), *right_im = right_image_get();
162   Tv *tv;
163   Imrect *im;
164   Parcam *pcam;
165   double (*interp_func)(Imrect *image, float x, float y,
166                         float *px, float *py);
167 
168   pcam = pcam_get();
169 
170   if (left_im == NULL || right_im == NULL || pcam == NULL)
171     return;
172 
173   if (interp == sinc5_interp)
174     interp_func = im_get_sinc5interpf;
175   else if (interp == sinc3_interp)
176     interp_func = im_get_sinc3interpf;
177   else
178     interp_func = im_get_quadinterpf;
179 
180   tv = left_tv();
181   if ((tv != NULL) && (use_TV_ROIs == true))
182     im = imf_left_rectify(left_im, roi_inter(tv_get_im_roi(tv),
183                                              left_im->region),
184                           pcam, interp_func);
185   else
186     im = imf_left_rectify(left_im, NULL, pcam, interp_func);
187   left_image_set(im);
188 
189   tv = right_tv();
190   if ((tv != NULL) && (use_TV_ROIs == true))
191     im = imf_right_rectify(right_im, roi_inter(tv_get_im_roi(tv),
192                                                right_im->region),
193                            pcam, interp_func);
194   else
195     im = imf_right_rectify(right_im, NULL, pcam, interp_func);
196   right_image_set(im);
197 
198   stereo_method = STEREO_SC;
199 }
200 
201 /**** canny callback ****/
202 
203 void mono_canny_proc(void)
204 {
205     Tv     *tv;
206     Imrect *im;
207 
208     sigma = (imf_diffx_noise( mono_image_get(), tv_get_im_roi( mono_tv_get() ) )
209           + imf_diffy_noise( mono_image_get(), tv_get_im_roi( mono_tv_get() ) )) / 2.0;
210 
211 
212     tv = mono_tv_get();
213     im = mono_image_get();
214     if (tv != NULL && tv->tv_screen != NULL)    /* get roi from tv */
215         im = im_subim(im, tv_get_im_roi(tv));
216     if (feature_type == 0)
217         mono_edges_set(canny(im, sigma, precision, low_edge_thres));
218     else if (feature_type == 1)
219         mono_edges_set(var_canny(im, 0.718*sigma, precision, low_edge_thres));
220     else if (feature_type == 2)
221         mono_edges_set(iso_canny(im, sigma, precision, low_edge_thres, -mid_point));
222     else 
223         mono_edges_set(im_canny(im, sigma, precision, low_edge_thres));
224     canny_link(mono_edges_get(), up_edge_thres, len_thres, simple_link);
225     if (tv != NULL && tv->tv_screen != NULL)
226         im_free(im);
227     tv_edges_conn(tv, mono_edges_get());
228     tv_flush(tv);
229     mono_geom_set((List *) NULL);       /* now out of date */
230 }
231 
232 static unsigned int block_label = 0;    /* no block is labeled 0 */
233 
234 static void stereo_canny_proc(void)
235 {
236     Tv     *tv;
237     Imrect *im;
238 
239     left_edges_null();
240     right_edges_null();
241     ralloc_free_blocked(block_label);   /* actually free up majority */
242     block_label = ralloc_new_blocked(1024);
243     (void) ralloc_end_blocked();
244 
245     tv = left_tv_get();
246     im = left_image_get();
247     if (tv != NULL && tv->tv_screen != NULL)    /* get roi from tv */
248         im = im_subim(im, tv_get_im_roi(tv));
249     (void) ralloc_start_blocked(block_label);
250     if (feature_type == 0)
251         left_edges_set(canny(im, sigma, precision, low_edge_thres));
252     else if (feature_type == 1)
253         left_edges_set(var_canny(im, 0.718*sigma, precision, low_edge_thres));
254     else if (feature_type ==2)
255         left_edges_set(iso_canny(im, sigma, precision, low_edge_thres, -mid_point));
256     else
257         left_edges_set(im_canny(im, sigma, precision, low_edge_thres));
258     (void) ralloc_end_blocked();
259     canny_link(left_edges_get(), up_edge_thres, len_thres, simple_link);
260     if (tv != NULL && tv->tv_screen != NULL)
261         im_free(im);
262     tv_edges_conn(tv, left_edges_get());
263     tv_flush(tv);
264 
265     tv = right_tv_get();
266     im = right_image_get();
267     if (tv != NULL && tv->tv_screen != NULL)    /* get roi from tv */
268         im = im_subim(im, tv_get_im_roi(tv));
269     (void) ralloc_start_blocked(block_label);
270     if (feature_type == 0)
271         right_edges_set(canny(im, sigma, precision, low_edge_thres));
272     else if (feature_type == 1)
273         right_edges_set(var_canny(im, 0.718*sigma, precision, low_edge_thres));
274     else if (feature_type == 2)
275         right_edges_set(iso_canny(im, sigma, precision, low_edge_thres, -mid_point));
276     else
277         right_edges_set(im_canny(im, sigma, precision, low_edge_thres));
278 
279     (void) ralloc_end_blocked();
280     canny_link(right_edges_get(), up_edge_thres, len_thres, simple_link);
281     if (tv != NULL && tv->tv_screen != NULL)
282         im_free(im);
283     tv_edges_conn(tv, right_edges_get());
284     tv_flush(tv);
285 
286     Disp = 0;
287     edges_rectified = false;
288     left_geom_set((List *) NULL);       /* now out of date */
289     right_geom_set((List *) NULL);      /* now out of date */
290 }
291 
292 static void canny_proc(void)
293 {
294     if (stereo_images)
295         stereo_canny_proc();
296     else
297         mono_canny_proc();
298 }
299 
300 /**** rectify edges callback ****/
301 
302 static void rectify_edges_proc(void)
303 {
304     Imrect *left_er;
305     Imrect *right_er;
306     Camera *lcam;
307     Camera *rcam;
308     Parcam *pcam;
309     Vec2    cleft =
310     {Vec2_id};
311     Vec2    cright =
312     {Vec2_id};
313 
314     if (!stereo_images)
315     {
316         error("edge tool: not in stereo mode", warning);
317         return;
318     }
319     if (edges_rectified == true)
320     {
321         error("edge tool: edges already rectified", warning);
322         return;
323     }
324     left_er = left_edges_get();
325     right_er = right_edges_get();
326     lcam = left_camera();
327     rcam = right_camera();
328 
329     if (left_er == NULL || right_er == NULL)
330     {
331         error("no edges", warning);
332         return;
333     }
334     if (lcam == NULL || rcam == NULL)
335     {
336         error("no camera data", warning);
337         return;
338     }
339     pcam = pcam_get();
340     (void) ralloc_start_blocked(block_label);
341     er_apply_to_all_edges(left_er, edge_save_pos_prop, (void *) IMPOS);
342     er_apply_to_all_edges(right_er, edge_save_pos_prop, (void *) IMPOS);
343     if (lcam->correct_func != NULL)
344         er_correct(left_er, lcam);
345     if (rcam->correct_func != NULL)
346         er_correct(right_er, rcam);
347     er_rectify(left_er, pcam->rect1);
348     er_rectify(right_er, pcam->rect2);
349     (void) ralloc_end_blocked();
350     cleft = rectify_pos(pcam->rect1, vec2(lcam->cx, lcam->cy));
351     cright = rectify_pos(pcam->rect2, vec2(rcam->cx, rcam->cy));
352     Disp = vec2_x(cright) - vec2_x(cleft);
353     edges_rectified = true;
354     stereo_method = STEREO_PMF;
355 }
356 
357 /**** derectify edges callback ****/
358 
359 static void derectify_edges_proc(void)
360 {
361     Imrect *left_er;
362     Imrect *right_er;
363     Parcam *pcam;
364 
365     if (!stereo_images)
366     {
367         error("edge tool: not in stereo mode", warning);
368         return;
369     }
370     if (edges_rectified == false)
371     {
372         error("edge tool: edges not rectified", warning);
373         return;
374     }
375     left_er = left_edges_get();
376     right_er = right_edges_get();
377 
378     if (left_er == NULL || right_er == NULL)
379     {
380         error("no edges", warning);
381         return;
382     }
383     pcam = pcam_get();
384     if (pcam == NULL)
385     {
386         error("no camera data", warning);
387         return;
388     }
389     er_apply_to_all_edges(left_er, edge_get_pos_prop, (void *) IMPOS);
390     er_apply_to_all_edges(right_er, edge_get_pos_prop, (void *) IMPOS);
391 
392     /* old de-rectification without distortion correction NAT 12/5/92
393      * er_derectify(left_er, pcam->derect1); er_derectify(right_er,
394      * pcam->derect2); */
395     edges_rectified = false;
396 }
397 
398 /**** geom2 callback ****/
399 
400 static void stereo_geom2_proc(void)
401 {
402     Imrect *er;
403     Tv     *tv;
404     List   *strings;
405     double  low_th, up_th;
406 
407     if ((er = left_edges_get()) == NULL)
408         return;
409 
410     low_th = (edges_rectified == true) ? low_fit_thres * rect_scale : low_fit_thres;
411     up_th = (edges_rectified == true) ? up_fit_thres * rect_scale : up_fit_thres;
412 
413     strings = (List *) prop_get(er->props, STRING);
414 
415     switch (approx_type)
416     {
417     case POLY_PROX:
418         strings = poly_strings(strings, low_th);
419         break;
420     case LINEAR_PROX:
421         strings = linear_strings(strings, low_th);
422         break;
423     case CONIC_PROX:
424         conic_filter_set(conic_bckf);   /* set bias corrected filter */
425         strings = conic_strings(strings, sample, low_th, up_th, max_div);
426         break;
427     case LINEAR_CONIC_PROX:
428         conic_filter_set(conic_bckf);   /* set bias corrected filter */
429         strings = linear_strings(strings, low_th);
430         poly_strings_find_conics(strings, sample, low_th, up_th, max_div);
431         break;
432     }
433 
434     if (options & JOIN)
435     {
436         Imregion *roi;
437 
438         if (edges_rectified == true)
439         {
440             Rindex *sx = (Rindex *) prop_get(er->props, SINDEX);
441 
442             if (sx != NULL)
443                 roi = roi_copy(sx->region);
444             else
445                 roi = er_bounding_region(er);
446             roi->lx -= 10;
447             roi->ly -= 10;
448             roi->ux += 10;
449             roi->uy += 10;
450         } else
451             roi = roi_copy(er->region);
452 
453         strings = conic_join(strings, roi, conf_thres, low_th, up_th, max_div);
454         rfree((void *) roi);
455     }
456     if (edges_rectified == true)
457     {
458         Parcam *pcam = pcam_get();
459 
460         reclist_list_apply(strings, geom_add_image_pos_prop, 0, (void *) &pcam->derect1);
461     }
462     left_geom_set(strings);
463     tv = left_tv_get();
464     tv_repaint(tv);
465     reclist_list_draw(tv, strings, 0, geom_col_draw, NULL);
466 }
467 
468 static void mono_geom2_proc(void)
469 {
470     Imrect *er;
471     Tv     *tv;
472     List   *strings;
473     double  low_th, up_th;
474 
475     if ((er = mono_edges_get()) == NULL)
476         return;
477 
478     low_th = low_fit_thres;
479     up_th = up_fit_thres;
480 
481     if((strings = (List *) prop_get(er->props, STRING))==NULL)
482     {
483         er_find_edge_strings(er);
484         er_rm_edges(er, EDGE_GET_CONN_MASK, EDGE_NOLINK);
485         er_edge_strings_thres(er, len_thres, up_edge_thres);
486         er_set_row_index(er);
487         strings = (List *) prop_get(er->props, STRING);
488     }
489 
490     switch (approx_type)
491     {
492     case POLY_PROX:
493         strings = poly_strings(strings, low_th);
494         break;
495     case LINEAR_PROX:
496         strings = linear_strings(strings, low_th);
497         break;
498     case CONIC_PROX:
499         conic_filter_set(conic_bckf);   /* set bias corrected filter */
500         strings = conic_strings(strings, sample, low_th, up_th, max_div);
501         break;
502     case LINEAR_CONIC_PROX:
503         conic_filter_set(conic_bckf);   /* set bias corrected filter */
504         strings = linear_strings(strings, low_th);
505         poly_strings_find_conics(strings, sample, low_th, up_th, max_div);
506         break;
507     }
508 
509     if (options & JOIN)
510         strings = conic_join(strings, er->region, conf_thres, low_th, up_th, max_div);
511 
512     mono_geom_set(strings);
513     tv = mono_tv_get();
514     tv_repaint(tv);
515     reclist_list_draw(tv, strings, 0, geom_col_draw, NULL);
516 }
517 
518 static void geom2_proc(void)
519 {
520     if (stereo_images)
521         stereo_geom2_proc();
522     else
523         mono_geom2_proc();
524 }
525 
526 /**** Pick function callbacks ****/
527 
528 static void mono_edge_pick_proc(Tv_pick(*func) ( /* ??? */ ))
529 {
530     Tv     *tv = mono_tv_get();
531 
532     tv_set_pick(tv, (*func) ());
533     (void) tv_set_activity(tv, PICK);
534 }
535 
536 static void left_edge_pick_proc(Tv_pick(*func) ( /* ??? */ ))
537 {
538     Tv     *tv = left_tv_get();
539 
540     tv_set_pick(tv, (*func) ());
541     (void) tv_set_activity(tv, PICK);
542 }
543 
544 static void right_edge_pick_proc(Tv_pick(*func) ( /* ??? */ ))
545 {
546     Tv     *tv = right_tv_get();
547 
548     tv_set_pick(tv, (*func) ());
549     (void) tv_set_activity(tv, PICK);
550 }
551 
552 static void left_geom_pick_proc(Tv_pick(*func) ( /* ??? */ ))
553 {
554     Tv     *tv = left_tv_get();
555 
556     tv_set_pick(tv, (*func) ());
557     (void) tv_set_activity(tv, PICK);
558 }
559 
560 /**** Mouse function callbacks ****/
561 
562 static void mono_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
563 {
564     Tv     *tv = mono_tv_get();
565 
566     tv_set_mouse(tv, (*func) ());
567     (void) tv_set_activity(tv, MOUSE);
568 }
569 
570 static void left_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
571 {
572     Tv     *tv = left_tv_get();
573 
574     tv_set_mouse(tv, (*func) ());
575     (void) tv_set_activity(tv, MOUSE);
576 }
577 
578 static void right_mouse_proc(Tv_mouse(*func) ( /* ??? */ ))
579 {
580     Tv     *tv = right_tv_get();
581 
582     tv_set_mouse(tv, (*func) ());
583     (void) tv_set_activity(tv, MOUSE);
584 }
585 
586 /********** Choice item callbacks **********/
587 
588 /**** Image choice callback ****/
589 
590 static void image_choice_proc(int val)
591 {
592     stereo_images = val;
593 }
594 
595 /**** disparity range choice callback ****/
596 
597 /*
598 static void disp_range_choice_proc(int val)
599 {
600     use_disp_histogram = val;
601 }
602 */
603 
604 /**** geom2 choice callback ****/
605 
606 static void geom2_choice_proc(int val)
607 {
608     approx_type = val;
609 }
610 
611 /**** geom2 option callback ****/
612 
613 static void geom2_option_proc(int val)
614 {
615     options = val;
616 }
617 
618 /********** Paramter dialog callbacks **********/
619 
620 void   *tw_fglobal();
621 void   *tw_iglobal();
622 void   *tw_ivalue();
623 
624 /**** Edge parameter dialog box callback ****/
625 
626 static void *sig, *pre, *th1, *th2, *lth;       /* callback handles */
627 
628 static void edge_param_refresh(void)
629 {
630      
631     (void) tw_fglobal_reset(sig);
632     (void) tw_fglobal_reset(pre);
633     (void) tw_fglobal_reset(th1);
634     (void) tw_fglobal_reset(th2);
635     (void) tw_iglobal_reset(lth);
636 }
637 
638 static void edge_choice_proc(int val)
639 {
640     feature_type = val;
641 }
642 
643 static void link_choice_proc(int val)
644 {
645     if ( val == 0)
646         simple_link = true;    
647     else
648         simple_link = false;
649 }
650 
651 
652 void edge_param_dialog(void)
653 {
654     static void *dialog = NULL;
655 
656     if (dialog)
657     {
658         tw_show_dialog(dialog);
659         return;
660     }
661     dialog = tw_dialog("Edge Parameters");
662 
663     tw_choice("Feature:",
664            edge_choice_proc, 0, "step", "var", "iso", "image", NULL);
665     tw_help_button("edge_tool_parms");
666     tw_newrow();
667     sig = tw_fglobal("Sigma        :", &sigma, 12);
668     tw_newrow();
669     pre = tw_fglobal("Precision    :", &precision, 12);
670     tw_newrow();
671     th1 = tw_fglobal("Lower Thres  :", &low_edge_thres, 12);
672     tw_newrow();
673     th2 = tw_fglobal("Upper Thres  :", &up_edge_thres, 12);
674     tw_newrow();
675     lth = tw_iglobal("Length Thres :", &len_thres, 12);
676     tw_newrow();
677     tw_choice("Linkage:", link_choice_proc, 1, "simple", "complex", NULL);
678     tw_newrow();
679     tw_fglobal("Iso value :", &mid_point, 12);
680 
681     tw_end_dialog();
682 }
683 
684 /**** Stereo paramter dialog callback ****/
685 
686 static void stereo_param_dialog(void)
687 {
688     static void *dialog = NULL;
689 
690     if (dialog)
691     {
692         tw_show_dialog(dialog);
693         return;
694     }
695     dialog = tw_dialog("Rectify Parameters");
696 
697     tw_newrow();
698     rsc = tw_fglobal("Rect scale :", &rect_scale, 20);
699     tw_fglobal("  noise:", &noise, 10);
700 
701     tw_end_dialog();
702 }
703 
704 /**** Geom paramter dialog callback ****/
705 
706 static void *ct, *lft, *uft, *ft3;
707 
708 static void geom_param_refresh(void)
709 {
710     (void) tw_fglobal_reset(ct);
711     (void) tw_fglobal_reset(lft);
712     (void) tw_fglobal_reset(uft);
713     (void) tw_fglobal_reset(ft3);
714 }
715 
716 static void geom_param_dialog(void)
717 {
718     static void *dialog = NULL;
719 
720     if (dialog)
721     {
722         tw_show_dialog(dialog);
723         return;
724     }
725     dialog = tw_dialog("Geom Parameters");
726 
727     ct = tw_fglobal("Confidence thres :", &conf_thres, 20);
728     tw_newrow();
729     lft = tw_fglobal("Low fit thres :", &low_fit_thres, 20);
730     tw_newrow();
731     uft = tw_fglobal("Up  fit thres :", &up_fit_thres, 20);
732 
733     tw_end_dialog();
734 }
735 
736 void    edge_tool_refresh(void)
737 {
738     edge_param_refresh();
739     geom_param_refresh();
740 }
741 
742 /********** Tool creation **********/
743 
744 void    edge_tool(int x, int y)
745 {
746     static void *tool = NULL;
747 
748     if (tool)
749     {
750         tw_show_tool(tool);
751         return;
752     }
753     tool = tw_tool("Edge Geom Tool", x, y);
754 
755     tw_menubar("Pick :",
756                "Mono",
757                "null", mono_edge_pick_proc, null_pick,
758                "edge", mono_edge_pick_proc, mono_print,
759                NULL,
760                "Left",
761                "null", left_edge_pick_proc, null_pick,
762                "edge", left_edge_pick_proc, left_edge_print,
763                NULL,
764                "Geoml",
765                "print", left_geom_pick_proc, left_geom_print,
766                "choose", left_geom_pick_proc, left_geom_choose,
767                "delete", left_geom_pick_proc, left_geom_delete,
768                NULL,
769                "Right",
770                "null", right_edge_pick_proc, null_pick,
771                "edge", right_edge_pick_proc, right_edge_print,
772                NULL,
773                NULL);
774 
775     tw_newrow();
776     tw_menubar("Mouse:",
777                "Mono",
778                "null", mono_mouse_proc, null_mouse,
779                NULL,
780                "Left",
781                "null", left_mouse_proc, null_mouse,
782                "epi", left_mouse_proc, left_epi_mouse,
783                "rast", left_mouse_proc, left_raster_mouse,
784                NULL,
785                "Right",
786                "null", right_mouse_proc, null_mouse,
787                "epi", right_mouse_proc, right_epi_mouse,
788                "rast", right_mouse_proc, right_raster_mouse,
789                NULL,
790                NULL);
791 
792     tw_help_button("edge_geom_tool");
793     tw_newrow();
794     tw_choice("Image Select:",
795            image_choice_proc, 1, "mono image", "stereo images", NULL);
796 
797     tw_newrow();
798     tw_choice("2D Geom Fit:",
799     geom2_choice_proc, 3, "poly", "linear", "conic", "lin/con", NULL);
800 
801     tw_newrow();
802     tw_check("2D Options :", geom2_option_proc, 0, "join", NULL);
803 
804     tw_newrow();
805     tw_button("im rank", rank_proc, NULL);
806     tw_button("im rectify", stereo_rectify_proc, NULL);
807     tw_newrow();
808     tw_button("canny", canny_proc, NULL);
809     tw_button("edge rectify", rectify_edges_proc, NULL);
810     tw_button("edge derect", derectify_edges_proc, NULL);
811 
812     tw_newrow();
813     tw_button("geom2", geom2_proc, NULL);
814 
815     tw_newrow();
816     tw_button("Edge Params", edge_param_dialog, NULL);
817     tw_button("Rectify Params", stereo_param_dialog, NULL);
818     tw_button("Geom Params", geom_param_dialog, NULL);
819 
820     tw_end_tool();
821 }
822 

~ [ 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.