diff options
-rw-r--r-- | extern/libmv/intern/reconstruction.cc | 13 | ||||
-rw-r--r-- | extern/libmv/intern/reconstruction.h | 2 | ||||
-rw-r--r-- | extern/libmv/intern/stub.cc | 4 | ||||
-rw-r--r-- | source/blender/blenkernel/intern/tracking_solver.c | 7 |
4 files changed, 25 insertions, 1 deletions
diff --git a/extern/libmv/intern/reconstruction.cc b/extern/libmv/intern/reconstruction.cc index f89efd8e8ca..046671e467f 100644 --- a/extern/libmv/intern/reconstruction.cc +++ b/extern/libmv/intern/reconstruction.cc @@ -61,6 +61,7 @@ struct libmv_Reconstruction { CameraIntrinsics *intrinsics; double error; + bool is_valid; }; namespace { @@ -289,6 +290,12 @@ libmv_Reconstruction *libmv_solveReconstruction( 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); @@ -319,6 +326,7 @@ libmv_Reconstruction *libmv_solveReconstruction( progress_update_callback, callback_customdata); + libmv_reconstruction->is_valid = true; return (libmv_Reconstruction *) libmv_reconstruction; } @@ -377,9 +385,14 @@ libmv_Reconstruction *libmv_solveModal( progress_update_callback, callback_customdata); + libmv_reconstruction->is_valid = true; return (libmv_Reconstruction *) libmv_reconstruction; } +int libmv_reconstructionIsValid(libmv_Reconstruction *libmv_reconstruction) { + return libmv_reconstruction->is_valid; +} + void libmv_reconstructionDestroy(libmv_Reconstruction *libmv_reconstruction) { LIBMV_OBJECT_DELETE(libmv_reconstruction->intrinsics, CameraIntrinsics); LIBMV_OBJECT_DELETE(libmv_reconstruction, libmv_Reconstruction); diff --git a/extern/libmv/intern/reconstruction.h b/extern/libmv/intern/reconstruction.h index 88e810b54aa..8b6b34a6142 100644 --- a/extern/libmv/intern/reconstruction.h +++ b/extern/libmv/intern/reconstruction.h @@ -68,6 +68,8 @@ libmv_Reconstruction* libmv_solveModal( reconstruct_progress_update_cb progress_update_callback, void* callback_customdata); +int libmv_reconstructionIsValid(libmv_Reconstruction *libmv_reconstruction); + void libmv_reconstructionDestroy(libmv_Reconstruction* libmv_reconstruction); int libmv_reprojectionPointForTrack( diff --git a/extern/libmv/intern/stub.cc b/extern/libmv/intern/stub.cc index f307d831475..f02509de90a 100644 --- a/extern/libmv/intern/stub.cc +++ b/extern/libmv/intern/stub.cc @@ -138,6 +138,10 @@ libmv_Reconstruction *libmv_solveModal( return NULL; } +int libmv_reconstructionIsValid(libmv_Reconstruction * /*libmv_reconstruction*/) { + return 0; +} + int libmv_reprojectionPointForTrack( const libmv_Reconstruction * /*libmv_reconstruction*/, int /*track*/, diff --git a/source/blender/blenkernel/intern/tracking_solver.c b/source/blender/blenkernel/intern/tracking_solver.c index 6d4e7efa815..d5e2f24e9ed 100644 --- a/source/blender/blenkernel/intern/tracking_solver.c +++ b/source/blender/blenkernel/intern/tracking_solver.c @@ -391,7 +391,7 @@ MovieReconstructContext *BKE_tracking_reconstruction_context_new(MovieClip *clip last_marker--; } - if (first < track->markersnr - 1) + if (first <= track->markersnr - 1) sfra = min_ii(sfra, first_marker->framenr); if (last >= 0) @@ -509,6 +509,11 @@ bool BKE_tracking_reconstruction_finish(MovieReconstructContext *context, MovieT MovieTrackingReconstruction *reconstruction; MovieTrackingObject *object; + if (!libmv_reconstructionIsValid(context->reconstruction)) { + printf("Failed solve the motion: most likely there are no good keyframes\n"); + return false; + } + tracks_map_merge(context->tracks_map, tracking); BKE_tracking_dopesheet_tag_update(tracking); |