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

Linux Cross Reference
Tina4/src/pgh/pgh_HT.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/draw.h>
 14 #include <tina/drawfuncs.h>
 15 #include <tina/tv.h>
 16 #include <tina/tvfuncs.h>
 17 #include <tina/toolsfuncs.h>
 18 #include <tina/tw_Xfuncs.h>
 19 #include <pgh/pgh_defs.h>
 20 #include <pgh/pgh_types.h>
 21 #include <pgh/pgh_funcs.h>
 22 
 23 #include <pgh/extra.h>
 24 
 25 /* ---------- */
 26 
 27 int locate_using_long_lines(Model_poly_header *current_model, Imrect *location_hough_space, List *scene_pairs_list, Match_cut_def *match_cut_def)
 28 {
 29     int         num_lines_plotted=0;
 30     List       *scene_ptr;
 31     List       *match_ptr;
 32     Vec2        model_perp_vec;
 33     Vec2        scene_perp_vec;
 34     Mat2        rotation_mat;
 35     Line2      *scene_line;
 36     Line2      *match_line;
 37     Line2       line;
 38     Imrect     *scene_hist;
 39     Imrect     *match_hist;    
 40     double      rotation;
 41     Hist_ref   *scene_hist_ref;
 42     Hist_ref   *match_hist_ref;
 43     Transform2  trans;
 44     Match_ref  *match_ref;
 45     List       *cut_match_list;
 46     List       *copy_and_cut_matches_list();
 47     Hist_ref *hist_ref_get();
 48     int         orientation; /* Added apa 10/1/96 */
 49 
 50 
 51         /* (1) For each scene histogram...
 52            (2)     For each matched histogram in the list...
 53            (3)         If the matched histogram comes from the
 54                        current model plot 2 lines parallel to the
 55                        scene line */
 56 
 57     for(scene_ptr=scene_pairs_list;scene_ptr!=NULL;scene_ptr=scene_ptr->next)
 58     {
 59         scene_hist = scene_ptr->to;
 60         scene_hist_ref = hist_ref_get(scene_hist);
 61         scene_line = scene_hist_ref->line_seg;
 62 
 63         cut_match_list = 
 64                      copy_and_cut_matches_list(scene_hist_ref, match_cut_def);
 65 
 66         for(match_ptr=cut_match_list;match_ptr!=NULL;
 67                                       match_ptr=match_ptr->next)
 68         {
 69             match_ref = match_ptr->to;
 70             match_hist = match_ref->hist;
 71             match_hist_ref = hist_ref_get(match_hist);
 72             match_line = match_hist_ref->line_seg;
 73 
 74             if (match_hist_ref->type == DIRECTED)
 75                orientation = match_ref->orientation;
 76             else
 77                orientation = 0;
 78 
 79             if (match_hist_ref->model==current_model)
 80             {
 81 
 82                 model_perp_vec = vec2_projperp(match_line->p, match_line->v);
 83                 model_perp_vec = vec2_times(match_ref->scale_factor, 
 84                                                                 model_perp_vec);
 85                 rotation = vec2_angle(scene_line->v, match_line->v);
 86                 rotation_mat = rot2(rotation);
 87                 scene_perp_vec = mat2_vprod(rotation_mat, model_perp_vec);
 88 
 89                 if (orientation == 0 || orientation == -1 )
 90                 {
 91                     line = *scene_line;         
 92                     rotation_mat = rot2(0.0);
 93                     trans.R = rotation_mat;
 94                     trans.t = scene_perp_vec;
 95                     line2_transform(&line, trans);
 96                     if (hough2_extend_line(&line, location_hough_space)==TRUE)
 97                     {
 98                         num_lines_plotted++;
 99                         hough2_plot_line(&line, location_hough_space, 
100                                                           scene_line->length);
101                     }
102                 }
103 
104 
105                 if (orientation == 0 || orientation == 1 )
106                 {
107                     line = *scene_line;       
108                     rotation_mat = rot2(0.0);
109                     trans.R = rotation_mat;
110                     trans.t = vec2_minus(scene_perp_vec);
111                     line2_transform(&line, trans);
112                     if (hough2_extend_line(&line, location_hough_space)==TRUE)
113                     {
114                         num_lines_plotted++;
115                         hough2_plot_line(&line, location_hough_space, 
116                                                           scene_line->length);
117                     }
118                 }
119 
120             }/*endif*/
121         }/*endfor(match_ptr)*/
122 
123       /* Free the generated match list */
124 
125       list_rm(cut_match_list, rfree);
126 
127     }/*endfor(scene_ptr)*/
128 
129     return (num_lines_plotted);
130 
131 }
132 
133 /* ---------- */
134 
135 int locate_using_short_lines(Model_poly_header *current_model, Imrect *location_hough_space, List *scene_pairs_list, Match_cut_def *match_cut_def)
136 {
137     int         num_lines_plotted=0;
138     List       *scene_ptr;
139     List       *match_ptr;
140     Vec2        model_vec;
141     Vec2        scene_vec;
142     Mat2        rotation_mat;
143     Line2      *scene_line;
144     Line2      *match_line;
145     Line2       line;
146     Imrect     *scene_hist;
147     Imrect     *match_hist;    
148     double      rotation;
149     Hist_ref   *scene_hist_ref;
150     Hist_ref   *match_hist_ref;
151     Match_ref  *match_ref;
152     List       *cut_match_list;
153     List       *copy_and_cut_matches_list();
154     double      model_l0;
155     
156 
157         /* (1) For each scene histogram...
158            (2)     For each matched histogram in the list...
159            (3)         If the matched histogram comes from the
160                        current model plot 2 lines parallel to the
161                        scene line of length 2*model lines length */
162 
163     for(scene_ptr=scene_pairs_list;scene_ptr!=NULL;scene_ptr=scene_ptr->next)
164     {
165         scene_hist = scene_ptr->to;
166         scene_hist_ref = prop_get(scene_hist->props, HIST_REF_TYPE);
167         scene_line = scene_hist_ref->line_seg;
168 
169         cut_match_list = 
170                      copy_and_cut_matches_list(scene_hist_ref, match_cut_def);
171 
172         for(match_ptr=cut_match_list;match_ptr!=NULL;
173                                       match_ptr=match_ptr->next)
174         {
175             match_ref = match_ptr->to;
176             match_hist = match_ref->hist;
177             match_hist_ref = prop_get(match_hist->props, HIST_REF_TYPE);
178             match_line = match_hist_ref->line_seg;
179             model_l0 = match_hist_ref->l0;
180 
181             if (match_hist_ref->model==current_model)
182             {
183 
184     /* Perhaps there should be 4 cases, rather than just 2 ???? */
185 
186                 model_vec = match_line->p;
187                 rotation = vec2_angle(scene_line->v, match_line->v);
188                 rotation_mat = rot2(rotation);
189                 scene_vec = mat2_vprod(rotation_mat, model_vec);
190 
191                 /* Now scale the scene vector by the scale factor */
192                 scene_vec = vec2_times(match_ref->scale_factor, scene_vec);
193 
194 
195                 line.p =  vec2_diff(scene_line->p, scene_vec);
196                 line.p1 = vec2_diff(line.p, vec2_times(
197                     (match_ref->scale_factor*model_l0/2.0), scene_line->v));
198                 line.p2 = vec2_sum(line.p, vec2_times(
199                     (match_ref->scale_factor*model_l0/2.0), scene_line->v));
200                 line.v = scene_line->v;
201                 line.length = (float)model_l0;
202 
203                 num_lines_plotted++;
204                     
205                 hough2_plot_line(&line, location_hough_space, 
206                                 match_ref->scale_factor*scene_line->length);
207                 line.p1 = vec2_diff(line.p, vec2_times(
208                     (match_ref->scale_factor*model_l0/2.0), scene_line->v));
209                 line.p2 = vec2_sum(line.p, vec2_times(
210                     (match_ref->scale_factor*model_l0/2.0), scene_line->v));
211 
212                 line.p =  vec2_sum(scene_line->p, scene_vec);
213 
214                 line.v = scene_line->v;
215                 line.length = (float)(2.0*model_l0);
216 
217                 num_lines_plotted++;
218                     
219                 hough2_plot_line(&line, location_hough_space, 
220                                 match_ref->scale_factor*scene_line->length);
221 
222 
223             }/*endif*/
224 
225         }/*endfor(match_ptr)*/
226 
227       /* Free the generated match list */
228 
229       list_rm(cut_match_list, rfree);
230 
231     }/*endfor(scene_ptr)*/
232 
233     return (num_lines_plotted);
234 }
235 
236 /* ---------- */
237 
238 void locate_using_points(Model_poly_header *current_model, Imrect *location_hough_space, List *scene_pairs_list, Match_cut_def *match_cut_def)
239 {
240         /* (1) For each pair of scene histograms which have been 
241                matched to lines from this model place votes in 
242                the hough space at the respective location - ie,  4
243                points which are the intersection of parallel lines 
244                to the scene lines. */
245 
246     List       *scene_ptr;
247     List       *match_ptr;
248     Vec2        model_perp_vec;
249     Vec2        scene_perp_vec;
250     Mat2        rotation_mat;
251     Line2      *scene_line;
252     Line2      *match_line;
253     Imrect     *scene_hist;
254     Imrect     *match_hist;    
255     double      rotation;
256     Hist_ref   *scene_hist_ref;
257     Hist_ref   *match_hist_ref;
258     Match_ref  *match_ref;
259     List       *cut_match_list;
260     List       *copy_and_cut_matches_list();
261     List       *entry_list = NULL;
262     Pairs_HT_entry *entry;
263     int         orientation;
264     Pgh_serr *serr;
265     
266 /* Get the data from the scene and the match list */
267 
268   for(scene_ptr=scene_pairs_list;scene_ptr!=NULL;scene_ptr=scene_ptr->next)
269     {
270         scene_hist = scene_ptr->to;
271         scene_hist_ref = prop_get(scene_hist->props, HIST_REF_TYPE);
272         scene_line = scene_hist_ref->line_seg;
273 
274         cut_match_list = copy_and_cut_matches_list(scene_hist_ref, match_cut_def);
275 
276         for(match_ptr=cut_match_list;match_ptr!=NULL;
277                                       match_ptr=match_ptr->next)
278         {
279             match_ref = match_ptr->to;
280             match_hist = match_ref->hist;
281             match_hist_ref = prop_get(match_hist->props, HIST_REF_TYPE);
282             if (match_hist_ref->type == DIRECTED)
283                orientation = match_ref->orientation;
284             else
285                orientation = 0;
286 
287             match_line = match_hist_ref->line_seg;
288 
289             if (match_hist_ref->model==current_model)
290             {
291                 /* Create a list of HT entry data */
292 
293                 model_perp_vec = vec2_projperp(match_line->p, match_line->v);
294                 rotation = vec2_angle(scene_line->v, match_line->v);
295                 rotation_mat = rot2(rotation);
296                 scene_perp_vec = mat2_vprod(rotation_mat, model_perp_vec);
297 
298                 if (orientation == 0 || orientation == -1 )
299                 {
300                     entry = ralloc(sizeof(Pairs_HT_entry));
301                     entry->scene_line = scene_line;
302                     entry->perp_vec = scene_perp_vec;
303                     entry->scale = match_ref->scale_factor;
304 
305                     if ((serr = prop_get(match_hist->props, PGH_SERR_TYPE))==NULL)
306                     {
307                         entry->smin = match_ref->scale_factor;
308                         entry->smax = match_ref->scale_factor;
309                     }
310                     else
311                     {
312                         entry->smin = serr->smin;
313                         entry->smax = serr->smax;
314                     }
315 
316                     entry_list = ref_addtostart(entry_list, entry, 
317                                                           PAIRS_HT_ENTRY);
318                         }
319 
320                 if (orientation == 0 || orientation == 1 )
321                 {
322                     entry = ralloc(sizeof(Pairs_HT_entry));
323 
324                     entry->scene_line = scene_line;
325                     entry->perp_vec = vec2_minus(scene_perp_vec);
326                     entry->scale = match_ref->scale_factor;
327 
328                     if ((serr = prop_get(match_hist->props, PGH_SERR_TYPE))==NULL)
329                     {
330                         entry->smin = match_ref->scale_factor;
331                         entry->smax = match_ref->scale_factor;
332                     }
333                     else
334                     {
335                         entry->smin = serr->smin;
336                         entry->smax = serr->smax;
337                     }
338 
339                     entry_list = ref_addtostart(entry_list, entry, PAIRS_HT_ENTRY);
340                         } 
341             } /*end if match_hist_ref*/
342         } /*end for match_ptr*/
343         
344         list_rm(cut_match_list, rfree);
345 
346      } /*end for scene_ptr*/
347 
348 
349     /* Call the plotting procedure then on return delete the parallel lines list */
350 
351         hough2_fill(location_hough_space, 0.0);
352     hough2_plot_points(entry_list, location_hough_space);
353     list_rm(entry_list, rfree);
354 }
355 
356 /* ---------- */
357 
358 void angle_from_loc(Imrect *hough1, Point2 *loc, Model_poly_header *current_model)
359 {
360     Vec2       scene_ref_vec;
361     List      *scene_ptr, *match_ptr;
362     Line2     *scene_line, *match_line;
363     double     angle1,angle2,sigma;
364     Imrect    *scene_hist, *match_hist;
365     Hist_ref  *scene_hist_ref, *match_hist_ref;
366     Match_ref *match_ref;
367     List      *cut_match_list;
368     List      *copy_and_cut_matches_list();
369     Match_cut_def *pairs_match_cut_def_get();
370     List          *scene_pairs_list;
371     Match_cut_def *match_cut_def;
372     List          *pairs_scene_pairs_list_get();
373     Pairs_hist_def *hist_def;
374 
375         /* (1) For each scene line which has matched to
376                the current model...
377            (2) Plot a point in hough space for the angle 
378                between the scene reference vector and the 
379                matched model reference vector. */
380     scene_pairs_list = pairs_scene_pairs_list_get();
381     match_cut_def = pairs_match_cut_def_get();
382     hist_def = pairs_hist_def_get();
383 
384     for(scene_ptr=scene_pairs_list; scene_ptr!=NULL;
385                                        scene_ptr=scene_ptr->next)
386     {
387         scene_hist = scene_ptr->to;
388         scene_hist_ref = prop_get(scene_hist->props, HIST_REF_TYPE);
389         scene_line = scene_hist_ref->line_seg;
390 
391         cut_match_list = copy_and_cut_matches_list(scene_hist_ref, 
392                                                             match_cut_def);
393 
394         for(match_ptr=cut_match_list;match_ptr!=NULL;
395                                               match_ptr=match_ptr->next)
396         {
397             match_ref = match_ptr->to;
398             match_hist = match_ref->hist;
399             match_hist_ref = prop_get(match_hist->props, HIST_REF_TYPE);
400             match_line = match_hist_ref->line_seg;
401 
402             if ( (match_hist_ref->model==current_model) &&
403                  (scene_line->length>hist_def->min_length) )
404             {
405                 sigma = (float)(sqrt(pow(atan((double)(2.0
406                                /(scene_line->length))),2.0)
407                                + pow(atan((double)(2.0
408                                /(match_line->length))),2.0)));
409 
410                 scene_ref_vec = vec2_sum(scene_line->p, vec2_minus(loc->p));
411                 angle1 = vec2_angle(scene_ref_vec, match_line->p);
412                 angle2 = vec2_angle(scene_line->v, match_line->v);
413                 if (fabs(angle1-angle2)<3.0*sigma)
414                 {
415                     hough1_plot_log_gauss(hough1, angle2-2.0*PI, sigma);
416                     hough1_plot_log_gauss(hough1, angle2, sigma);
417                     hough1_plot_log_gauss(hough1, angle2+2.0*PI, sigma);
418                 }
419                 else if (fabs(angle1-angle2+PI)<3.0*sigma)
420                 {
421                     hough1_plot_log_gauss(hough1, angle2-PI, sigma);
422                     hough1_plot_log_gauss(hough1, angle2+PI, sigma);
423                     hough1_plot_log_gauss(hough1, angle2+3.0*PI, sigma);
424                 }
425                 else if (fabs(angle1-angle2-PI)<3.0*sigma)
426                 {
427                     hough1_plot_log_gauss(hough1, angle2-3.0*PI, sigma);
428                     hough1_plot_log_gauss(hough1, angle2-PI, sigma);
429                     hough1_plot_log_gauss(hough1, angle2+PI, sigma);
430                 }
431             }
432         }
433 
434       /* Free the generated match list */
435 
436       list_rm(cut_match_list, rfree);
437     }
438 
439 }
440 
441 /* ---------- */
442 
443 double scale_from_loc(Point2 *loc, Model_poly_header *model)
444 {
445     Imrect *scale_hough;
446     Pairs_scale_def *scale_def;
447     List *scene_pairs_list, *scene_ptr;
448     Imrect *scene_hist;
449     Hist_ref *scene_hist_ref;
450     Line2 *scene_line;
451     List *cut_match_list, *match_ptr;
452     Match_cut_def *match_cut_def;
453     Match_ref *match_ref;
454     Imrect *match_hist;
455     Hist_ref *match_hist_ref;
456     Line2 *match_line;
457     double scene_dist, model_dist, scale;
458     double model_perp_dist, scene_perp_dist, dist_error;
459     Hough1_peak peak;
460         Mat2 *C;
461         Mat2 R, Rt, C_rot;
462         double scene_line_angle;
463         double scale_error;
464 
465     scale_def = pairs_scale_def_get();
466     scene_pairs_list = pairs_scene_pairs_list_get();
467     match_cut_def = pairs_match_cut_def_get();
468 
469     if ( (scale_def->scale_max==1.0) &&
470          (scale_def->scale_min==1.0) )
471         return 1.0;
472 
473     scale_hough = hough1_alloc(scale_def->scale_min, scale_def->scale_max,
474                                scale_def->HTbinsize, float_v);
475 
476     C = prop_get(loc->props, COVAR2);
477 
478 /* Make scale entries for matches which may have been responsible for this
479    peak in the location HT */
480 
481     for(scene_ptr=scene_pairs_list;scene_ptr!=NULL;scene_ptr=scene_ptr->next)
482     {
483         scene_hist = scene_ptr->to;
484         scene_hist_ref = prop_get(scene_hist->props, HIST_REF_TYPE);
485         scene_line = scene_hist_ref->line_seg;
486 
487         scene_line_angle = acos(vec2_dot(scene_line->v, vec2_ex()));
488         R = rot2(-scene_line_angle);
489         Rt = mat2_transpose(R);
490         C_rot = mat2_prod(mat2_prod(Rt, *C), R);
491         scale_error = sqrt(mat2_yy(C_rot));
492 
493         cut_match_list = copy_and_cut_matches_list(scene_hist_ref, 
494                                                             match_cut_def);
495 
496         for(match_ptr=cut_match_list;match_ptr!=NULL;
497                                               match_ptr=match_ptr->next)
498         {
499             match_ref = match_ptr->to;
500             match_hist = match_ref->hist;
501             match_hist_ref = hist_ref_get(match_hist);
502             match_line = match_hist_ref->line_seg;
503 
504             if (match_hist_ref->model==model)
505             {
506 
507                 /* Could this match have contributed to the peak */
508                 model_perp_dist = 
509                         vec2_mod(vec2_projperp(match_line->p, match_line->v));
510                 scene_perp_dist = vec2_dist_point_line(loc->p, scene_line->p, 
511                                                                scene_line->v);
512                 dist_error = scene_perp_dist-model_perp_dist*
513                                                 match_ref->scale_factor;
514 
515                 if ((dist_error>-scale_def->HTd_error) &&
516                     (dist_error<scale_def->HTd_error))
517                 {
518 
519                     scene_dist = vec2_dist(scene_line->p, loc->p);
520                     model_dist = vec2_mod(match_line->p);
521 
522                     switch(scale_def->HTmethod)
523                     {
524                         case SCALE_HT_REF:
525                             scale = match_ref->scale_factor;
526                             break;
527                         case SCALE_HT_PERPDIST:
528                             scale = scene_perp_dist/model_perp_dist;
529                             break;
530                         case SCALE_HT_DIST:
531                             scale = scene_dist/model_dist;
532                     }
533     
534                     hough1_plot_log_gauss(scale_hough, scale,
535                                                             scale_error*0.2/*scale_def->HTsigma*/);
536 
537                 }
538             }
539         }
540     }
541 
542     /* Output the scale data to the stdio */
543     /*printf("Scale Space Plot\n----------------\n");
544     hough1_output(scale_hough);*/
545     
546     stack_push(scale_hough, IMRECT, im_free);
547 
548     peak = hough1_locate_max_peak(scale_hough, 0.0, float_v);
549 
550     return peak.x;
551 }
552 
553 /* ---------- */
554 
555 /* ---------- Code from hough2_points.c APA 4/2/94 ---------- */
556 
557 
558 void hough2_plot_points(List *entry_list, Imrect *hough2)
559 {
560     double          min_angle;
561     Line2          *line1, *line2;
562     List           *ptr1;
563     List           *ptr2;
564     double          weight, angle;
565     Bool            t1, t2;
566     Pairs_hough_def *hough_def;
567     Vec2            get_intersection();
568 
569     Pairs_HT_entry *entry1, *entry2;
570     Mat2 R;
571     Transform2 T;
572     Vec2 OS0, OS1, S0S1;
573     double smin, smax;
574     double smin1, smax1;
575     double smin2, smax2;
576     Vec2 p0, p1, p;
577 
578     double a, b, c, d, det;    /* APA 31.1.96 */
579     Mat2 C;
580     double theta, l1, l2, eig_lim;
581     void             get_covariance();
582     double sigma2;
583 
584     double sdx, sdy, s_angle;
585     Mat2 SCov, U, U_trans, SCov_rot;
586     Mat2 TotCov;
587 
588 /* Get the values which define the extended parallel lines from the list then find the */
589 /* intersection between a pair.  Plot a point in the hough space to correspond to the */
590                     /* intersection after smoothing using a gaussian */
591 
592     hough_def = pairs_hough_def_get();
593     min_angle = hough_def->min_angle;
594     sigma2 = hough_def->gauss_sigma*hough_def->gauss_sigma;
595     eig_lim = hough_def->eig_lim;
596 
597     R = rot2(0.0);
598     T.R = R;
599 
600     for(ptr1=entry_list;ptr1!=NULL;ptr1=ptr1->next)
601     {
602         entry1 = ptr1->to;
603 
604 
605         for(ptr2=ptr1->next;ptr2!=NULL;ptr2=ptr2->next)
606         {
607             entry2 = ptr2->to;
608 
609             /* Determine the start of the line of equal scale 
610                (where the scene lines intersect) */
611 
612             OS0 = get_intersection(entry1->scene_line, entry2->scene_line, &t1, &t2);
613 
614             /* Determine the point at scale=1 */
615 
616             line1 = line2_copy(entry1->scene_line);
617             T.t = entry1->perp_vec;
618             line2_transform(line1, T);
619 
620             line2 = line2_copy(entry2->scene_line);
621             T.t = entry2->perp_vec;
622             line2_transform(line2, T);
623 
624             OS1 = get_intersection(line1, line2, &t1, &t2);
625 
626             S0S1 = vec2_sum(OS1, vec2_minus(OS0));
627 
628             /* Now: p(s) = OS0 + s x S0S1 */
629 
630             smin1 = entry1->smin;
631             smax1 = entry1->smax;
632             smin2 = entry2->smin;
633             smax2 = entry2->smax;
634 
635             if (smin1<smin2)
636                 smin = smin2;
637             else
638                 smin = smin1;
639 
640             if (smax1>smax2)
641                 smax = smax2;
642             else
643                 smax = smax1;
644 
645             p0 = vec2_sum(OS0, vec2_times(smin, S0S1));
646             p1 = vec2_sum(OS0, vec2_times(smax, S0S1));
647 
648             /* Construct a covariance matrix to represent the scale 
649                error if dealing with variable scale data. This is 
650                an approximation to the correct error */
651 
652             sdx = vec2_mod(vec2_diff(p1, p0))*2.0;
653             sdy = sdx/1000.0;
654 
655             if (smin!=smax)
656                 s_angle = vec2_angle(vec2_ex(), vec2_diff(p0, p1));
657             else
658                 s_angle = 0.0;            
659 
660             SCov = mat2(sdx*sdx, 0.0, 0.0, sdy*sdy);
661             U = rot2(s_angle);
662             U_trans = mat2_transpose(U);
663             SCov_rot = mat2_prod(mat2_prod(U_trans, SCov), U);
664 
665             p = vec2_midpoint(p0, p1);
666 
667             angle = fabs(vec2_angle(line2->v , line1->v));
668             if(angle > min_angle)
669             {
670                 weight = entry1->scene_line->length + 
671                                      entry2->scene_line->length;
672 
673 
674                 /* Remove short lines */
675                 if( (entry1->scene_line->length >= 4.0) && 
676                     (entry2->scene_line->length >= 4.0) )
677                 {
678                     get_covariance(line1, line2, &a, &b, &c, &d);
679                     det = a*d - c*b;
680                     conic_eigen(d/det, -c/det, a/det, &theta, &l1, &l2);
681 
682                     /* Don't bother with v.large ellipses */
683                     if ( (l1 <= eig_lim*eig_lim) &&
684                          (l2 <= eig_lim*eig_lim) )
685                     {
686                         C = mat2(d/det, -c/det, -b/det, a/det); 
687 
688                         /* Scale the covariance matrix according to
689                            line endpoint error*/
690                         mat2_xx(C) *= (float)sigma2;
691                         mat2_xy(C) *= (float)sigma2;
692                         mat2_yx(C) *= (float)sigma2;
693                         mat2_yy(C) *= (float)sigma2;
694 
695                         TotCov = mat2_sum(C, SCov_rot);
696 
697                         hough2_plot_ellipse(hough2, &p, &TotCov, weight);
698                     }
699                 }
700             }
701         }
702     }
703 }
704 
705 
706 /* ---------- */
707 
708 
709 

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