Adapting to the case where no AU models are present (e.g. due to licensing issues).

This commit is contained in:
Tadas Baltrusaitis 2018-03-27 16:26:26 +01:00
parent b1524ca98b
commit 51fbf805bc
3 changed files with 67 additions and 58 deletions

View file

@ -1224,6 +1224,8 @@ void FaceAnalyser::ReadRegressor(std::string fname, const vector<string>& au_nam
{
ifstream regressor_stream(fname.c_str(), ios::in | ios::binary);
if(regressor_stream.is_open())
{
// First read the input type
int regressor_type;
regressor_stream.read((char*)&regressor_type, 4);
@ -1244,6 +1246,7 @@ void FaceAnalyser::ReadRegressor(std::string fname, const vector<string>& au_nam
{
AU_SVM_dynamic_appearance_lin.Read(regressor_stream, au_names);
}
}
}
double FaceAnalyser::GetCurrentTimeSeconds() {

View file

@ -182,7 +182,7 @@ void FaceAnalyserParameters::init()
}
else
{
std::cout << "Could not find the AU detection model to load" << std::endl;
std::cout << "Could not find the face analysis module to load" << std::endl;
}
orientation_bins = vector<cv::Vec3d>();
@ -226,7 +226,7 @@ void FaceAnalyserParameters::OptimizeForVideos()
}
else
{
std::cout << "Could not find the AU detection model to load" << std::endl;
std::cout << "Could not find the face analysis module to load" << std::endl;
}
}
@ -256,7 +256,7 @@ void FaceAnalyserParameters::OptimizeForImages()
}
else
{
std::cout << "Could not find the AU detection model to load" << std::endl;
std::cout << "Could not find the face analysis module to load" << std::endl;
}
}

View file

@ -234,6 +234,8 @@ void Visualizer::SetObservationPose(const cv::Vec6d& pose, double confidence)
void Visualizer::SetObservationActionUnits(const std::vector<std::pair<std::string, double> >& au_intensities,
const std::vector<std::pair<std::string, double> >& au_occurences)
{
if(au_intensities.size() > 0 || au_occurences.size() > 0)
{
const int NB_AUS = 17;
const int AU_TRACKBAR_LENGTH = 400;
@ -253,7 +255,8 @@ void Visualizer::SetObservationActionUnits(const std::vector<std::pair<std::stri
// then, build the graph
size_t idx = 0;
for (auto& au : aus) {
for (auto& au : aus)
{
std::string name = au.first;
bool present = au.second.first;
double intensity = au.second.second;
@ -264,18 +267,21 @@ void Visualizer::SetObservationActionUnits(const std::vector<std::pair<std::stri
cv::putText(action_units_image, name, cv::Point(10, offset + 10), CV_FONT_HERSHEY_SIMPLEX, 0.5, CV_RGB(present ? 0 : 200, 0, 0), 1, CV_AA);
cv::putText(action_units_image, AUS_DESCRIPTION.at(name), cv::Point(55, offset + 10), CV_FONT_HERSHEY_SIMPLEX, 0.3, CV_RGB(0, 0, 0), 1, CV_AA);
if(present) {
if(present)
{
cv::putText(action_units_image, au_i.str(), cv::Point(160, offset + 10), CV_FONT_HERSHEY_SIMPLEX, 0.3, CV_RGB(0, 100, 0), 1, CV_AA);
cv::rectangle(action_units_image, cv::Point(MARGIN_X, offset),
cv::Point(MARGIN_X + AU_TRACKBAR_LENGTH * intensity/5, offset + AU_TRACKBAR_HEIGHT),
cv::Scalar(128,128,128),
CV_FILLED);
}
else {
else
{
cv::putText(action_units_image, "0.00", cv::Point(160, offset + 10), CV_FONT_HERSHEY_SIMPLEX, 0.3, CV_RGB(0, 0, 0), 1, CV_AA);
}
idx++;
}
}
}
// Eye gaze infomration drawing, first of eye landmarks then of gaze
@ -374,14 +380,14 @@ char Visualizer::ShowObservation()
{
cv::imshow("hog", hog_image);
}
if (vis_aus)
if (vis_aus && !action_units_image.empty())
{
cv::namedWindow("action units", cv::WindowFlags::WINDOW_NORMAL);
cv::namedWindow("action units", cv::WindowFlags::WINDOW_KEEPRATIO);
cv::imshow("action units", action_units_image);
}
if (vis_track)
{
cv::namedWindow("tracking result", cv::WindowFlags::WINDOW_NORMAL);
cv::namedWindow("tracking result", cv::WindowFlags::WINDOW_KEEPRATIO);
cv::imshow("tracking result", captured_image);
}
return cv::waitKey(1);