Fix T42800: Blender suddenly closes after pressing solve camera motion
Couple of issues: - Fist/last frame calculation was wrong - Keyframe selection might silently fail leading to unpredictable math errors all over the place. Now if keyframe selection fails solver wouldn't run.
This commit is contained in:
13
extern/libmv/intern/reconstruction.cc
vendored
13
extern/libmv/intern/reconstruction.cc
vendored
@@ -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);
|
||||
|
||||
2
extern/libmv/intern/reconstruction.h
vendored
2
extern/libmv/intern/reconstruction.h
vendored
@@ -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(
|
||||
|
||||
4
extern/libmv/intern/stub.cc
vendored
4
extern/libmv/intern/stub.cc
vendored
@@ -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*/,
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user