-
Notifications
You must be signed in to change notification settings - Fork 12
/
ransac_ellipse2d.h
102 lines (81 loc) · 2.36 KB
/
ransac_ellipse2d.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#ifndef RANSAC_ELLIPSE2D_H_
#define RANSAC_ELLIPSE2D_H_
#include "ransac2d.h"
namespace sac
{
class ransacModelEllipse2D : public RansacModel
{
public:
using RansacModel::input_;
using RansacModel::indices_;
using RansacModel::error_sqr_dists_;
typedef RansacModel::PointCloud PointCloud;
ransacModelEllipse2D(const PointCloud &cloud,
double threshold,
int max_iterations)
:RansacModel(cloud, threshold, max_iterations)
{
spLAxis = 0;
spSAxis = 0;
spAngle = 0;
spRatio = 0.2;
m_dAvgError = -1;
}
ransacModelEllipse2D(const PointCloud &cloud,
const std::vector<int> &indices,
double threshold,
int max_iterations)
:RansacModel(cloud, indices, threshold, max_iterations)
{
spLAxis = 0;
spSAxis = 0;
spAngle = 0;
spRatio = 0.2;
m_dAvgError = -1;
}
ransacModelEllipse2D()
{
m_dAvgError = -1;
};
~ransacModelEllipse2D(){};
modelType getModelType()const{ return MODEL_ELLIPSE2D; }
inline double getAvgError(){ return m_dAvgError; }
bool isGoodSample(const std::vector<int> &samples) const;
bool computeModelCoefficients(const std::vector<int> &samples, ModelCoefficient &model_coefficient);
int countWithinDistance(const ModelCoefficient model_coefficients, const double threshold);
int countWithinDistance(const ModelCoefficient model_coefficients, const double threshold, double& avgError);
void selectWithinDistance(const ModelCoefficient model_coefficients, const double threshold, std::vector<int> &inliers);
/**
* \Brief: set the long/short axis and different ratio between the calculated axis
* \Details:
*/
inline void setSpecficAxisLength(const double lAxis, const double sAxis, const double ratioThld)
{
spLAxis = lAxis;
spSAxis = sAxis;
spRatio = ratioThld;
return;
}
/**
* \Brief: set specfic angle of the target ellipse
* \Details:
*/
inline void setSpecficAngle(const double angle)
{
spAngle = angle;
return;
}
/**
* \Brief: calculate model of 2D lines with 2 points
* \Details: 2 points represent a 2D lines consist of 4 parameters( first 2 is one point and last 2 is another)
*/
bool computeModel();
private:
double spLAxis;
double spSAxis;
double spAngle;
double spRatio;
double m_dAvgError;
};
}
#endif