From f58bc9de86e79df8f7a30fe1e21821bdabfb165e Mon Sep 17 00:00:00 2001 From: Michael Welter Date: Tue, 26 Oct 2021 11:31:26 +0200 Subject: tracker/nn: catch exception in case the head pose model throws during inference --- tracker-neuralnet/ftnoir_tracker_neuralnet.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp index 3687a6cd..50d1e7b4 100644 --- a/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp +++ b/tracker-neuralnet/ftnoir_tracker_neuralnet.cpp @@ -315,7 +315,16 @@ std::optional PoseEstimator::run( const auto nt = omp_get_num_threads(); omp_set_num_threads(num_threads); - session.Run(Ort::RunOptions{nullptr}, input_names, &input_val, 1, output_names, output_val, 3); + try + { + session.Run(Ort::RunOptions{ nullptr }, input_names, &input_val, 1, output_names, output_val, 3); + } + catch (const Ort::Exception &e) + { + qDebug() << "Failed to run the model: " << e.what(); + omp_set_num_threads(nt); + return {}; + } omp_set_num_threads(nt); // FIXME: Execution time fluctuates wildly. 19 to 26 ms. Why??? -- cgit v1.2.3