Implementation of a general RANdom SAmple Consensus algorithm with implicit parameters.
More...
|
void | _doEstimate (int *params, int param_c, void *model) |
|
bool | _doSupports (int param, void *model) |
|
virtual void | doEstimate (int *params, int param_c, MODEL *model)=0 |
| Creates a model estimate from a set of parameters. More...
|
|
virtual bool | doSupports (int param, MODEL *model)=0 |
| Computes how well a parameters supports a model. More...
|
|
virtual void | _doEstimate (void **params, int param_c, void *model) |
|
virtual bool | _doSupports (void *param, void *model) |
|
int | _estimate (void *params, int param_c, int support_limit, int max_rounds, void *model) |
|
int | _estimate (int param_c, int support_limit, int max_rounds, void *model) |
|
int | _refine (void *params, int param_c, int support_limit, int max_rounds, void *model, char *inlier_mask=NULL) |
|
int | _refine (int param_c, int support_limit, int max_rounds, void *model, char *inlier_mask=NULL) |
|
| RansacImpl (int min_params, int max_params, int sizeof_param, int sizeof_model) |
|
| RansacImpl (int min_params, int max_params, int sizeof_model) |
|
virtual | ~RansacImpl () |
|
template<typename MODEL>
class alvar::IndexRansac< MODEL >
Implementation of a general RANdom SAmple Consensus algorithm with implicit parameters.
These parameters are accessed by indises. The benefit of this is that we avoid copying input data from an array into another. See Ransac class for more details.
Extending class must provide two methods:
void doEstimate(
int* params,
int param_c, MODEL* model);
Example fitting points to a line (compare this with the example in the Ransac class):
typedef struct Point {
double x,
double y; };
typedef struct Line {
Point p1, p2; };
class MyLineFittingRansac :
public IndexRansac<Line, Point> {
MyLineFittingRansac(Points *input) : Ransac(2, 16), points(input) {}
void doEstimate(
int *indises,
int points_c, Line *line) {
if (points_c == 2) { return Line(points[indises[0]], *points[indises[1]]); }
else {
}
Point *point = &points[index];
return distance < POINT_DISTANCE_LIMIT;
}
};
Point input[N_POINTS] = { .. };
Line line;
MyLineFittingRansac ransac(input);
int max_rounds = ransac.estimateRequiredRounds(0.99, 0.6);
int number_of_inliers = ransac.estimate(input, N_POINTS, N_POINTS, max_rounds, &line);
if (number_of_inliers > 0 && number_of_inliers < N_POINTS)
number_of_inliers = ransac.refine(input, N_POINTS, N_POINTS, 10, &line);
double inlier_percentage = (double)number_of_inliers / (double)N_POINTS;
Definition at line 343 of file Ransac.h.
template<typename MODEL >
int alvar::IndexRansac< MODEL >::estimate |
( |
int |
param_c, |
|
|
int |
support_limit, |
|
|
int |
max_rounds, |
|
|
MODEL * |
model |
|
) |
| |
|
inline |
Estimates a model from input data parameters.
Randomly samples min_params number of input data elements from params array and chooses the model that has the largest set of supporting parameters (inliers) in the params array.
Note that this method always uses min_params number of parameters, that is, doEstimate method can be implemented to support only the minimum number of parameters unless refine method is used.
- Parameters
-
param_c | Number of parameters available in estimation. |
support_limit | The search is stopped if a model receives more support that this limit. |
max_rounds | How many different samples are tried before stopping the search. |
model | The estimated model is stored here. |
- Returns
- the number of parameters supporting the model, or 0 if a suitable model could not be build at all.
Definition at line 421 of file Ransac.h.
template<typename MODEL >
int alvar::IndexRansac< MODEL >::refine |
( |
int |
param_c, |
|
|
int |
support_limit, |
|
|
int |
max_rounds, |
|
|
MODEL * |
model, |
|
|
char * |
inlier_mask = NULL |
|
) |
| |
|
inline |
Iteratively makes the estimated model better.
Starting with the estimated model, computes the model from all inlier parameters and interates until no new parameters support the model.
Note that this method uses up to max_params number of parameters, that is, doEstimate method must be implemented in such a way that it can estimate a model from a variable number of parameters.
- Parameters
-
param_c | Number of parameters available for estimation. |
support_limit | The search is stopped if a model receives more support that this limit. |
max_rounds | How many iterations of the refinement are run. |
model | The estimated model that is refined. |
inlier_mask | Byte array where 1 is stored for inliers and 0 for outliers. |
- Returns
- the number of parameters supporting the model.
Definition at line 445 of file Ransac.h.