From 82c7ccd57f49ddbf4bade90b4b23a84dc9221b8f Mon Sep 17 00:00:00 2001 From: Tadas Baltrusaitis Date: Fri, 24 Nov 2017 19:49:46 +0000 Subject: [PATCH] Dealing better with empty frames at the beginning. --- lib/local/FaceAnalyser/src/FaceAnalyser.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/lib/local/FaceAnalyser/src/FaceAnalyser.cpp b/lib/local/FaceAnalyser/src/FaceAnalyser.cpp index 3a6af5f..041be6e 100644 --- a/lib/local/FaceAnalyser/src/FaceAnalyser.cpp +++ b/lib/local/FaceAnalyser/src/FaceAnalyser.cpp @@ -434,12 +434,6 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const cv::Mat_& det // Perform AU prediction AU_predictions_reg = PredictCurrentAUs(orientation_to_use); - std::vector> AU_predictions_reg_corrected; - if(online) - { - AU_predictions_reg_corrected = CorrectOnlineAUs(AU_predictions_reg, orientation_to_use, true, false, success, true); - } - // Add the reg predictions to the historic data for (size_t au = 0; au < AU_predictions_reg.size(); ++au) { @@ -453,6 +447,9 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const cv::Mat_& det else { AU_predictions_reg_all_hist[AU_predictions_reg[au].first].push_back(0); + + // Also invalidate AU if not successful + AU_predictions_reg[au].second = 0; } } @@ -470,9 +467,18 @@ void FaceAnalyser::AddNextFrame(const cv::Mat& frame, const cv::Mat_& det else { AU_predictions_class_all_hist[AU_predictions_class[au].first].push_back(0); + + // Also invalidate AU if not successful + AU_predictions_class[au].second = 0; } + } + + // A workaround for online predictions to make them a bit more accurate + std::vector> AU_predictions_reg_corrected; + if (online) + { + AU_predictions_reg_corrected = CorrectOnlineAUs(AU_predictions_reg, orientation_to_use, true, false, success, true); } - if(online) {