diff options
Diffstat (limited to 'extern/libmv')
-rw-r--r-- | extern/libmv/libmv-capi.cc | 59 | ||||
-rw-r--r-- | extern/libmv/libmv-capi.h | 17 | ||||
-rw-r--r-- | extern/libmv/libmv-capi_stub.cc | 23 |
3 files changed, 85 insertions, 14 deletions
diff --git a/extern/libmv/libmv-capi.cc b/extern/libmv/libmv-capi.cc index 74e9e52094d..2d3afcd16e7 100644 --- a/extern/libmv/libmv-capi.cc +++ b/extern/libmv/libmv-capi.cc @@ -158,6 +158,19 @@ static void imageToFloatBuf(const libmv::FloatImage *image, int channels, float } } +static void imageToByteBuf(const libmv::FloatImage *image, int channels, unsigned char *buf) +{ + int x, y, k, a = 0; + + for (y = 0; y < image->Height(); y++) { + for (x = 0; x < image->Width(); x++) { + for (k = 0; k < channels; k++) { + buf[a++] = (*image)(y, x, k) * 255.0f; + } + } + } +} + #if defined(DUMP_FAILURE) || defined (DUMP_ALWAYS) static void savePNGImage(png_bytep *row_pointers, int width, int height, int depth, int color_type, const char *file_name) @@ -385,10 +398,12 @@ int libmv_trackRegion(const libmv_TrackRegionOptions *options, return tracking_result; } -void libmv_samplePlanarPatch(const float *image, int width, int height, - int channels, const double *xs, const double *ys, +void libmv_samplePlanarPatch(const float *image, + int width, int height, int channels, + const double *xs, const double *ys, int num_samples_x, int num_samples_y, - const float *mask, float *patch, + const float *mask, + float *patch, double *warped_position_x, double *warped_position_y) { libmv::FloatImage libmv_image, libmv_patch, libmv_mask; @@ -402,13 +417,45 @@ void libmv_samplePlanarPatch(const float *image, int width, int height, libmv_mask_for_sample = &libmv_mask; } - libmv::SamplePlanarPatch(libmv_image, xs, ys, num_samples_x, num_samples_y, - libmv_mask_for_sample, &libmv_patch, - warped_position_x, warped_position_y); + libmv::SamplePlanarPatch(libmv_image, xs, ys, + num_samples_x, num_samples_y, + libmv_mask_for_sample, + &libmv_patch, + warped_position_x, + warped_position_y); imageToFloatBuf(&libmv_patch, channels, patch); } + void libmv_samplePlanarPatchByte(const unsigned char *image, + int width, int height, int channels, + const double *xs, const double *ys, + int num_samples_x, int num_samples_y, + const float *mask, + unsigned char *patch, + double *warped_position_x, double *warped_position_y) +{ + libmv::FloatImage libmv_image, libmv_patch, libmv_mask; + libmv::FloatImage *libmv_mask_for_sample = NULL; + + byteBufToImage(image, width, height, channels, &libmv_image); + + if (mask) { + floatBufToImage(mask, width, height, 1, &libmv_mask); + + libmv_mask_for_sample = &libmv_mask; + } + + libmv::SamplePlanarPatch(libmv_image, xs, ys, + num_samples_x, num_samples_y, + libmv_mask_for_sample, + &libmv_patch, + warped_position_x, + warped_position_y); + + imageToByteBuf(&libmv_patch, channels, patch); +} + /* ************ Tracks ************ */ struct libmv_Tracks *libmv_tracksNew(void) diff --git a/extern/libmv/libmv-capi.h b/extern/libmv/libmv-capi.h index d183bc4cd41..53bf40064fb 100644 --- a/extern/libmv/libmv-capi.h +++ b/extern/libmv/libmv-capi.h @@ -64,11 +64,22 @@ int libmv_trackRegion(const libmv_TrackRegionOptions *options, const double *x1, const double *y1, libmv_TrackRegionResult *result, double *x2, double *y2); -void libmv_samplePlanarPatch(const float *image, int width, int height, - int channels, const double *xs, const double *ys, +void libmv_samplePlanarPatch(const float *image, + int width, int height, + int channels, + const double *xs, const double *ys, int num_samples_x, int num_samples_y, - const float *mask, float *patch, + const float *mask, + float *patch, double *warped_position_x, double *warped_position_y); +void libmv_samplePlanarPatchByte(const unsigned char *image, + int width, int height, + int channels, + const double *xs, const double *ys, + int num_samples_x, int num_samples_y, + const float *mask, + unsigned char *patch, + double *warped_position_x, double *warped_position_y); /* Tracks */ struct libmv_Tracks *libmv_tracksNew(void); diff --git a/extern/libmv/libmv-capi_stub.cc b/extern/libmv/libmv-capi_stub.cc index bd5d16c9077..6db07974c47 100644 --- a/extern/libmv/libmv-capi_stub.cc +++ b/extern/libmv/libmv-capi_stub.cc @@ -68,11 +68,24 @@ int libmv_trackRegion(const libmv_TrackRegionOptions * /*options*/, return false; } -void libmv_samplePlanarPatch(const float *image, int width, int height, - int channels, const double *xs, const double *ys, - int num_samples_x, int num_samples_y, - const float *mask, float *patch, - double *warped_position_x, double *warped_position_y) +void libmv_samplePlanarPatch(const float * /*image*/, + int /*width*/, int /*height*/, int /*channels*/, + const double * /*xs*/, const double * /*ys*/, + int /*num_samples_x*/, int /*num_samples_y*/, + const float * /*mask*/, + float * /*patch*/, + double * /*warped_position_x*/, double * /*warped_position_y*/ +{ + /* TODO(sergey): implement */ +} + +void libmv_samplePlanarPatch(const unsigned char * /*image*/, + int /*width*/, int /*height*/, int /*channels*/, + const double * /*xs*/, const double * /*ys*/, + int /*num_samples_x*/, int /*num_samples_y*/, + const float * /*mask*/, + unsigned char * /*patch*/, + double * /*warped_position_x*/, double * /*warped_position_y*/ { /* TODO(sergey): implement */ } |