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

Linux Cross Reference
Tina4/src/vision/corner/t_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 xdisp, ydisp, height, width, correlate, uniqueness;
 14 static double asymetry = 0.85, range = 3.0;
 15 static Imrect *old_er_left = NULL;
 16 static Imrect *old_er_right = NULL;
 17 static Imrect *old_er_mono = NULL;
 18 
 19 void    mono_corners_store(Imrect * er)
 20 {
 21     old_er_mono = er;
 22 }
 23 
 24 void    left_corners_store(Imrect * er)
 25 {
 26     old_er_left = er;
 27 }
 28 
 29 void    right_corners_store(Imrect * er)
 30 {
 31     old_er_right = er;
 32 }
 33 
 34 Imrect *stored_mono_corners(void)
 35 {
 36     return (old_er_mono);
 37 }
 38 
 39 Imrect *stored_left_corners(void)
 40 {
 41     return (old_er_left);
 42 }
 43 
 44 Imrect *stored_right_corners(void)
 45 {
 46     return (old_er_right);
 47 }
 48 
 49 void    temporal_corner_match(Imrect * er, Imrect * old_er, double new_xdisp, double new_ydisp, double new_height, double new_width, double new_corr, double new_unique, double new_asym)
 50 {
 51     Rindex *fx;
 52     Rindex *old_fx;
 53     Rindex *er_set_findex();
 54     Imregion backward_search_func(Edgel * edgel);
 55     Imregion forward_search_func(Edgel * edgel);
 56     int     type = BACKTEMP;
 57 
 58     if (er == NULL || old_er == NULL)
 59     {
 60         error("missing edge structure", non_fatal);
 61         return;
 62     }
 63     if ((fx = prop_get(er->props, ER_TINDEX)) == NULL)
 64         if ((fx = er_set_findex(er, ER_TINDEX, (Vec2 * (*) ()) NULL)) == NULL)
 65             return;
 66     if ((old_fx = prop_get(old_er->props, ER_TINDEX)) == NULL)
 67         if ((old_fx = er_set_findex(old_er, ER_TINDEX, (Vec2 * (*) ()) NULL)) == NULL)
 68             return;
 69 
 70     xdisp = new_xdisp;
 71     ydisp = new_ydisp;
 72     height = new_height;
 73     width = new_width;
 74     correlate = new_corr;
 75     uniqueness = new_unique;
 76     asymetry = new_asym;
 77 
 78     rm_corner_matches(fx, &type);
 79     get_corner_matches(fx, old_fx, (int) NULL, backward_search_func, (void*(*) ())temp_backward_match);
 80     type = FORTEMP;
 81     rm_corner_matches(old_fx, &type);
 82     get_corner_matches(old_fx, fx, (int) NULL, forward_search_func, (void*(*) ())temp_forward_match);
 83     set_temporal_corner_matches(fx);
 84 }
 85 
 86 /* BUGFIX JB 22/11/93 was: void   *temp_backward_match(Edgel * edge1,
 87  * Edgel * edge2) */
 88 void    temp_backward_match(Edgel * edge1, Edgel * edge2)
 89 {
 90     float   corr;
 91 
 92     corr = good_corner(edge1, edge2, (float) range, (float) asymetry,
 93                        (Imrect *) NULL, (Imrect *) NULL);
 94 
 95     if (corr > correlate - uniqueness)
 96     {
 97         Match  *match;
 98         Match  *match_alloc();
 99 
100         match = match_alloc(CORNER);
101         match->weight = corr;
102         match->to1 = (void *) edge1;
103         match->to2 = (void *) edge2;
104         add_match_to_props(edge1, (void *) match, BACKTEMP);
105     }
106 }
107 
108 
109 void    temp_forward_match(Edgel * edge2, Edgel * edge1)
110 {
111     float   corr;
112 
113     corr = good_corner(edge1, edge2, (float) range, (float) asymetry,
114                        (Imrect *) NULL, (Imrect *) NULL);
115 
116     if (corr > correlate - uniqueness)
117     {
118         Match  *match;
119         Match  *match_alloc();
120 
121         match = match_alloc(CORNER);
122         match->weight = corr;
123         match->to1 = (void *) edge1;
124         match->to2 = (void *) edge2;
125         add_match_to_props(edge2, (void *) match, FORTEMP);
126     }
127 }
128 
129 Imregion forward_search_func(Edgel * edgel)
130 {
131     Imregion tempr = {Imregion_id};
132     Vec2   *rect;
133 
134     rect = &edgel->pos;
135 
136     tempr.lx = (int)floor(rect->el[0] - width + xdisp);
137     tempr.ux = (int)floor(rect->el[0] + width + xdisp);
138     tempr.ly = (int)floor(rect->el[1] - height + ydisp);
139     tempr.uy = (int)floor(rect->el[1] + height + ydisp);
140     return (tempr);
141 }
142 
143 Imregion backward_search_func(Edgel * edgel)
144 {
145     Imregion tempr = {Imregion_id};
146     Vec2   *rect;
147 
148     rect = &edgel->pos;
149 
150     tempr.lx = (int)floor(rect->el[0] - width - xdisp);
151     tempr.ux = (int)floor(rect->el[0] + width - xdisp);
152     tempr.ly = (int)floor(rect->el[1] - height - ydisp);
153     tempr.uy = (int)floor(rect->el[1] + height - ydisp);
154     return (tempr);
155 }
156 
157 void    set_temporal_corner_matches(Rindex * fx)
158 {
159     void   *data = NULL;
160     apply_func_to_windex(fx, (void*(*)())set_temporal_corner_match, data);
161 }
162 
163 
164 void    set_temporal_corner_match(Edgel * edge1, void *data)
165 {
166         List    *matches1, *matches2;
167         Match   *best_match1,*best_match2;
168         Edgel   *edge2;
169 
170 
171     if ((matches1 = (List *) prop_get(edge1->props, BACKTEMP)) == NULL)
172         return;
173     if ((best_match1 = (Match *) matches1->to) == NULL)
174         return;
175 
176     if ((edge2 = (Edgel *) best_match1->to2) == NULL)
177         return;
178 
179     if ((matches2 = (List *) prop_get(edge2->props, FORTEMP)) == NULL)
180         return;
181     if ((best_match2 = (Match *) matches2->to) == NULL)
182         return;
183 
184     if (edge1 == best_match2->to1 && best_match1->weight > correlate)
185     {
186                 matches1->type = GOOD_MATCH;
187                 matches2->type = GOOD_MATCH;
188     }
189 
190 }/* end proc */
191         
192 

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