#include <gandalf/vision/line_feature.h>A

/* Definition of basic 2D line feature structure */ typedef struct Gan_LineFeature { unsigned r1, c1, r2, c2; /* row/column coordinates in coordinate frame of 2D feature array */ Gan_Vector2_f p1, p2; /* endpoints of line */ double strength; /* line feature strength/contrast value */ Gan_Vector3_f l; /* line parameters a*x + b*y + c = 0 scaled so that a^2 + b^2 = 1 */ Gan_SquMatrix22_f N, Ni; /* covariance and inverse covariance for canonical line parameters a/b in y=ax+b, with x/y system centred on midpoint of line (p1+p2)/2 with positive x-axis along the line towards p2 endpoint, and positive y-axis 90 degrees anticlockwise from x-axis */ /* fields for user program to define */ int status; int index; /* array of points attached to this line */ Gan_Vector2_f *point; unsigned npoints; } Gan_LineFeature;The

The lines are stored in the line map structure as follows:

/* Definition of 2D line feature map structure */ typedef struct Gan_LineFeatureMap { unsigned nlines; /* number of line features stored */ Gan_LineFeature *line; /* array of line features */ unsigned max_nlines; /* allocated limit on number of line features */ /* dimensions of image region in which line features have been computed */ unsigned height, width; /* whether the following A, Ai fields are set */ Gan_Bool A_set; /* transformation between region coordinates (0..width) and (0..height) and line coordinates, and its inverse */ Gan_Matrix23_f A, Ai; /* local blocked feature index map */ Gan_LocalFeatureMap local_fmap; /* points making up line (optional) */ Gan_Vector2_f *point; /* array of points used to fit the lines to: may be NULL */ unsigned npoints; /* current number of points */ unsigned max_npoints; /* maximum (allocated) number of points */ /* whether this structure was dynamically allocated */ Gan_Bool alloc; } Gan_LineFeatureMap;

To create a line map with an initially allocated number of lines, use the following routine:

Gan_LineFeatureMap LineMap; /* initialise line map */ gan_line_feature_map_form ( &LineMap, 10000 ); /* initial limit on number of lines */If the initially allocated number of lines is exceeded,

The line detection algorithm will then add lines to the line map,
using the functions
`gan_line_feature_add()` defined in the
`line_feature.[ch]` module. To free the line map afterwards, call

/* free line map */ gan_line_feature_map_free ( &LineMap );The other low-level line routines defined in the