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

Linux Cross Reference
Tina4/src/tools/corner/cnr_pick.c

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

  1 /**@(#)
  2 **/
  3 #include <stdio.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/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/toolsfuncs.h>
 16 
 17 static int SEARCH_RADIUS = 25;
 18 static Edgel *picked_lmatch = NULL;
 19 static Edgel *picked_rmatch = NULL;
 20 
 21 void   *left_pick_closest_corner(Tv * tv, Ipos pos, int *type)
 22 {
 23     Imrect *er = left_corners_get();
 24     int     r, c;
 25     Vec2    v = {Vec2_id};
 26 
 27     *type = CORNER;
 28     v = tv_backproj2(tv, pos);
 29     r = tina_int(vec2_y(v));
 30     c = tina_int(vec2_x(v));
 31     picked_lmatch = er_closest(er, r, c, SEARCH_RADIUS, (void *(*) ()) NULL,
 32                                NULL);
 33     return ((void *) picked_lmatch);
 34 }
 35 
 36 void   *right_pick_closest_corner(Tv * tv, Ipos pos, int *type)
 37 {
 38     Imrect *er = right_corners_get();
 39     int     r, c;
 40     Vec2    v = {Vec2_id};
 41 
 42     *type = CORNER;
 43     v = tv_backproj2(tv, pos);
 44     r = tina_int(vec2_y(v));
 45     c = tina_int(vec2_x(v));
 46 
 47     picked_rmatch = er_closest(er, r, c, SEARCH_RADIUS, (void *(*) ()) NULL,
 48                                NULL);
 49 
 50     return ((void *) picked_rmatch);
 51 }
 52 
 53 /* ARGSUSED Quieten Lint */
 54 void    print_corners(Tv * tv, List * picklist)
 55 {
 56     List   *p,*left_matches,*right_matches;
 57     Match *lmatch,*rmatch;
 58 
 59     for (p = picklist; p != NULL; p = p->next)
 60         edge_format((Edgel *) p->to);
 61     if (picked_lmatch!=NULL && picked_rmatch!=NULL)
 62     {
 63         lmatch = match_alloc(CORNER);
 64         lmatch->weight = 1.0;
 65         lmatch->to1 = (void *) picked_lmatch;
 66         lmatch->to2 = (void *) picked_rmatch;
 67         add_match_to_props(picked_lmatch, (void *) lmatch, MLIST);
 68 
 69 
 70         rmatch = match_alloc(CORNER);
 71         rmatch->weight = 1.0;
 72         rmatch->to1 = (void *) picked_lmatch;
 73         rmatch->to2 = (void *) picked_rmatch;
 74         add_match_to_props(picked_rmatch, (void *) rmatch, MLIST);
 75 
 76         left_matches = (List *) prop_get(picked_lmatch->props, MLIST);
 77         right_matches = (List *) prop_get(picked_rmatch->props, MLIST);
 78         left_matches->type = FIXED_MATCH;
 79         right_matches->type = FIXED_MATCH;
 80         picked_lmatch = NULL;
 81         picked_rmatch = NULL;
 82     }
 83 }
 84 
 85 void    pick_corner_draw(Tv * tv, Edgel * edge, int type)
 86 {
 87     if (edge == NULL || type != CORNER)
 88         return;
 89 
 90     tv_cross2(tv, edge->pos, 7);
 91 }
 92 
 93 /* ARGSUSED Quieten Lint */
 94 void    print_cnrmatch(Match *match)
 95 {
 96     Transform3 rect_unrect = {Transform3_id};
 97     Parcam *pcam;
 98     Edgel  *edgel;
 99     Edgel  *edger;
100     Vec2   *rectl = NULL;
101     Vec2   *rectr = NULL;
102     Vec3    disp = {Vec3_id};
103     Vec3    pos = {Vec3_id};
104     Matrix         *left_patch, *right_patch;
105     int             i, j;
106     char    temp[128];
107 
108     if (match == NULL)
109         return;
110     edgel = (Edgel *) match->to1;
111     edger = (Edgel *) match->to2;
112     if (edgel == NULL || edger == NULL)
113         return;
114     edge_format(edgel);
115     edge_format(edger);
116 /*
117     rectl = (Vec2 *) prop_get(edgel->props, RECTPOS);
118     rectr = (Vec2 *) prop_get(edger->props, RECTPOS);
119     if (rectl && rectr)
120     {
121         (void) sprintf(temp, " rectified positions : %3.1f %3.1f %3.1f %3.1f \n",
122               rectl->el[0], rectl->el[1], rectr->el[0], rectr->el[1]);
123         format(temp);
124         disp.el[0] = rectl->el[0];
125         disp.el[1] = (rectl->el[1] + rectr->el[1]) / 2.0;
126         disp.el[2] = rectr->el[0] - rectl->el[0];
127         pos = vec3_par_proj_3d(disp);
128         (void) sprintf(temp, "rectified 3d location :  %3.1f %3.1f %3.1f \n",
129                        pos.el[0], pos.el[1], pos.el[2]);
130         format(temp);
131         pcam = pcam_get();
132         rect_unrect =           
133 */
134 /* trans3_prod(*(pcam->cam1->transf), */
135 /*
136             trans3_inverse(*(pcam->rcam1->transf));
137         pos = trans3_pos(rect_unrect, pos);
138         (void) sprintf(temp, "world 3d location :  %3.1f %3.1f %3.1f \n",
139                        pos.el[0], pos.el[1], pos.el[2]);
140         format(temp);
141     }
142 */
143     (void) sprintf(temp, "match->weight = %f\n", match->weight);
144     format(temp);
145     if ((left_patch = (Matrix *) prop_get(edgel->props, PATCH)) == NULL)
146         if ((left_patch=(Matrix *)add_patch_to_props(edgel,left_image_get(),3.0))==NULL)
147             return;
148     if ((right_patch = (Matrix *) prop_get(edger->props, PATCH)) == NULL)
149          if ((right_patch=(Matrix *)add_patch_to_props(edger,right_image_get(),3.0))==NULL)
150             return;;
151 
152     for (i=0;i<5;i++)
153     {
154         sprintf(temp," %1.4f %1.4f %1.4f %1.4f %1.4f \n",
155                 left_patch->el.float_v[i][0],
156                 left_patch->el.float_v[i][1],
157                 left_patch->el.float_v[i][2],
158                 left_patch->el.float_v[i][3],
159                 left_patch->el.float_v[i][4]);
160         format(temp);
161     }
162     for (i=0;i<5;i++)
163     {
164         sprintf(temp," %1.4f %1.4f %1.4f %1.4f %1.4f \n",
165                right_patch->el.float_v[i][0],
166                right_patch->el.float_v[i][1],
167                right_patch->el.float_v[i][2],
168                right_patch->el.float_v[i][3],
169                right_patch->el.float_v[i][4]);
170         format(temp);
171     }
172 }
173 
174 void   print_corner_match(Tv * tv, List * picklist)
175 {
176     List   *matchlist;
177     Match  *match;
178 
179     if (picklist == NULL || (matchlist = picklist->to) == NULL)
180     return;
181 
182     match = matchlist->to;
183     print_cnrmatch(match);
184 }
185 
186 void   *mono_pick_corner_matchlist(Tv * tv, Ipos pos, int *type)
187 {
188     Imrect *er = mono_corners_get();
189     int     r, c;
190     Vec2    v = {Vec2_id};
191     int     data = BACKTEMP;
192     void   *get_matches_list();
193 
194     *type = LIST;
195     v = tv_backproj2(tv, pos);
196     r = tina_int(vec2_y(v));
197     c = tina_int(vec2_x(v));
198     return ((void *) er_closest(er, r, c, SEARCH_RADIUS, get_matches_list, (void *) &data));
199 }
200 
201 void   *left_pick_corner_matchlist(Tv * tv, Ipos pos, int *type)
202 {
203     Imrect *er = left_corners_get();
204     int     r, c;
205     Vec2    v = {Vec2_id};
206     int     data = MLIST;
207     void   *get_mlist();
208 
209     *type = LIST;
210     v = tv_backproj2(tv, pos);
211     r = tina_int(vec2_y(v));
212     c = tina_int(vec2_x(v));
213     return ((void *) er_closest(er, r, c, SEARCH_RADIUS, get_matches_list, (void *) &data));
214 }
215 
216 void   *right_pick_corner_matchlist(Tv * tv, Ipos pos, int *type)
217 {
218     Imrect *er = right_corners_get();
219     int     r, c;
220     Vec2    v = {Vec2_id};
221     int     data = MLIST;
222     void   *get_mlist();
223 
224     *type = LIST;
225     v = tv_backproj2(tv, pos);
226     r = tina_int(vec2_y(v));
227     c = tina_int(vec2_x(v));
228     return ((void *) er_closest(er, r, c, SEARCH_RADIUS, get_matches_list, (void *) &data));
229 }
230 
231 static void pick_mlist_cordraw(Tv * tv, List * mlist, int type)
232 {
233     Tv     *tvl = left_tv();
234     Tv     *tvr = right_tv();
235     List   *lptr;
236     Match  *match;
237  
238     if (mlist == NULL || type != LIST)
239         return;
240 
241     if (tv == tvl)
242     {
243          tv_set_overlay(tvr);
244          match = (Match *)mlist->to;
245          tv_cross2(tvl, ((Edgel *) match->to1)->pos, 7);
246          for (lptr = mlist; lptr != NULL; lptr = lptr->next)
247          {
248               match = (Match *) lptr->to;
249               tv_cross2(tvr, ((Edgel *) match->to2)->pos, 7);
250          }
251          tv_reset_draw(tvr);
252     }
253     else
254     {
255          tv_set_overlay(tvl);
256          match = (Match *)mlist->to;
257          tv_cross2(tvr, ((Edgel *) match->to2)->pos, 7);
258          for (lptr = mlist; lptr != NULL; lptr = lptr->next)
259          {
260               match = (Match *) lptr->to;
261               tv_cross2(tvl, ((Edgel *) match->to1)->pos, 7);
262          }
263          tv_reset_draw(tvl);
264     }
265 }
266 
267 static void mono_pick_mlist_cordraw(Tv * tv, List * mlist, int type)
268 {
269     List   *lptr;
270     Match  *match;
271  
272     if (mlist == NULL || type != LIST)
273         return;
274 
275     for (lptr = mlist; lptr != NULL; lptr = lptr->next)
276     {
277          match = (Match *) lptr->to;
278          tv_cross2(tv, ((Edgel *) match->to2)->pos, 7);
279     }
280     tv_reset_draw(tv);
281     tv_set_color(tv, green);
282     match = (Match *)mlist->to;
283     tv_cross2(tv, ((Edgel *) match->to1)->pos, 7);
284     tv_set_overlay(tv);
285 }
286 
287 
288 
289 Tv_pick mono_corner_matches(void)
290 {
291     return (pick_define(
292                         PICK_CLOSEST, mono_pick_corner_matchlist,
293                         PICK_DRAW, mono_pick_mlist_cordraw,
294                         PICK_REPAINT, false,
295                         PICK_FUNC, print_corner_match,
296                         NULL));
297 
298 }
299 
300 Tv_pick left_corner_matches(void)
301 {
302     return (pick_define(
303                         PICK_CLOSEST, left_pick_corner_matchlist,
304                         PICK_DRAW, pick_mlist_cordraw,
305                         PICK_REPAINT, false,
306                         PICK_FUNC, print_corner_match,
307                         NULL));
308 }
309 
310 Tv_pick right_corner_matches(void)
311 {
312     return (pick_define(
313                         PICK_CLOSEST, right_pick_corner_matchlist,
314                         PICK_DRAW, pick_mlist_cordraw,
315                         PICK_REPAINT, false,
316                         PICK_FUNC, print_corner_match,
317                         NULL));
318 }
319 
320 Tv_pick left_print_cor(void)
321 {
322     void   *left_pick_closest_corner(Tv * tv, Ipos pos, int *type);
323     void    pick_corner_draw(Tv * tv, Edgel * edge, int type);
324     void    print_corners(Tv * tv, List * picklist);
325 
326     return (pick_define(
327                         PICK_CLOSEST, left_pick_closest_corner,
328                         PICK_DRAW, pick_corner_draw,
329                         PICK_REPAINT, false,
330                         PICK_FUNC, print_corners,
331                         NULL));
332 }
333 
334 Tv_pick right_print_cor(void)
335 {
336     void   *right_pick_closest_corner(Tv * tv, Ipos pos, int *type);
337     void    pick_corner_draw(Tv * tv, Edgel * edge, int type);
338     void    print_corners(Tv * tv, List * picklist);
339 
340     return (pick_define(
341                         PICK_CLOSEST, right_pick_closest_corner,
342                         PICK_DRAW, pick_corner_draw,
343                         PICK_REPAINT, false,
344                         PICK_FUNC, print_corners,
345                         NULL));
346 }
347 

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