Commit d8941da5 authored by emilkeyder@google.com's avatar emilkeyder@google.com Committed by Emil Keyder

Remove inlier_map argument from ransac methods.

Change-Id: I111180626f51a866f6b3ba17d17156d74ad53d57
parent 31b6a4f9
......@@ -241,15 +241,14 @@ static INLINE RansacFunc get_ransac_type(TransformationType type) {
// computes global motion parameters by fitting a model using RANSAC
static int compute_global_motion_params(TransformationType type,
int *correspondences,
int num_correspondences, double *params,
int *inlier_map) {
int num_correspondences,
double *params) {
int result;
int num_inliers = 0;
RansacFunc ransac = get_ransac_type(type);
if (ransac == NULL) return 0;
result = ransac(correspondences, num_correspondences, &num_inliers,
inlier_map, params);
result = ransac(correspondences, num_correspondences, &num_inliers, params);
if (!result && num_inliers < MIN_INLIER_PROB * num_correspondences) {
result = 1;
num_inliers = 0;
......@@ -284,7 +283,6 @@ int compute_global_motion_feature_based(TransformationType type,
int *correspondences;
int num_inliers;
int frm_corners[2 * MAX_CORNERS], ref_corners[2 * MAX_CORNERS];
int *inlier_map = NULL;
unsigned char *frm_buffer = frm->y_buffer;
unsigned char *ref_buffer = ref->y_buffer;
......@@ -319,10 +317,8 @@ int compute_global_motion_feature_based(TransformationType type,
(int *)ref_corners, num_ref_corners, frm->y_width, frm->y_height,
frm->y_stride, ref->y_stride, correspondences);
inlier_map = (int *)malloc(num_correspondences * sizeof(*inlier_map));
num_inliers = compute_global_motion_params(
type, correspondences, num_correspondences, params, inlier_map);
num_inliers = compute_global_motion_params(type, correspondences,
num_correspondences, params);
free(correspondences);
free(inlier_map);
return (num_inliers > 0);
}
......@@ -156,7 +156,7 @@ static int get_rand_indices(int npoints, int minpts, int *indices,
}
static int ransac(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_mask, double *best_params, const int minpts,
double *best_params, const int minpts,
IsDegenerateFunc is_degenerate,
FindTransformationFunc find_transformation,
ProjectPointsDoubleFunc projectpoints) {
......@@ -183,7 +183,6 @@ static int ransac(int *matched_points, int npoints, int *number_of_inliers,
double *corners1;
double *corners2;
double *image1_coord;
int *inlier_mask;
double *cnp1, *cnp2;
......@@ -202,10 +201,9 @@ static int ransac(int *matched_points, int npoints, int *number_of_inliers,
corners1 = (double *)aom_malloc(sizeof(*corners1) * npoints * 2);
corners2 = (double *)aom_malloc(sizeof(*corners2) * npoints * 2);
image1_coord = (double *)aom_malloc(sizeof(*image1_coord) * npoints * 2);
inlier_mask = (int *)aom_malloc(sizeof(*inlier_mask) * npoints);
if (!(best_inlier_set1 && best_inlier_set2 && inlier_set1 && inlier_set2 &&
corners1 && corners2 && image1_coord && inlier_mask)) {
corners1 && corners2 && image1_coord)) {
ret_val = 1;
goto finish_ransac;
}
......@@ -260,8 +258,7 @@ static int ransac(int *matched_points, int npoints, int *number_of_inliers,
double dy = image1_coord[i * 2 + 1] - corners2[i * 2 + 1];
double distance = sqrt(dx * dx + dy * dy);
inlier_mask[i] = distance < INLIER_THRESHOLD;
if (inlier_mask[i]) {
if (distance < INLIER_THRESHOLD) {
inlier_set1[num_inliers * 2] = corners1[i * 2];
inlier_set1[num_inliers * 2 + 1] = corners1[i * 2 + 1];
inlier_set2[num_inliers * 2] = corners2[i * 2];
......@@ -291,8 +288,6 @@ static int ransac(int *matched_points, int npoints, int *number_of_inliers,
num_inliers * 2 * sizeof(*best_inlier_set1));
memcpy(best_inlier_set2, inlier_set2,
num_inliers * 2 * sizeof(*best_inlier_set2));
memcpy(best_inlier_mask, inlier_mask,
npoints * sizeof(*best_inlier_mask));
assert(npoints > 0);
fracinliers = (double)num_inliers / (double)npoints;
......@@ -318,7 +313,6 @@ finish_ransac:
aom_free(corners1);
aom_free(corners2);
aom_free(image1_coord);
aom_free(inlier_mask);
return ret_val;
}
......@@ -343,45 +337,43 @@ static int is_degenerate_homography(double *p) {
}
int ransac_translation(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_mask, double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_inlier_mask,
best_params, 3, is_degenerate_translation, find_translation,
double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_params, 3,
is_degenerate_translation, find_translation,
project_points_double_translation);
}
int ransac_rotzoom(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_mask, double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_inlier_mask,
best_params, 3, is_degenerate_affine, find_rotzoom,
double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_params, 3,
is_degenerate_affine, find_rotzoom,
project_points_double_rotzoom);
}
int ransac_affine(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_mask, double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_inlier_mask,
best_params, 3, is_degenerate_affine, find_affine,
double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_params, 3,
is_degenerate_affine, find_affine,
project_points_double_affine);
}
int ransac_homography(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_mask, double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_inlier_mask,
best_params, 4, is_degenerate_homography, find_homography,
double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_params, 4,
is_degenerate_homography, find_homography,
project_points_double_homography);
}
int ransac_hortrapezoid(int *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_mask,
double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_inlier_mask,
best_params, 4, is_degenerate_homography, find_hortrapezoid,
int *number_of_inliers, double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_params, 4,
is_degenerate_homography, find_hortrapezoid,
project_points_double_hortrapezoid);
}
int ransac_vertrapezoid(int *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_mask,
double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_inlier_mask,
best_params, 4, is_degenerate_homography, find_vertrapezoid,
int *number_of_inliers, double *best_params) {
return ransac(matched_points, npoints, number_of_inliers, best_params, 4,
is_degenerate_homography, find_vertrapezoid,
project_points_double_vertrapezoid);
}
......@@ -20,23 +20,20 @@
#include "av1/common/warped_motion.h"
typedef int (*RansacFunc)(int *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_mask,
double *best_params);
int *number_of_inliers, double *best_params);
/* Each of these functions fits a motion model from a set of
corresponding points in 2 frames using RANSAC. */
int ransac_homography(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_indices, double *best_params);
double *best_params);
int ransac_affine(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_indices, double *best_params);
double *best_params);
int ransac_hortrapezoid(int *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_indices,
double *best_params);
int *number_of_inliers, double *best_params);
int ransac_vertrapezoid(int *matched_points, int npoints,
int *number_of_inliers, int *best_inlier_indices,
double *best_params);
int *number_of_inliers, double *best_params);
int ransac_rotzoom(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_indices, double *best_params);
double *best_params);
int ransac_translation(int *matched_points, int npoints, int *number_of_inliers,
int *best_inlier_indices, double *best_params);
double *best_params);
#endif // AV1_ENCODER_RANSAC_H_
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment