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:
parent
2f637004d5
commit
8600dc6365
Notes:
blender-bot
2023-02-14 09:44:56 +01:00
Referenced by issue #42800, blender suddenly closes after pressing solve camera motion
|
@ -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);
|
||||
|
|
|
@ -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(
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
Loading…
Reference in New Issue