Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'intern/libmv/intern/track_region.cc')
-rw-r--r--intern/libmv/intern/track_region.cc80
1 files changed, 51 insertions, 29 deletions
diff --git a/intern/libmv/intern/track_region.cc b/intern/libmv/intern/track_region.cc
index 2a3909c0ced..f434906407b 100644
--- a/intern/libmv/intern/track_region.cc
+++ b/intern/libmv/intern/track_region.cc
@@ -21,6 +21,7 @@
#include "intern/image.h"
#include "intern/utildefines.h"
#include "libmv/image/image.h"
+#include "libmv/logging/logging.h"
#include "libmv/tracking/track_region.h"
/* define this to generate PNG images with content of search areas
@@ -32,27 +33,53 @@
#undef DUMP_ALWAYS
using libmv::FloatImage;
+using libmv::TrackRegion;
using libmv::TrackRegionOptions;
using libmv::TrackRegionResult;
-using libmv::TrackRegion;
-void libmv_configureTrackRegionOptions(
- const libmv_TrackRegionOptions& options,
- TrackRegionOptions* track_region_options) {
- switch (options.motion_model) {
-#define LIBMV_CONVERT(the_model) \
- case TrackRegionOptions::the_model: \
- track_region_options->mode = TrackRegionOptions::the_model; \
- break;
+namespace {
+
+TrackRegionOptions::Direction convertDirection(
+ libmv_TrackRegionDirection direction) {
+ switch (direction) {
+ case LIBMV_TRACK_REGION_FORWARD: return TrackRegionOptions::FORWARD;
+ case LIBMV_TRACK_REGION_BACKWARD: return TrackRegionOptions::BACKWARD;
+ }
+
+ LOG(FATAL) << "Unhandled tracking direction " << direction
+ << ", should never happen.";
+
+ return TrackRegionOptions::FORWARD;
+}
+
+TrackRegionOptions::Mode convertMotionModelToMode(int motion_model) {
+ switch (motion_model) {
+#define LIBMV_CONVERT(the_model) \
+ case TrackRegionOptions::the_model: return TrackRegionOptions::the_model;
+
LIBMV_CONVERT(TRANSLATION)
LIBMV_CONVERT(TRANSLATION_ROTATION)
LIBMV_CONVERT(TRANSLATION_SCALE)
LIBMV_CONVERT(TRANSLATION_ROTATION_SCALE)
LIBMV_CONVERT(AFFINE)
LIBMV_CONVERT(HOMOGRAPHY)
+
#undef LIBMV_CONVERT
}
+ LOG(FATAL) << "Unhandled motion model " << motion_model
+ << ", should never happen.";
+
+ return TrackRegionOptions::TRANSLATION;
+}
+
+} // namespace
+
+void libmv_configureTrackRegionOptions(
+ const libmv_TrackRegionOptions& options,
+ TrackRegionOptions* track_region_options) {
+ track_region_options->direction = convertDirection(options.direction);
+ track_region_options->mode = convertMotionModelToMode(options.motion_model);
track_region_options->minimum_correlation = options.minimum_correlation;
track_region_options->max_iterations = options.num_iterations;
track_region_options->sigma = options.sigma;
@@ -66,7 +93,8 @@ void libmv_configureTrackRegionOptions(
* so disabling for now for until proper prediction model is landed.
*
* The thing is, currently blender sends input coordinates as the guess to
- * region tracker and in case of fast motion such an early out ruins the track.
+ * region tracker and in case of fast motion such an early out ruins the
+ * track.
*/
track_region_options->attempt_refine_before_brute = false;
track_region_options->use_normalized_intensities = options.use_normalization;
@@ -74,7 +102,7 @@ void libmv_configureTrackRegionOptions(
void libmv_regionTrackergetResult(const TrackRegionResult& track_region_result,
libmv_TrackRegionResult* result) {
- result->termination = (int) track_region_result.termination;
+ result->termination = (int)track_region_result.termination;
result->termination_reason = "";
result->correlation = track_region_result.correlation;
}
@@ -108,33 +136,27 @@ int libmv_trackRegion(const libmv_TrackRegionOptions* options,
libmv_configureTrackRegionOptions(*options, &track_region_options);
if (options->image1_mask) {
- libmv_floatBufferToFloatImage(options->image1_mask,
- image1_width,
- image1_height,
- 1,
- &image1_mask);
+ libmv_floatBufferToFloatImage(
+ options->image1_mask, image1_width, image1_height, 1, &image1_mask);
track_region_options.image1_mask = &image1_mask;
}
// Convert from raw float buffers to libmv's FloatImage.
FloatImage old_patch, new_patch;
- libmv_floatBufferToFloatImage(image1,
- image1_width,
- image1_height,
- 1,
- &old_patch);
- libmv_floatBufferToFloatImage(image2,
- image2_width,
- image2_height,
- 1,
- &new_patch);
+ libmv_floatBufferToFloatImage(
+ image1, image1_width, image1_height, 1, &old_patch);
+ libmv_floatBufferToFloatImage(
+ image2, image2_width, image2_height, 1, &new_patch);
TrackRegionResult track_region_result;
- TrackRegion(old_patch, new_patch,
- xx1, yy1,
+ TrackRegion(old_patch,
+ new_patch,
+ xx1,
+ yy1,
track_region_options,
- xx2, yy2,
+ xx2,
+ yy2,
&track_region_result);
// Convert to floats for the blender api.