pub fn homography<OutType>(
) -> (Array<OutType>, i32) where
OutType: HasAfEnum + RealFloating,
Homography estimation find a perspective transform between two sets of 2D points. Currently, two methods are supported for the estimation, RANSAC (RANdom SAmple Consensus) and LMedS (Least Median of Squares). Both methods work by randomly selecting a subset of 4 points of the set of source points, computing the eigenvectors of that set and finding the perspective transform. The process is repeated several times, a maximum of times given by the value passed to the iterations arguments for RANSAC (for the CPU backend, usually less than that, depending on the quality of the dataset, but for CUDA and OpenCL backends the transformation will be computed exactly the amount of times passed via the iterations parameter), the returned value is the one that matches the best number of inliers, which are all of the points that fall within a maximum L2 distance from the value passed to the inlier_thr argument.
x_srcis the x coordinates of the source points.
y_srcis the y coordinates of the source points.
x_dstis the x coordinates of the destination points.
y_dstis the y coordinates of the destination points.
htypecan be AF_HOMOGRAPHY_RANSAC, for which a RANdom SAmple Consensus will be used to evaluate the homography quality (e.g., number of inliers), or AF_HOMOGRAPHY_LMEDS, which will use Least Median of Squares method to evaluate homography quality
inlier_thr- if htype is AF_HOMOGRAPHY_RANSAC, this parameter will five the maximum L2-distance for a point to be considered an inlier.
iterationsis the maximum number of iterations when htype is AF_HOMOGRAPHY_RANSAC and backend is CPU,if backend is CUDA or OpenCL, iterations is the total number of iterations, an iteration is a selection of 4 random points for which the homography is estimated and evaluated for number of inliers.
otypeis the array type for the homography output.
Returns a tuple of Array and int.
His a 3x3 array containing the estimated homography.
inliersis the number of inliers that the homography was estimated to comprise, in the case that htype is AF_HOMOGRAPHY_RANSAC, a higher inlier_thr value will increase the estimated inliers. Note that if the number of inliers is too low, it is likely that a bad homography will be returned.