40 lines
889 B
C++
40 lines
889 B
C++
#pragma once
|
|
#define _USE_MATH_DEFINES
|
|
|
|
#include "opencv2/imgproc/imgproc.hpp"
|
|
#include "opencv2/highgui/highgui.hpp"
|
|
#include <iostream>
|
|
#include <vector>
|
|
#include <string>
|
|
#include <math.h>
|
|
|
|
using namespace std;
|
|
using namespace cv;
|
|
|
|
class FeatureExtractor
|
|
{
|
|
public:
|
|
FeatureExtractor(vector<Point> 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<Point> &contour);
|
|
private:
|
|
vector<Point> 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);
|
|
};
|
|
|