Global motion work continued

Interface change for the global Mv functions.

Change-Id: Ie4722faa638ac557f99743f7b33ff46c3d29e9a1
This commit is contained in:
Spencer Egart 2015-02-20 11:16:23 -08:00 committed by Deb Mukherjee
parent 6fcaa06911
commit faaaf85fc3
2 changed files with 60 additions and 53 deletions

View File

@ -161,13 +161,11 @@ static int compute_global_motion_single(TransformationType type,
} }
// Returns number of models actually returned: 1 - if success, 0 - if failure // Returns number of models actually returned: 1 - if success, 0 - if failure
int vp9_compute_global_motion_single_feature_based(TransformationType type, int vp9_compute_global_motion_single_feature_based(
unsigned char *frmbuf, struct VP9_COMP *cpi,
unsigned char *refbuf, TransformationType type,
int width, YV12_BUFFER_CONFIG *frm,
int height, YV12_BUFFER_CONFIG *ref,
int frm_stride,
int ref_stride,
double *H) { double *H) {
int num_frm_corners, num_ref_corners; int num_frm_corners, num_ref_corners;
int num_correspondences; int num_correspondences;
@ -175,11 +173,14 @@ int vp9_compute_global_motion_single_feature_based(TransformationType type,
int num_inliers; int num_inliers;
int *inlier_map = NULL; int *inlier_map = NULL;
int frm_corners[2 * MAX_CORNERS], ref_corners[2 * MAX_CORNERS]; int frm_corners[2 * MAX_CORNERS], ref_corners[2 * MAX_CORNERS];
(void) cpi;
#ifdef USE_FAST_CORNER #ifdef USE_FAST_CORNER
num_frm_corners = FastCornerDetect(frmbuf, width, height, frm_stride, num_frm_corners = FastCornerDetect(frm->y_buffer, frm->y_width,
frm->y_height, frm->y_stride,
frm_corners, MAX_CORNERS); frm_corners, MAX_CORNERS);
num_ref_corners = FastCornerDetect(refbuf, width, height, ref_stride, num_ref_corners = FastCornerDetect(ref->y_buffer, ref->y_width,
ref->y_height, ref->y_stride,
ref_corners, MAX_CORNERS); ref_corners, MAX_CORNERS);
#else #else
num_frm_corners = HarrisCornerDetect(frmbuf, width, height, frm_stride, num_frm_corners = HarrisCornerDetect(frmbuf, width, height, frm_stride,
@ -192,15 +193,17 @@ int vp9_compute_global_motion_single_feature_based(TransformationType type,
printf("Reference corners = %d\n", num_ref_corners); printf("Reference corners = %d\n", num_ref_corners);
#endif #endif
correspondences = (int *)malloc( correspondences = (int *) malloc(num_frm_corners * 4 *
num_frm_corners * 4 * sizeof(int)); sizeof(*correspondences));
num_correspondences = determine_correspondence(frmbuf, (int*)frm_corners, num_correspondences = determine_correspondence(frm->y_buffer,
(int*)frm_corners,
num_frm_corners, num_frm_corners,
refbuf, (int*)ref_corners, ref->y_buffer,
(int*)ref_corners,
num_ref_corners, num_ref_corners,
width, height, frm->y_width, frm->y_height,
frm_stride, ref_stride, frm->y_stride, ref->y_stride,
correspondences); correspondences);
#ifdef VERBOSE #ifdef VERBOSE
printf("Number of correspondences = %d\n", num_correspondences); printf("Number of correspondences = %d\n", num_correspondences);
@ -289,13 +292,11 @@ static int compute_global_motion_multiple(TransformationType type,
} }
// Returns number of models actually returned // Returns number of models actually returned
int vp9_compute_global_motion_multiple_feature_based(TransformationType type, int vp9_compute_global_motion_multiple_feature_based(
unsigned char *frmbuf, struct VP9_COMP *cpi,
unsigned char *refbuf, TransformationType type,
int width, YV12_BUFFER_CONFIG *frm,
int height, YV12_BUFFER_CONFIG *ref,
int frm_stride,
int ref_stride,
int max_models, int max_models,
double inlier_prob, double inlier_prob,
double *H) { double *H) {
@ -306,11 +307,14 @@ int vp9_compute_global_motion_multiple_feature_based(TransformationType type,
int frm_corners[2 * MAX_CORNERS], ref_corners[2 * MAX_CORNERS]; int frm_corners[2 * MAX_CORNERS], ref_corners[2 * MAX_CORNERS];
int num_models = 0; int num_models = 0;
int *inlier_map = NULL; int *inlier_map = NULL;
(void) cpi;
#ifdef USE_FAST_CORNER #ifdef USE_FAST_CORNER
num_frm_corners = FastCornerDetect(frmbuf, width, height, frm_stride, num_frm_corners = FastCornerDetect(frm->y_buffer, frm->y_width,
frm->y_height, frm->y_stride,
frm_corners, MAX_CORNERS); frm_corners, MAX_CORNERS);
num_ref_corners = FastCornerDetect(refbuf, width, height, ref_stride, num_ref_corners = FastCornerDetect(ref->y_buffer, ref->y_width,
ref->y_height, ref->y_stride,
ref_corners, MAX_CORNERS); ref_corners, MAX_CORNERS);
#else #else
num_frm_corners = HarrisCornerDetect(frmbuf, width, height, frm_stride, num_frm_corners = HarrisCornerDetect(frmbuf, width, height, frm_stride,
@ -323,14 +327,17 @@ int vp9_compute_global_motion_multiple_feature_based(TransformationType type,
printf("Reference corners = %d\n", num_ref_corners); printf("Reference corners = %d\n", num_ref_corners);
#endif #endif
correspondences = (int *)malloc(num_frm_corners * 4 * sizeof(int)); correspondences = (int *) malloc(num_frm_corners * 4 *
sizeof(*correspondences));
num_correspondences = determine_correspondence(frmbuf, (int*)frm_corners, num_correspondences = determine_correspondence(frm->y_buffer,
(int*)frm_corners,
num_frm_corners, num_frm_corners,
refbuf, (int*)ref_corners, ref->y_buffer,
(int*)ref_corners,
num_ref_corners, num_ref_corners,
width, height, frm->y_width, frm->y_height,
frm_stride, ref_stride, frm->y_stride, ref->y_stride,
correspondences); correspondences);
#ifdef VERBOSE #ifdef VERBOSE
printf("Number of correspondences = %d\n", num_correspondences); printf("Number of correspondences = %d\n", num_correspondences);
@ -371,8 +378,10 @@ int vp9_compute_global_motion_single_block_based(struct VP9_COMP *cpi,
double confidence[4096]; double confidence[4096];
get_frame_motionfield(cpi, frm, ref, blocksize, motionfield, confidence); get_frame_motionfield(cpi, frm, ref, blocksize, motionfield, confidence);
correspondences = (int *)malloc(4 * cm->mb_rows * cm->mb_cols * correspondences = (int *)malloc(4 * cm->mb_rows * cm->mb_cols *
sizeof(*correspondences)); sizeof(*correspondences));
for (i = 0; i < cm->mb_rows * cm->mb_cols; i ++) { for (i = 0; i < cm->mb_rows * cm->mb_cols; i ++) {
int x = (i % cm->mb_cols) * blocksize + blocksize/2; int x = (i % cm->mb_cols) * blocksize + blocksize/2;
int y = (i / cm->mb_cols) * blocksize + blocksize/2; int y = (i / cm->mb_cols) * blocksize + blocksize/2;
@ -386,6 +395,7 @@ int vp9_compute_global_motion_single_block_based(struct VP9_COMP *cpi,
} }
inlier_map = (int *)malloc(num_correspondences * sizeof(*inlier_map)); inlier_map = (int *)malloc(num_correspondences * sizeof(*inlier_map));
num_inliers = compute_global_motion_single(type, correspondences, num_inliers = compute_global_motion_single(type, correspondences,
num_correspondences, H, num_correspondences, H,
inlier_map); inlier_map);
@ -420,6 +430,7 @@ int vp9_compute_global_motion_multiple_block_based(struct VP9_COMP *cpi,
MV motionfield[4096]; MV motionfield[4096];
double confidence[4096]; double confidence[4096];
get_frame_motionfield(cpi, frm, ref, blocksize, motionfield, confidence); get_frame_motionfield(cpi, frm, ref, blocksize, motionfield, confidence);
correspondences = (int *)malloc(4 * cm->mb_rows * cm->mb_cols * correspondences = (int *)malloc(4 * cm->mb_rows * cm->mb_cols *
sizeof(*correspondences)); sizeof(*correspondences));

View File

@ -21,13 +21,9 @@
#include "vp9_corner_match.h" #include "vp9_corner_match.h"
#include "vp9_ransac.h" #include "vp9_ransac.h"
// Default is Harris
#define USE_FAST_CORNER
#define MAX_CORNERS 4096
struct VP9_COMP; struct VP9_COMP;
const int CONFIDENCE_THRESHOLD = 40; static const int CONFIDENCE_THRESHOLD = 10;
typedef enum { typedef enum {
UNKNOWN_TRANSFORM = -1, UNKNOWN_TRANSFORM = -1,
@ -44,13 +40,10 @@ inline ransacType get_ransacType(TransformationType type);
inline projectPointsType get_projectPointsType(TransformationType type); inline projectPointsType get_projectPointsType(TransformationType type);
// Returns number of models actually returned: 1 - if success, 0 - if failure // Returns number of models actually returned: 1 - if success, 0 - if failure
int vp9_compute_global_motion_single_feature_based(TransformationType type, int vp9_compute_global_motion_single_feature_based(struct VP9_COMP *cpi,
unsigned char *frm, TransformationType type,
unsigned char *ref, YV12_BUFFER_CONFIG *frm,
int width, YV12_BUFFER_CONFIG *ref,
int height,
int frm_stride,
int ref_stride,
double *H); double *H);
// Returns number of models actually returned: 1+ - #models, 0 - if failure // Returns number of models actually returned: 1+ - #models, 0 - if failure
@ -60,13 +53,10 @@ int vp9_compute_global_motion_single_feature_based(TransformationType type,
// Ex. if max_models = 4, and inlier_prob = 0.8, and during the // Ex. if max_models = 4, and inlier_prob = 0.8, and during the
// process three models together already cover more than 80% of the // process three models together already cover more than 80% of the
// matching points, then only three models are returned. // matching points, then only three models are returned.
int vp9_compute_global_motion_multiple_feature_based(TransformationType type, int vp9_compute_global_motion_multiple_feature_based(struct VP9_COMP *cpi,
unsigned char *frm, TransformationType type,
unsigned char *ref, YV12_BUFFER_CONFIG *frm,
int width, YV12_BUFFER_CONFIG *ref,
int height,
int frm_stride,
int ref_stride,
int max_models, int max_models,
double inlier_prob, double inlier_prob,
double *H); double *H);
@ -79,7 +69,13 @@ int vp9_compute_global_motion_single_block_based(struct VP9_COMP *cpi,
int blocksize, int blocksize,
double *H); double *H);
// Returns number of models actually returned: 1 - if success, 0 - if failure // Returns number of models actually returned: 1+ - #models, 0 - if failure
// max_models is the maximum number of models returned
// inlier_prob is the probability of being inlier over all the models
// combined, beyond which no more models are computed.
// Ex. if max_models = 4, and inlier_prob = 0.8, and during the
// process three models together already cover more than 80% of the
// matching points, then only three models are returned.
int vp9_compute_global_motion_multiple_block_based(struct VP9_COMP *cpi, int vp9_compute_global_motion_multiple_block_based(struct VP9_COMP *cpi,
TransformationType type, TransformationType type,
YV12_BUFFER_CONFIG *frm, YV12_BUFFER_CONFIG *frm,