next up previous contents
Next: Displaying a corner map Up: Feature detection Previous: The Canny edge detector   Contents

Corner detection

      #include <gandalf/vision/corner_feature.h>
An corner map is a collection of ``corner'' points stored in a corner map structure. The corner structure is
      /* Definition of basic 2D corner feature structure */
      typedef struct Gan_CornerFeature
         unsigned short r, c; /* row/column coordinates in coordinate frame of 2D
                                 feature array */
         Gan_Vector2_f p; /* potentially sub-pixel coordinates of corner feature in
                             coordinate frame defined by corner map */
         Gan_Vector2_f pu; /* coordinates of feature with any non-linear image
                              distortion removed */
         float strength; /* corner feature strength/contrast value */
         Gan_SquMatrix22_f N, Ni; /* covariance and inverse covariance for feature
                                     point position */

         /* fields for user program to define */
         short status;
         short index;
      } Gan_CornerFeature;

The r, c fields are the integer local coordinates of the corner feature. p and pu are coordinates in the user-defined coordinate frame.

The corners are stored in the corner map structure as follows:

      /* Definition of 2D corner feature map structure */
      typedef struct Gan_CornerFeatureMap
         unsigned ncorners;         /* number of corner features stored */
         Gan_CornerFeature *corner; /* array of corner features */
         unsigned max_ncorners;     /* allocated limit on number of corner features*/

         /* dimensions of image region in which corner 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 corner coordinates, and its inverse */
         Gan_Matrix23_f A, Ai;

         /* calibration structure defining camera used for non-linear distortion
            correction */
         Gan_Camera_f camera;

         /* local blocked feature index map */
         Gan_LocalFeatureMap local_fmap;

         /* whether this structure was dynamically allocated */
         Gan_Bool alloc;
      } Gan_CornerFeatureMap;

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

      Gan_CornerFeatureMap CornerMap;

      /* initialise corner map */
      gan_corner_feature_map_form ( &CornerMap,
                                    10000 ); /* initial limit on number of corners */
If the initially allocated number of corners is exceeded, gan_realloc_array() is used to reallocate the array, so if you have no idea what reasonable initial limit should be, you can pass zero.

The corner detection algorithm will then add corners to the corner map, using the functions
gan_corner_feature_add() defined in the corner_feature.[ch] module. To free the corner map afterwards, call

      /* free corner map */
      gan_corner_feature_map_free ( &CornerMap );
The other low-level corner routines defined in the corner_feature.[ch] module are relevant only if you are developing your own corner detector; examples of their use can be found in the Harris corner detector code.

next up previous contents
Next: Displaying a corner map Up: Feature detection Previous: The Canny edge detector   Contents