contrib/brl/bseg/sdet/sdet_harris_detector.h
Go to the documentation of this file.
00001 // This is brl/bseg/sdet/sdet_harris_detector.h
00002 #ifndef sdet_harris_detector_h_
00003 #define sdet_harris_detector_h_
00004 //---------------------------------------------------------------------
00005 //:
00006 // \file
00007 // \brief a processor for extracting Harris corners
00008 //
00009 //  The Harris Corner is defined as a local maximum of
00010 //   Det(A)-k*Trace^2(A)
00011 //  where
00012 // \verbatim
00013 //                        _                           _
00014 //                       | (dI/dx)^2    (dI/dx)(dI/dy) |
00015 //                       |                             |
00016 //  A = Sum(neighborhood)|                             |
00017 //                       |(dI/dx)(dI/dy)   (dI/dx)^2   |
00018 //                       |_                           _|
00019 // \endverbatim
00020 //  over a 2n+1 x 2n+1 neighborhood.
00021 //  The value of k is typically 0.04 as originally recommended by Harris.
00022 //
00023 // Note:
00024 //  There is a version in osl, but the plan is to build a suite of
00025 //  feature trackers and the gradient matrix is a fundamental concept
00026 //  across many tracking algorithms. Thus this Harris implementation
00027 //  is built on a more generally usable image processing base.
00028 //
00029 // \author
00030 //  J.L. Mundy - February 26, 2003
00031 //
00032 // \verbatim
00033 //  Modifications
00034 // J.L. MUndy December 28, 2004 - added interface for vil images
00035 // \endverbatim
00036 //
00037 //-------------------------------------------------------------------------
00038 #include <vcl_vector.h>
00039 #include <vil1/vil1_image.h>
00040 #include <vil/vil_image_resource.h>
00041 #include <vsol/vsol_point_2d_sptr.h>
00042 #include <sdet/sdet_harris_detector_params.h>
00043 
00044 class sdet_harris_detector : public sdet_harris_detector_params
00045 {
00046  public:
00047   //Constructors/destructor
00048   sdet_harris_detector(sdet_harris_detector_params& rpp);
00049 
00050   ~sdet_harris_detector();
00051   //Accessors
00052   void set_image(vil1_image const& image);
00053   void set_image_resource(vil_image_resource_sptr const& image);
00054 
00055   vcl_vector<vsol_point_2d_sptr>& get_points(){return points_;}
00056 
00057   //Utility Methods
00058   void extract_corners();
00059   void clear();
00060 
00061  protected:
00062   //protected methods
00063   bool extract_corners_vil1(vcl_vector<float>& x_pos,
00064                             vcl_vector<float>& y_pos,
00065                             vcl_vector<float>& val);
00066 
00067   bool extract_corners_vil(vcl_vector<float>& x_pos,
00068                            vcl_vector<float>& y_pos,
00069                            vcl_vector<float>& val);
00070   //members
00071   bool points_valid_;      //process state flag
00072   bool use_vil_image_;
00073   vil1_image image_;  //input image
00074   vil_image_resource_sptr vimage_;  //input image
00075   vcl_vector<vsol_point_2d_sptr> points_; //resulting corners
00076 };
00077 
00078 #endif // sdet_harris_detector_h_