00001 #ifndef LS_EXTRACTOR
00002 #define LS_EXTRACTOR
00003
00004 #include <image/Image.hpp>
00005 #include "lineSegment.hpp"
00006 #include "lineSegmentSet.hpp"
00007 #include "histogram.hpp"
00008 #include "lsMisc.hpp"
00009 #include "ctdef.hpp"
00010
00011 namespace jafar{
00012 namespace lines{
00013
00015
00028 class LsExtractor{
00029 public:
00030 LsExtractor();
00031
00033
00037 bool procCanny(jafar::image::Image* image, jafar::image::Image* cannyIm);
00038
00040
00044 static bool procCannySt(jafar::image::Image* image, jafar::image::Image* cannyIm, int lowerThresh, int higherThresh, int ap);
00045
00047
00057 void extractLineSegments(jafar::image::Image* image, jafar::image::Image* cannyIm, LineSegmentSet& segmentStorage,double thresh=15);
00058
00060
00073 static void extractLineSegmentsSt(jafar::image::Image* image, jafar::image::Image* cannyIm, LineSegmentSet& segmentStorage, double thresh=15, int lowerThresh=75, int higherThresh=150, int ap=3);
00074
00076
00081 bool procHough(jafar::image::Image* image, LineSegmentSet& newSegments);
00082
00090 bool procCvFindContour(jafar::image::Image* image, LineSegmentSet& newSegments, double thresh=15 );
00091
00101 static void findLinesDP(jafar::image::Image* image, LineSegmentSet& newSegments, double thresh );
00102
00107 static void findLinesCalife(jafar::image::Image* image, LineSegmentSet& newSegments, double thresh=15 );
00108
00113 static int dp(short *x, short *y, int startIdx, int endIdx, std::vector<CvPoint> &endpoints, double thresh=1);
00114
00115 void setCannyLowerThresh(int lowerThresh){ cannyLowerThresh = lowerThresh;}
00116 void setCannyHigherThresh(int higherThresh){ cannyHigherThresh = higherThresh;}
00117 void setCannyAp(int ap){ if(ap>0) cannyAp = ap; }
00118 void setCannyPara(int lowerThresh, int higherThresh, int ap){
00119 cannyLowerThresh = lowerThresh;
00120 cannyHigherThresh = higherThresh;
00121 cannyAp = ap;
00122 }
00123
00124 void setHoughMethod(int method){ houghMethod = method;}
00125 void setHoughRho(double rho){ if(rho>0) houghRho = rho;}
00126 void setHoughTheta(double theta){ if(theta>0) houghTheta = theta;}
00127 void setHoughThreshold(int thresh){ houghThreshold = thresh;}
00128 void setHoughParam1(double param){ houghParam1 = param;}
00129 void setHoughParam2(double param){ houghParam2 = param;}
00130 void setHoughPara(int method, double rho, double theta, int thresh, int param1, int param2){
00131 houghMethod = method;
00132 if(rho>0)houghRho = rho;
00133 if(theta>0) houghTheta = theta;
00134 houghThreshold = thresh;
00135 houghParam1 = param1;
00136 houghParam2 = param2;
00137 }
00138
00139 protected:
00140
00141
00142 int cannyLowerThresh;
00143 int cannyHigherThresh;
00144 int cannyAp;
00145
00146
00147 int houghMethod;
00148 double houghRho;
00149 double houghTheta;
00150 int houghThreshold;
00151 double houghParam1;
00152 double houghParam2;
00153 };
00154
00155 }
00156 }
00157
00158 #endif