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

Linux Cross Reference
Tina4/src/vision/calib/h_v_lines.c

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

  1 /**@(#)
  2 **/
  3 #include <math.h>
  4 #include <stdio.h>
  5 #include <tina/sys.h>
  6 #include <tina/sysfuncs.h>
  7 #include <tina/math.h>
  8 #include <tina/mathfuncs.h>
  9 #include <tina/vision.h>
 10 #include <tina/visionfuncs.h>
 11 
 12 static double min_linex(Line2 * line)
 13 {
 14     if (line->p1.el[0] < line->p2.el[0])
 15         return (line->p1.el[0]);
 16     else
 17         return (line->p2.el[0]);
 18 }
 19 
 20 static double min_liney(Line2 * line)
 21 {
 22     if (line->p1.el[1] < line->p2.el[1])
 23         return (line->p1.el[1]);
 24     else
 25         return (line->p2.el[1]);
 26 }
 27 
 28 static List *remerge(List * line_list, double join_thres)
 29 {
 30     List   *ptr1 = NULL;
 31     List   *ptr2 = NULL;
 32     Line2  *line1 = NULL;
 33     Line2  *line2 = NULL;
 34     Tstring *s1, *s2, *snew, *es_combine();
 35 
 36     for (ptr1 = line_list; ptr1 != NULL; ptr1 = ptr1->next)
 37     {
 38         line1 = ptr1->to;
 39         if (line1 != NULL && line2 != NULL)
 40         {
 41             if (vec2_mod(vec2_diff(line2->p1, line1->p1)) < join_thres
 42              || vec2_mod(vec2_diff(line2->p1, line1->p2)) < join_thres
 43              || vec2_mod(vec2_diff(line2->p2, line1->p1)) < join_thres
 44             || vec2_mod(vec2_diff(line2->p2, line1->p2)) < join_thres)
 45             {
 46                 s1 = prop_get(line1->props, STRING);
 47                 s2 = prop_get(line2->props, STRING);
 48                 snew = es_combine(s1, s2);
 49                 line_list = list_rm_el(line_list, ptr1, line2_free);
 50                 line1 = line2_fit(snew->start, snew->end);
 51                 ptr1 = link_alloc((void *) line1, LINE2);
 52                 link_addafter(ptr2, ptr1);
 53                 line_list = list_rm_el(line_list, ptr2, line2_free);
 54             }
 55         }
 56         ptr2 = ptr1;
 57         line2 = line1;
 58     }
 59     return (line_list);
 60 }
 61 
 62 void    colinear_2Dlist(List * lines, List ** co_horizlist, List ** co_vertlist, double co_thres, double join_thres)
 63 {
 64     List   *ptr1;
 65     List   *co_linelist;
 66     List   *remerge();
 67     Line2  *line1;
 68     Line2  *refline;
 69     Line2  *colinear_2Dlines();
 70     double  min_linex(), min_liney();
 71     double  min_intery(), min_interx();
 72 
 73     while (lines != NULL)
 74     {
 75         ptr1 = lines;
 76         line1 = ptr1->to;
 77         lines = list_rm_el(lines, ptr1, (void (*) ()) NULL);
 78         co_linelist = ref_addtostart((List *) NULL, (void *) line1, LINE2);
 79         refline = colinear_2Dlines(&co_linelist, &lines, co_thres);
 80         if (fabs(refline->p1.el[0] - refline->p2.el[0])
 81             > fabs(refline->p1.el[1] - refline->p2.el[1]))
 82         {
 83             co_linelist = sort_list(co_linelist, min_linex, NULL);
 84             co_linelist = remerge(co_linelist, join_thres);
 85             *co_horizlist = ref_addtostart((List *) * co_horizlist, (void *) co_linelist, LIST);
 86         } else
 87         {
 88             co_linelist = sort_list(co_linelist, min_liney, NULL);
 89             co_linelist = remerge(co_linelist, join_thres);
 90             *co_vertlist = ref_addtostart((List *) * co_vertlist, (void *) co_linelist, LIST);
 91         }
 92     }
 93     *co_horizlist = sort_list(*co_horizlist, min_intery, NULL);
 94     *co_vertlist = sort_list(*co_vertlist, min_interx, NULL);
 95 }
 96 

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