Commit: 41ad8cea51e7f4270f665a7afe966577da3b4001
Author: Tianwei Shen
Date:   Thu Jun 9 00:03:56 2016 +0800
Branches: soc-2016-multiview
https://developer.blender.org/rB41ad8cea51e7f4270f665a7afe966577da3b4001

make refine_flags into an array

===================================================================

M       intern/libmv/intern/reconstructionN.cc
M       intern/libmv/intern/reconstructionN.h
M       source/blender/blenkernel/intern/tracking_correspondence.c

===================================================================

diff --git a/intern/libmv/intern/reconstructionN.cc 
b/intern/libmv/intern/reconstructionN.cc
index 6a1fd7e..0e1e109 100644
--- a/intern/libmv/intern/reconstructionN.cc
+++ b/intern/libmv/intern/reconstructionN.cc
@@ -46,23 +46,109 @@ using mv::Reconstruction;
 using libmv::CameraIntrinsics;
 
 struct libmv_ReconstructionN {
-  mv::Reconstruction reconstruction;
+       mv::Reconstruction reconstruction;
 
-  /* Used for per-track average error calculation after reconstruction */
-  mv::Tracks tracks;
-  libmv::CameraIntrinsics *intrinsics;
+       /* Used for per-track average error calculation after reconstruction */
+       mv::Tracks tracks;
+       libmv::CameraIntrinsics *intrinsics;
 
-  double error;
-  bool is_valid;
+       double error;
+       bool is_valid;
 };
 
-libmv_ReconstructionN** libmv_solveMultiviewReconstruction(
-        const int clip_num,
+libmv_ReconstructionN** libmv_solveMultiviewReconstruction(const int clip_num,
         const libmv_TracksN **all_libmv_tracks,
         const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-        libmv_ReconstructionOptions *libmv_reconstruction_options,
+        libmv_MultiviewReconstructionOptions *libmv_reconstruction_options,
         reconstruct_progress_update_cb progress_update_callback,
         void* callback_customdata)
 {
+       //libmv_ReconstructionN *libmv_reconstruction =
+       //        LIBMV_OBJECT_NEW(libmv_ReconstructionN);
+
+       //Tracks &tracks = *((Tracks *) libmv_tracks);
+       //EuclideanReconstruction &reconstruction =
+       //        libmv_reconstruction->reconstruction;
+
+       //ReconstructUpdateCallback update_callback =
+       //        ReconstructUpdateCallback(progress_update_callback,
+       //                                  callback_customdata);
+
+       ///* Retrieve reconstruction options from C-API to libmv API. */
+       //CameraIntrinsics *camera_intrinsics;
+       //camera_intrinsics = libmv_reconstruction->intrinsics =
+       //        
libmv_cameraIntrinsicsCreateFromOptions(libmv_camera_intrinsics_options);
+
+       ///* Invert the camera intrinsics/ */
+       //Tracks normalized_tracks;
+       //libmv_getNormalizedTracks(tracks, *camera_intrinsics, 
&normalized_tracks);
+
+       ///* keyframe selection. */
+       //int keyframe1 = libmv_reconstruction_options->keyframe1,
+       //        keyframe2 = libmv_reconstruction_options->keyframe2;
+
+       //if (libmv_reconstruction_options->select_keyframes) {
+       //      LG << "Using automatic keyframe selection";
+
+       //      update_callback.invoke(0, "Selecting keyframes");
+
+       //      selectTwoKeyframesBasedOnGRICAndVariance(tracks,
+       //                                               normalized_tracks,
+       //                                               *camera_intrinsics,
+       //                                               keyframe1,
+       //                                               keyframe2);
+
+       //      /* so keyframes in the interface would be updated */
+       //      libmv_reconstruction_options->keyframe1 = keyframe1;
+       //      libmv_reconstruction_options->keyframe2 = keyframe2;
+       //}
+
+       ///* Actual reconstruction. */
+       //LG << "frames to init from: " << keyframe1 << " " << keyframe2;
+
+       //libmv::vector<Marker> keyframe_markers =
+       //        normalized_tracks.MarkersForTracksInBothImages(keyframe1, 
keyframe2);
+
+       //LG << "number of markers for init: " << keyframe_markers.size();
+
+       //if (keyframe_markers.size() < 8) {
+       //      LG << "No enough markers to initialize from";
+       //      libmv_reconstruction->is_valid = false;
+       //      return libmv_reconstruction;
+       //}
+
+       //update_callback.invoke(0, "Initial reconstruction");
+
+       //EuclideanReconstructTwoFrames(keyframe_markers, &reconstruction);
+       //EuclideanBundle(normalized_tracks, &reconstruction);
+       //EuclideanCompleteReconstruction(normalized_tracks,
+       //                                &reconstruction,
+       //                                &update_callback);
+
+       ///* Refinement/ */
+       //if (libmv_reconstruction_options->refine_intrinsics) {
+       //      libmv_solveRefineIntrinsics(
+       //                  tracks,
+       //                  libmv_reconstruction_options->refine_intrinsics,
+       //                  libmv::BUNDLE_NO_CONSTRAINTS,
+       //                  progress_update_callback,
+       //                  callback_customdata,
+       //                  &reconstruction,
+       //                  camera_intrinsics);
+       //}
+
+       ///* Set reconstruction scale to unity. */
+       //EuclideanScaleToUnity(&reconstruction);
+
+       ///* Finish reconstruction. */
+       //finishReconstruction(tracks,
+       //                     *camera_intrinsics,
+       //                     libmv_reconstruction,
+       //                     progress_update_callback,
+       //                     callback_customdata);
+
+       //libmv_reconstruction->is_valid = true;
+
+       //return (libmv_Reconstruction *) libmv_reconstruction;
        return (libmv_ReconstructionN**) NULL;
 }
diff --git a/intern/libmv/intern/reconstructionN.h 
b/intern/libmv/intern/reconstructionN.h
index a885ed9..727b387 100644
--- a/intern/libmv/intern/reconstructionN.h
+++ b/intern/libmv/intern/reconstructionN.h
@@ -35,11 +35,17 @@ extern "C" {
 
 typedef struct libmv_ReconstructionN libmv_ReconstructionN;
 
+typedef struct libmv_MultiviewReconstructionOptions {
+       int select_keyframes;
+       int keyframe1, keyframe2;
+       int *all_refine_intrinsics;             /* this should be an array 
since each clip has its own refine_flags */
+} libmv_MultiviewReconstructionOptions;
+
 libmv_ReconstructionN** libmv_solveMultiviewReconstruction(
         const int clip_num,
         const struct libmv_TracksN **all_libmv_tracks,
         const libmv_CameraIntrinsicsOptions *libmv_camera_intrinsics_options,
-        libmv_ReconstructionOptions* libmv_reconstruction_options,
+        libmv_MultiviewReconstructionOptions* libmv_reconstruction_options,
         reconstruct_progress_update_cb progress_update_callback,
         void* callback_customdata);
 
diff --git a/source/blender/blenkernel/intern/tracking_correspondence.c 
b/source/blender/blenkernel/intern/tracking_correspondence.c
index 7f67b2e..9919e66 100644
--- a/source/blender/blenkernel/intern/tracking_correspondence.c
+++ b/source/blender/blenkernel/intern/tracking_correspondence.c
@@ -64,11 +64,11 @@ typedef struct MovieMultiviewReconstructContext {
        libmv_CameraIntrinsicsOptions *all_camera_intrinsics_options;   /* 
camera intrinsic of each camera */
        TracksMap **all_tracks_map;                             /* tracks_map 
of each clip */
        int *all_sfra, *all_efra;                               /* start and 
end frame of each clip */
+       int *all_refine_flags;                          /* refine flags of each 
clip */
        ListBase *corr_base;                    /* a set of correspondence 
across clips */
 
        bool select_keyframes;
        int keyframe1, keyframe2;               /* the key frames selected from 
the primary camera */
-       int refine_flags;
        char object_name[MAX_NAME];
        bool is_camera;
        short motion_flag;
@@ -172,6 +172,7 @@ BKE_tracking_multiview_reconstruction_context_new(MovieClip 
**clips,
        context->all_camera_intrinsics_options = MEM_callocN(num_clips * 
sizeof(libmv_CameraIntrinsicsOptions), "MRC camera intrinsics");
        context->all_sfra = MEM_callocN(num_clips * sizeof(int), "MRC start 
frames");
        context->all_efra = MEM_callocN(num_clips * sizeof(int), "MRC end 
frames");
+       context->all_refine_flags = MEM_callocN(num_clips * sizeof(int), "MRC 
refine flags");
        context->keyframe1 = keyframe1;
        context->keyframe2 = keyframe2;
        context->clip_num = num_clips;
@@ -199,7 +200,6 @@ BKE_tracking_multiview_reconstruction_context_new(MovieClip 
**clips,
                        context->motion_flag = tracking->settings.motion_flag;
                        context->select_keyframes =
                                (tracking->settings.reconstruction_flag & 
TRACKING_USE_KEYFRAME_SELECTION) != 0;
-                       context->refine_flags = 
multiview_refine_intrinsics_get_flags(tracking, object);
                }
 
                tracking_cameraIntrinscisOptionsFromTracking(tracking,
@@ -207,6 +207,7 @@ BKE_tracking_multiview_reconstruction_context_new(MovieClip 
**clips,
                                                             
&context->all_camera_intrinsics_options[i]);
 
                context->all_tracks_map[i] = 
tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
+               context->all_refine_flags[i] = 
multiview_refine_intrinsics_get_flags(tracking, object);
 
                track = tracksbase->first;
                while (track) {
@@ -260,13 +261,14 @@ void 
BKE_tracking_multiview_reconstruction_context_free(MovieMultiviewReconstruc
        MEM_freeN(context->all_tracks_map);
        MEM_freeN(context->all_sfra);
        MEM_freeN(context->all_efra);
+       MEM_freeN(context->all_refine_flags);
 
        MEM_freeN(context);
 }
 
 
 /* Fill in multiview reconstruction options structure from reconstruction 
context. */
-static void reconstructionOptionsFromContext(libmv_ReconstructionOptions 
*reconstruction_options,
+static void 
multiviewReconstructionOptionsFromContext(libmv_MultiviewReconstructionOptions 
*reconstruction_options,
                                              MovieMultiviewReconstructContext 
*context)
 {
        reconstruction_options->select_keyframes = context->select_keyframes;
@@ -274,7 +276,7 @@ static void 
reconstructionOptionsFromContext(libmv_ReconstructionOptions *recons
        reconstruction_options->keyframe1 = context->keyframe1;
        reconstruction_options->keyframe2 = context->keyframe2;
 
-       reconstruction_options->refine_intrinsics = context->refine_flags;
+       reconstruction_options->all_refine_intrinsics = 
context->all_refine_flags;
 }
 
 /* Callback which is called from libmv side to update progress in the 
interface. */
@@ -306,7 +308,7 @@ void 
BKE_tracking_multiview_reconstruction_solve(MovieMultiviewReconstructContex
 
        MultiviewReconstructProgressData progressdata;
 
-       libmv_ReconstructionOptions reconstruction_options;
+       libmv_MultiviewReconstructionOptions reconstruction_options;
 
        progressdata.stop = stop;
        progressdata.do_update = do_update;
@@ -314,7 +316,7 @@ void 
BKE_tracking_multiview_reconstruction_solve(MovieMultiviewReconstructContex
        progressdata.stats_message = stats_message;
        progressdata.message_size = message_size;
 
-       reconstructionOptionsFromContext(&reconstruction_options, context);
+       multiviewReconstructionOptionsFromContext(&reconstruction_options, 
context);
 
        if (context->motion_flag & TRACKING_MOTION_MODAL) {
                // TODO(tianwei): leave tracking solve object for now

_______________________________________________
Bf-blender-cvs mailing list
[email protected]
https://lists.blender.org/mailman/listinfo/bf-blender-cvs

Reply via email to