Main MRPT website > C++ reference for MRPT 1.5.7
Classes | Macros | Typedefs | Functions
xform.h File Reference
#include <mrpt/otherlibs/do_opencv_includes.h>
Include dependency graph for xform.h:

Go to the source code of this file.

Classes

struct  ransac_data
 holds feature data relevant to ransac More...
 

Macros

#define RANSAC_ERR_TOL   3
 
#define RANSAC_INLIER_FRAC_EST   0.25
 pessimistic estimate of fraction of inlers for RANSAC More...
 
#define RANSAC_PROB_BAD_SUPP   0.10
 estimate of the probability that a correspondence supports a bad model More...
 
#define feat_ransac_data(feat)   ( (struct ransac_data*) (feat)->feature_data )
 

Typedefs

typedef CvMat *(* ransac_xform_fn) (CvPoint2D64f *pts, CvPoint2D64f *mpts, int n)
 
Prototype for transformation functions passed to ransac_xform(). More...
 
typedef double(* ransac_err_fn) (CvPoint2D64f pt, CvPoint2D64f mpt, CvMat *M)
 
Prototype for error functions passed to ransac_xform(). More...
 

Functions

CvMat * ransac_xform (struct feature *features, int n, int mtype, ransac_xform_fn xform_fn, int m, double p_badxform, ransac_err_fn err_fn, double err_tol, struct feature ***inliers, int *n_in)
 
Calculates a best-fit image transform from image feature correspondences using RANSAC. More...
 
CvMat * lsq_homog (CvPoint2D64f *pts, CvPoint2D64f *mpts, int n)
 
Calculates a least-squares planar homography from point correspondeces. More...
 
double homog_xfer_err (CvPoint2D64f pt, CvPoint2D64f mpt, CvMat *H)
 
Calculates the transfer error between a point and its correspondence for a given homography, i.e. More...
 
CvPoint2D64f persp_xform_pt (CvPoint2D64f pt, CvMat *T)
 
Performs a perspective transformation on a single point. More...
 

Macro Definition Documentation

◆ feat_ransac_data

#define feat_ransac_data (   feat)    ( (struct ransac_data*) (feat)->feature_data )

Definition at line 41 of file xform.h.

◆ RANSAC_ERR_TOL

#define RANSAC_ERR_TOL   3

Definition at line 32 of file xform.h.

◆ RANSAC_INLIER_FRAC_EST

#define RANSAC_INLIER_FRAC_EST   0.25

pessimistic estimate of fraction of inlers for RANSAC

Definition at line 35 of file xform.h.

◆ RANSAC_PROB_BAD_SUPP

#define RANSAC_PROB_BAD_SUPP   0.10

estimate of the probability that a correspondence supports a bad model

Definition at line 38 of file xform.h.

Typedef Documentation

◆ ransac_err_fn

typedef double(* ransac_err_fn) (CvPoint2D64f pt, CvPoint2D64f mpt, CvMat *M)


Prototype for error functions passed to ransac_xform().

For a given point, its correspondence, and a transform, functions of this type should compute a measure of error between the correspondence and the point after the point has been transformed by the transform.

Parameters
pta point
mptpt's correspondence
Ta transform
Returns
Should return a measure of error between mpt and pt after pt has been transformed by the transform T.

Definition at line 74 of file xform.h.

◆ ransac_xform_fn

typedef CvMat*(* ransac_xform_fn) (CvPoint2D64f *pts, CvPoint2D64f *mpts, int n)


Prototype for transformation functions passed to ransac_xform().

Functions of this type should compute a transformation matrix given a set of point correspondences.

Parameters
ptsarray of points
mptsarray of corresponding points; each pts[i], i=0..n-1, corresponds to mpts[i]
nnumber of points in both pts and mpts
Returns
Should return a transformation matrix that transforms each point in pts to the corresponding point in mpts or NULL on failure.

Definition at line 57 of file xform.h.

Function Documentation

◆ homog_xfer_err()

double homog_xfer_err ( CvPoint2D64f  pt,
CvPoint2D64f  mpt,
CvMat *  H 
)


Calculates the transfer error between a point and its correspondence for a given homography, i.e.

for a point $x$, it's correspondence $x'$, and homography $H$, computes $d(x', Hx)^2$. Intended for use as a ransac_err_fn.

Parameters
pta point
mptpt's correspondence
Ha homography matrix
Returns
Returns the transfer error between pt and mpt given H

◆ lsq_homog()

CvMat* lsq_homog ( CvPoint2D64f *  pts,
CvPoint2D64f *  mpts,
int  n 
)


Calculates a least-squares planar homography from point correspondeces.

Intended for use as a ransac_xform_fn.

Parameters
ptsarray of points
mptsarray of corresponding points; each pts[i], i=0..n-1, corresponds to mpts[i]
nnumber of points in both pts and mpts; must be at least 4
Returns
Returns the $3 \times 3$ least-squares planar homography matrix that transforms points in pts to their corresponding points in mpts or NULL if fewer than 4 correspondences were provided

◆ persp_xform_pt()

CvPoint2D64f persp_xform_pt ( CvPoint2D64f  pt,
CvMat *  T 
)


Performs a perspective transformation on a single point.

That is, for a point $(x, y)$ and a $3 \times 3$ matrix $T$ this function returns the point $(u, v)$, where

$[x' \ y' \ w']^T = T \times [x \ y \ 1]^T$,

and

$(u, v) = (x'/w', y'/w')$.

Note that affine transforms are a subset of perspective transforms.

Parameters
pta 2D point
Ta perspective transformation matrix
Returns
Returns the point $(u, v)$ as above.

◆ ransac_xform()

CvMat* ransac_xform ( struct feature features,
int  n,
int  mtype,
ransac_xform_fn  xform_fn,
int  m,
double  p_badxform,
ransac_err_fn  err_fn,
double  err_tol,
struct feature ***  inliers,
int *  n_in 
)


Calculates a best-fit image transform from image feature correspondences using RANSAC.

For more information refer to:

Fischler, M. A. and Bolles, R. C. Random sample consensus: a paradigm for model fitting with applications to image analysis and automated cartography. Communications of the ACM, 24, 6 (1981), pp. 381–395.

Parameters
featuresan array of features; only features with a non-NULL match of type mtype are used in homography computation
nnumber of features in feat
mtypedetermines which of each feature's match fields to use for transform computation; should be one of FEATURE_FWD_MATCH, FEATURE_BCK_MATCH, or FEATURE_MDL_MATCH; if this is FEATURE_MDL_MATCH, correspondences are assumed to be between a feature's img_pt field and its match's mdl_pt field, otherwise correspondences are assumed to be between the the feature's img_pt field and its match's img_pt field
xform_fnpointer to the function used to compute the desired transformation from feature correspondences
mminimum number of correspondences necessary to instantiate the transform computed by xform_fn
p_badxformdesired probability that the final transformation returned by RANSAC is corrupted by outliers (i.e. the probability that no samples of all inliers were drawn)
err_fnpointer to the function used to compute a measure of error between putative correspondences for a given transform
err_tolcorrespondences within this distance of each other are considered as inliers for a given transform
inliersif not NULL, output as an array of pointers to the final set of inliers
n_inif not NULL, output as the final number of inliers
Returns
Returns a transformation matrix computed using RANSAC or NULL on error or if an acceptable transform could not be computed.



Page generated by Doxygen 1.8.14 for MRPT 1.5.7 Git: 5902e14cc Wed Apr 24 15:04:01 2019 +0200 at lun oct 28 01:39:17 CET 2019