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:
authorSergey Sharybin <sergey@blender.org>2021-03-15 17:22:03 +0300
committerSergey Sharybin <sergey@blender.org>2021-03-15 17:55:09 +0300
commit618c4b9daf216eb5d287fc7725d9154e21378219 (patch)
tree58c909c385d931d5221cb706cf04db829ecab266
parent1f7140e70955b2fbbea7a2fc6307c471c95f243e (diff)
Refactor Libmv C-API motion model conversion
Mode to an own utility function and guard missing enumerator values with a LOG(FATAL).
-rw-r--r--intern/libmv/intern/track_region.cc27
1 files changed, 20 insertions, 7 deletions
diff --git a/intern/libmv/intern/track_region.cc b/intern/libmv/intern/track_region.cc
index af88afd7ac2..334e331c7a8 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
@@ -36,23 +37,35 @@ using libmv::TrackRegion;
using libmv::TrackRegionOptions;
using libmv::TrackRegionResult;
-void libmv_configureTrackRegionOptions(
- const libmv_TrackRegionOptions& options,
- TrackRegionOptions* track_region_options) {
- switch (options.motion_model) {
+namespace {
+
+TrackRegionOptions::Mode convertMotionModelToMode(int motion_model) {
+ switch (motion_model) {
#define LIBMV_CONVERT(the_model) \
- case TrackRegionOptions::the_model: \
- track_region_options->mode = TrackRegionOptions::the_model; \
- break;
+ 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->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;