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

Linux Cross Reference
Tina4/src/vision/corner/s_mat_cnr.c

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

  1 /**@(#)
  2 **/
  3 #include <math.h>
  4 #include <tina/sys.h>
  5 #include <tina/sys_types.h>
  6 #include <tina/sysfuncs.h>
  7 #include <tina/math.h>
  8 #include <tina/mathfuncs.h>
  9 #include <tina/tina_types.h>
 10 #include <tina/vision.h>
 11 #include <tina/visionfuncs.h>
 12 
 13 static double disp, lowd, upd, width, correlate, uniqueness;
 14 static double asymetry = 0.85, range = 3.0;
 15 static Imrect *im_left, *im_right;      /* Defined in
 16                                          * corner/t_mat_cnr.c */
 17 
 18 void    stereo_corner_match(Imrect *im_left_new, Imrect *im_right_new,
 19        Imrect *left_er,Imrect *right_er,
 20        double new_disp, double new_lowd, double new_upd,
 21        double new_width, double new_corr, double new_unique, double new_asym)
 22 {
 23     Rindex *fxl;
 24     Rindex *fxr;
 25     Imregion left_search_func(Edgel * edgel);
 26     Imregion right_search_func(Edgel * edgel);
 27     Rindex *er_set_findex();
 28     int     type = MLIST;
 29     Vec2   *rectpos(Edgel * edgel);
 30 
 31     if (left_er == NULL || right_er == NULL)
 32     {
 33         error("no edge structure", non_fatal);
 34         return;
 35     }
 36     im_left = im_left_new;
 37     im_right = im_right_new;
 38 
 39     if (im_left == NULL || im_right == NULL)
 40     {
 41         error("no images", non_fatal);
 42         return;
 43     }
 44     if ((fxl = prop_get(left_er->props, ER_FINDEX)) == NULL)
 45         if ((fxl = er_set_findex(left_er, ER_FINDEX, rectpos)) == NULL)
 46             return;
 47     if ((fxr = prop_get(right_er->props, ER_FINDEX)) == NULL)
 48         if ((fxr = er_set_findex(right_er, ER_FINDEX, rectpos)) == NULL)
 49             return;
 50 
 51     disp = new_disp;
 52     lowd = new_lowd * left_er->width;
 53     upd = new_upd * left_er->width;
 54     width = new_width;
 55     correlate = new_corr;
 56     uniqueness = new_unique;
 57     asymetry = new_asym;
 58 
 59     rm_corner_matches(fxl, &type);
 60     get_corner_matches(fxl, fxr, RECTPOS, left_search_func, stereo_left_match);
 61     rm_corner_matches(fxr, &type);
 62     get_corner_matches(fxr, fxl, RECTPOS, right_search_func, stereo_right_match);
 63     set_stereo_corner_matches(fxl);
 64 }
 65 
 66 Vec2   *rectpos(Edgel * edgel)
 67 {
 68     return ((Vec2 *) prop_get(edgel->props, RECTPOS));
 69 }
 70 
 71 void   *stereo_left_match(Edgel * edgell, Edgel * edgelr)
 72 {
 73     float   corr;
 74 
 75     corr = good_corner(edgell, edgelr, (float) range, (float) asymetry, im_left, im_right);
 76 
 77     if (corr > correlate - uniqueness)
 78     {
 79         Match  *match;
 80         Match  *match_alloc();
 81 
 82         match = match_alloc(CORNER);
 83         match->weight = corr;
 84         match->to1 = (void *) edgell;
 85         match->to2 = (void *) edgelr;
 86         add_match_to_props(edgell, (void *) match, MLIST);
 87     }
 88 }
 89 
 90 void   *stereo_right_match(Edgel * edgelr, Edgel * edgell)
 91 {
 92     float   corr;
 93 
 94     corr = good_corner(edgelr, edgell, (float) range, (float) asymetry, im_right, im_left);
 95 
 96     if (corr > correlate - uniqueness)
 97     {
 98         Match  *match;
 99         Match  *match_alloc();
100 
101         match = match_alloc(CORNER);
102         match->weight = corr;
103         match->to1 = (void *) edgell;
104         match->to2 = (void *) edgelr;
105         add_match_to_props(edgelr, (void *) match, MLIST);
106     }
107 }
108 
109 Imregion left_search_func(Edgel * edgel)
110 {
111     Imregion stereor = {Imregion_id};
112     Vec2   *rect;
113 
114     rect = (Vec2 *) prop_get(edgel->props, RECTPOS);
115     if (rect == NULL)
116         rect = &edgel->pos;
117 
118     stereor.lx = (int)floor(rect->el[0] + lowd + disp);
119     stereor.ux = (int)floor(rect->el[0] + upd + disp);
120     stereor.ly = (int)floor(rect->el[1] - width);
121     stereor.uy = (int)floor(rect->el[1] + width);
122     return (stereor);
123 }
124 
125 Imregion right_search_func(Edgel * edgel)
126 {
127     Imregion stereor = {Imregion_id};
128     Vec2   *rect;
129 
130     rect = (Vec2 *) prop_get(edgel->props, RECTPOS);
131     if (rect == NULL)
132         rect = &edgel->pos;
133 
134     stereor.lx = (int)floor(rect->el[0] - upd - disp);
135     stereor.ux = (int)floor(rect->el[0] - lowd - disp);
136     stereor.ly = (int)floor(rect->el[1] - width);
137     stereor.uy = (int)floor(rect->el[1] + width);
138     return (stereor);
139 }
140 
141 void    set_stereo_corner_matches(Rindex * fxl)
142 {
143     void   *data = NULL;
144 
145     apply_func_to_windex(fxl, (void *(*) ()) set_stereo_corner_match, data);
146 }
147 
148 void    rm_stereo_corner_matches(Rindex * fx)
149 {
150     apply_func_to_windex(fx, (void *(*) ()) rm_match_from_props, (void *) MLIST);
151 }
152 
153 /* ARGSUSED quieten lint */
154 /* BUGFIX: JB 22/11/93 was void   *set_stereo_corner_match(Edgel *
155  * ledge, void *data) */
156 void    set_stereo_corner_match(Edgel * ledge, void *data /* unused */ )
157 {
158     Edgel  *redge;
159     List   *left_matches;
160     List   *right_matches;
161     Match  *best_left_match;
162     Match  *next_best_left;
163     Match  *best_right_match;
164     Match  *next_best_right;
165 
166     if ((left_matches = (List *) prop_get(ledge->props, MLIST)) == NULL)
167         return;
168     if ((best_left_match = (Match *) left_matches->to) == NULL)
169         return;
170 
171     if ((redge = (Edgel *) best_left_match->to2) == NULL)
172         return;
173 
174     if ((right_matches = (List *) prop_get(redge->props, MLIST)) == NULL)
175         return;
176     if ((best_right_match = (Match *) right_matches->to) == NULL)
177         return;
178 
179     if (ledge == best_right_match->to1 && best_left_match->weight > correlate)
180     {
181         left_matches->type = FIXED_MATCH;
182         right_matches->type = FIXED_MATCH;
183         if (left_matches->next != NULL && (next_best_left = (Match *) left_matches->next->to) != NULL)
184         {
185             if ((best_left_match->weight - next_best_left->weight) < uniqueness)
186             {
187                 left_matches->type = GOOD_MATCH;
188                 right_matches->type = GOOD_MATCH;
189             }
190         }
191         if (right_matches->next != NULL && (next_best_right = (Match *) right_matches->next->to) != NULL)
192         {
193             if ((best_right_match->weight - next_best_right->weight) < uniqueness)
194             {
195                 left_matches->type = GOOD_MATCH;
196                 right_matches->type = GOOD_MATCH;
197             }
198         }
199     }
200 }
201 

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