#pragma once #define _USE_MATH_DEFINES #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/highgui/highgui.hpp" #include #include #include #include using namespace std; using namespace cv; class FeatureExtractor { public: FeatureExtractor(vector contour); ~FeatureExtractor(); void Extract(Mat& ref); double AspectRatio(); double Circularity(); RotatedRect Rectangle(); double getMinEnclosingCircleRadius(); double getPerimeter(); double getBendingEnergy(); double getConvexHullBendingEnergy(); double convexDefects(); static void findContour(Mat &image, vector &contour); private: vector contour; RotatedRect rect; int rotateX[8] = { 0, 1, 1, 1, 0, -1, -1, -1 }; int rotateY[8] = { -1, -1, 0, 1, 1, 1, 0, -1 }; int discoverNextRelativeDirection(const cv::Point &pos, const cv::Point &target); };