1 #ifndef PERSONALITYMODULE_H 2 #define PERSONALITYMODULE_H 8 #include "ModuleInterface.h" 9 #include "src/hullmodel.h" 10 #include "src/supervisedstatisticalinfo.h" 14 #define M_1_DIV_2PI 0.159154943091895 23 bool setParameters(QDomNode& config);
32 bool updateParameters();
35 int readSupervisedData();
40 void getPersonalityPreAngular(QImage *current,
41 std::vector< std::vector<cv::Point> > &ccontours);
42 void getPersonalityFromAngular(std::vector< std::vector<cv::Point> > &contours,
47 static void getFarPoints(cv::Mat im,
float dx,
float dy, cv::Point2f &r1, cv::Point2f &r2,
float mean_x,
float mean_y);
48 static bool pointInNeighborhood(cv::Mat im,
float pos_x,
float pos_y,
50 static bool movementFound(cv::Mat f,
int wsize,
int i0,
int j0);
51 static bool movementFound(cv::Mat f,
int wsize,
int i0,
int j0, cv::Rect roi);
52 static double histogramDistance(cv::MatND h1, cv::MatND h2);
53 static double distanceToSegment(
int i1,
int i2, std::vector<cv::Point> &contour);
54 static bool lineSegmentIntersection(cv::Point3f &line,
55 cv::Point2f &p1, cv::Point2f &p2, cv::Point2f &r);
56 static bool getGeneralLineForm(cv::Point2f p1, cv::Point2f p2,
58 static bool getGeneralLineForm(
float x,
float y,
float dx,
float dy,
65 static int getContourToLineIntersection(std::vector<cv::Point> &hull,
67 cv::Point2f &r1, cv::Point2f &r2,
68 int *n1 = NULL,
int *n2 = NULL);
71 void getNormalIntersections(cv::Mat &f, cv::Rect &roi, std::vector<cv::Point> &hull,
72 cv::Point2f &r1, cv::Point2f &r2,
int n1,
int n2,
76 void setForegroundSegment(cv::Mat &f, cv::Rect &roi, std::vector<cv::Point> &hull,
78 float dx,
float dy,
int &I1,
int &I2);
82 static int getContourToLineIntersectionIndexed(std::vector<cv::Point> &polygon,
84 cv::Point2f &r1, cv::Point2f &r2,
88 static int movementCount(cv::Mat f,
int wsize,
int i0,
int j0, cv::Rect roi);
92 static void safeCopyQImageToMat(QImage &q, cv::Mat &m);
95 static void drawContourToMat(std::vector<cv::Point> &v, cv::Mat &m);
98 static void drawContourToMat(std::vector<cv::Point> &v, cv::Mat &m, cv::Scalar color);
101 static void blurContour(std::vector<cv::Point> &contour,
102 int scale,
int step);
105 void connectContours(std::vector< std::vector<cv::Point> > &contours,
106 std::vector< std::vector<cv::Point> > &ccontours);
109 void filterContours(std::vector< std::vector<cv::Point> > &contours,
110 std::vector< std::vector<cv::Point> > &fcontours,
114 void drawPointsToMat(std::vector<cv::Point2f> &pca_points, cv::Mat &m);
116 void drawKMeansPointsToMat(std::vector<cv::Point2f> &pca_points, cv::Mat &m,
117 cv::Mat &klabels, cv::Mat &kcenters,
int K);
122 void prepareImage(cv::Mat ¤t);
125 void getShapeBorder(cv::Mat ¤t, cv::Mat &border);
128 int getCentroid(cv::Mat &image,
float x,
float y);
131 void getMainAxis(cv::Mat &image,
float x,
float y,
int n,
132 cv::Point2f &r1, cv::Point2f &r2);
135 void getAngularFunction(std::vector<float> &angular,
136 std::vector< std::vector<cv::Point> > &contours);
139 void getHistogram(std::vector<float> &input, cv::MatND &hist);
141 cv::PCA *getPCAfromHistograms(std::vector<cv::MatND> h);
142 cv::PCA *getPCAfromHistograms(std::vector<cv::MatND> h, cv::Mat &pcadata, cv::Mat &pcamean);
144 cv::PCA *getPCA(cv::Mat &pcadata, cv::Mat &pcamean);
147 cv::Mat getKMeansFromPCA(cv::PCA *pca, cv::Mat &pcadata, cv::Mat &pcamean);
150 float crossValidation(std::vector<SupervisedStatisticalInfo> &supervised, std::vector< cv::Ptr<cv::ml::ANN_MLP> > &anns,
float &rel_error);
152 void getModel(std::vector<SupervisedStatisticalInfo> &sup,
153 cv::Ptr<cv::ml::ANN_MLP> &ann,
bool mean,
bool reliability);
155 float getPrediction(cv::Ptr<cv::ml::ANN_MLP> ann,
158 std::vector<cv::Ptr<cv::ml::ANN_MLP> > anns;
160 float crossValidation(std::vector<SupervisedStatisticalInfo> &supervised, std::vector<CvANN_MLP> &anns,
float &rel_error);
162 void getModel(std::vector<SupervisedStatisticalInfo> &sup,
163 CvANN_MLP &ann,
bool mean,
bool reliability);
165 float getPrediction(CvANN_MLP &ann,
168 std::vector<CvANN_MLP> anns;
174 int m_min_images_to_process;
175 int processed_images;
179 bool m_abs_angular_diff;
186 bool m_use_reliability;
188 std::vector<cv::MatND> histograms;
189 std::vector<SupervisedStatisticalInfo> supervised;
191 std::vector< std::vector< std::vector<cv::Point> > > image_contours;
193 std::map<int, double> gaussianConstant;
194 std::map<int, double> gaussianFactor;
196 std::vector<std::string> names;
197 std::vector<bool> elegant;
199 std::string m_supervisedFile;
200 int m_min_contour_length;
208 std::ostream& operator<<(std::ostream& out, cv::ml::ANN_MLP &ann);
210 std::ostream& operator<<(std::ostream& out, CvANN_MLP &ann);
213 #endif // PERSONALITYMODULE_H Definition: geometric.h:103
Definition: supervisedstatisticalinfo.h:9
Definition: ModuleInterface.h:43
An object of this class is instantiated at main code, and this object is used by every class to push ...
Definition: Datapool.h:39
Definition: PersonalityModule.h:17