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

Linux Cross Reference
Tina4/tinatool/skeleton.c

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

  1 #include <stdio.h>
  2 #include <sys/param.h>
  3 #include <string.h>
  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/file.h>
 11 #include <tina/filefuncs.h>
 12 #include <tina/file_gen.h>
 13 #include <tina/tv.h>
 14 #include <tina/tvfuncs.h>
 15 #include <tina/toolsfuncs.h>
 16 #include <tina/tw_Xfuncs.h>
 17 
 18 
 19 static int stereo_images = 1;
 20 
 21 /* interactive global variables for access via dialog box */
 22 static double sigma = 2.0;
 23 static double precision = 0.001;
 24 
 25 static void     mono_skeleton_proc(void)
 26 {
 27     Tv             *tv;
 28     Imrect         *im;
 29 
 30     tv = mono_tv();
 31     im = mono_image();
 32     if (tv != NULL)     /* get roi from tv */
 33         im = im_subim(im, tv_get_im_roi(tv));
 34     im = imf_grad_h(im);
 35     mono_image_set(im);
 36     tv_flush(tv);
 37 }
 38 
 39 void            stereo_skeleton_proc(void)
 40 {
 41     Imrect         *left_im=left_image_get(), *right_im=right_image_get();
 42     Tv             *tv;
 43     Imrect         *im;
 44     Imrect         *er;
 45     Vec2            ul, lr;
 46     Imregion       *roi;
 47     Imrect         *stored_left_corners(), *stored_right_corners();
 48 
 49     if (left_im == NULL || right_im == NULL)
 50         return;
 51 
 52     tv = left_tv();
 53     im = left_image();
 54     if (tv != NULL) /* get roi from tv */
 55        im = im_subim(im, tv_get_im_roi(tv));
 56     im = imf_grad_h(im);
 57     left_image_set(im);
 58     tv_flush(tv);
 59 
 60     tv = right_tv();
 61     im = right_image();
 62     if (tv != NULL) /* get roi from tv */
 63         im = im_subim(im, tv_get_im_roi(tv));
 64     im = imf_grad_h(im);
 65     right_image_set(im);
 66     tv_flush(tv);
 67 }
 68 
 69 static void     update_pcam(void)
 70 {
 71     Camera         *lcam, *rcam;
 72     Parcam         *pcam_get();
 73 
 74     lcam = left_camera();
 75     rcam = right_camera();
 76 
 77     if (lcam == NULL || rcam == NULL)
 78     {
 79         error("no camera data", non_fatal);
 80         return;
 81     }
 82 
 83     pcam_set(parcam_make(lcam, rcam, CAMERA_PHYSICAL));
 84 }
 85 
 86 /**** Image choice callback ****/
 87 
 88 static void     image_choice_proc(int value)
 89 {
 90     switch (value)
 91     {
 92       case 0:
 93         stereo_images = 1;
 94         break;
 95       case 1:
 96         stereo_images = 0;
 97         break;
 98     }
 99 }
100 
101 /** Pick function callbacks **/
102 
103 static void     mono_pick_proc(Tv_pick(*func) ())
104 {
105     tv_set_pick(mono_tv(), (*func) ());
106     tv_set_activity(mono_tv(), PICK);
107 }
108 
109 static void     left_pick_proc( Tv_pick(*func) ())
110 {
111     tv_set_pick(left_tv(), (*func) ());
112     tv_set_activity(left_tv(), PICK);
113 }
114 
115 static void     right_pick_proc(Tv_pick(*func) ())
116 {
117     tv_set_pick(right_tv(), (*func) ());
118     tv_set_activity(right_tv(), PICK);
119 }
120 
121 /** Mouse function callbacks **/
122 
123 static void     mono_mouse_proc(Tv_mouse(*func) ())
124 {
125     tv_set_mouse(mono_tv(), (*func) ());
126     tv_set_activity(mono_tv(), MOUSE);
127 }
128 
129 static void     left_mouse_proc(Tv_mouse(*func) ())
130 {
131     update_pcam();
132     tv_set_mouse(left_tv(), (*func) ());
133     tv_set_activity(left_tv(), MOUSE);
134 }
135 
136 static void     right_mouse_proc(Tv_mouse(*func) ())
137 {
138     update_pcam();
139     tv_set_mouse(right_tv(), (*func) ());
140     tv_set_activity(right_tv(), MOUSE);
141 }
142 
143 /*** Paramter dialog callbacks ***/
144 
145 static void     skeleton_param_dialog(void)
146 {
147     static void *dialog = NULL;
148 
149     if (dialog)
150     {
151         tw_show_dialog(dialog);
152         return;
153     }
154 
155     dialog = tw_dialog("Skeleton Parameters");
156 
157     tw_fglobal("sigma   :", &sigma, 20);
158     tw_newrow();
159     tw_fglobal("precision :", &precision, 20);
160 
161     tw_end_dialog();
162 }
163 
164 /********** Tool creation **********/
165 
166 void            skeleton_tool(int x, int y)
167 {
168     static void *tool = NULL;
169 
170     if (tool)
171     {
172         tw_show_tool(tool);
173         return;
174     }
175 
176     tool = (void *)tw_tool("Skeleton Tool", x, y);
177 
178     tw_menubar("Pick: ",
179         "mono",
180         "null", mono_pick_proc, null_pick,
181         NULL,
182         "left",
183         "null", left_pick_proc, null_pick,
184         NULL,
185         "right",
186         "null", right_pick_proc, null_pick,
187         NULL,
188         NULL);
189 
190     tw_label("          ");
191     tw_help_button("skeleton");
192 
193     tw_newrow();
194     tw_menubar("Mouse:",
195         "mono",
196         "null", mono_mouse_proc, null_mouse,
197         NULL,
198         "left",
199         "null", left_mouse_proc, null_mouse,
200         "epi", left_mouse_proc, left_epi_mouse,
201         "rast", left_mouse_proc, left_raster_mouse,
202         NULL,
203         "right",
204         "null", right_mouse_proc, null_mouse,
205         "epi", right_mouse_proc, right_epi_mouse,
206         "rast", right_mouse_proc, right_raster_mouse,
207         NULL,
208         NULL);
209 
210     tw_newrow();
211     tw_choice("Image Select:",
212         image_choice_proc, 0, "stereo images", "mono image", NULL);
213 
214     tw_newrow();
215     tw_button("mono", mono_skeleton_proc, NULL);
216     tw_button("stereo", stereo_skeleton_proc, NULL);
217     tw_newrow();
218     tw_button("Skeleton Params", skeleton_param_dialog, NULL);
219 
220     tw_end_tool();
221 }
222 

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