ellipse_refinement.h
Go to the documentation of this file.
00001 
00007 #ifndef  TUW_ELLIPSE_REFINEMENT_H
00008 #define  TUW_ELLIPSE_REFINEMENT_H
00009 
00010 #include <vector>
00011 #include <opencv2/core/core.hpp>
00012 
00013 namespace tuw
00014 {
00015 
00016 class EllipseRefinement
00017 {
00018 public:
00019 
00020 
00021     class Parameter
00022     {
00023     public:
00024         int border;
00025         double min_gradient;
00026         Parameter(int _border=3, double _min_gradient=30)
00027             : border(_border), min_gradient(_min_gradient) {}
00028     };
00029 
00030 
00031     class Ellipse
00032     {
00033     private:
00034 
00035         double a2, b2, a4, b4;  // a^2 etc., stored for Distance()
00036         double x2,y2;
00037     public:
00038         int id;
00039         // ellipse position      [px]
00040         double x, y;
00041         // ellipse long/short axis length [px]
00042         double a, b;
00043         // ellipse rotation in radiants [rad]
00044         double phi;
00045         // mean fit error
00046         double fit_error;
00047         // ellipse support
00048         double support;
00049 
00052         Ellipse();
00055         Ellipse(const Ellipse &e);
00056         
00064         void setEllipse(const double &_x, const double &_y, const double &_a, const double &_b, const double &_phi);
00065 
00070         void setEllipse(const cv::RotatedRect& rect);
00071 
00076         void get(cv::RotatedRect &r);
00077 
00083         double ellipseCircumference(double a, double b);
00084         
00088         bool insideEllipse(double _a, double _b, double _x0, double _y0, double _phi, double _x, double _y) const;
00089 
00090         unsigned ellipseSupport(const std::vector<cv::Point2f> &points, double inl_dist, std::vector<bool> &inl_idx);
00091         
00092         bool computeAndSetGeomFromConic(double A, double B, double C, double D, double E, double F);
00093 
00094     };
00095 private:
00096 
00097     std::vector<cv::Point2d> pointsToUse;
00098 
00099 public:
00100     Parameter param;
00101 
00102     EllipseRefinement(const Parameter &_param = Parameter());
00103     ~EllipseRefinement();
00104 
00111     bool refine(const cv::Mat_<short> &im_dx, const cv::Mat_<short> &im_dy, const std::vector<cv::Point2f> &points, Ellipse &ellipse);
00112 };
00113 
00114 }
00115 
00116 #endif //TUW_ELLIPSE_REFINEMENT_H


tuw_ellipses
Author(s):
autogenerated on Sun May 29 2016 02:50:24