Adapting to the case where no AU models are present (e.g. due to licensing issues).
This commit is contained in:
parent
b1524ca98b
commit
51fbf805bc
3 changed files with 67 additions and 58 deletions
|
@ -1224,25 +1224,28 @@ void FaceAnalyser::ReadRegressor(std::string fname, const vector<string>& au_nam
|
||||||
{
|
{
|
||||||
ifstream regressor_stream(fname.c_str(), ios::in | ios::binary);
|
ifstream regressor_stream(fname.c_str(), ios::in | ios::binary);
|
||||||
|
|
||||||
// First read the input type
|
if(regressor_stream.is_open())
|
||||||
int regressor_type;
|
{
|
||||||
regressor_stream.read((char*)®ressor_type, 4);
|
// First read the input type
|
||||||
|
int regressor_type;
|
||||||
|
regressor_stream.read((char*)®ressor_type, 4);
|
||||||
|
|
||||||
if(regressor_type == SVR_appearance_static_linear)
|
if(regressor_type == SVR_appearance_static_linear)
|
||||||
{
|
{
|
||||||
AU_SVR_static_appearance_lin_regressors.Read(regressor_stream, au_names);
|
AU_SVR_static_appearance_lin_regressors.Read(regressor_stream, au_names);
|
||||||
}
|
}
|
||||||
else if(regressor_type == SVR_appearance_dynamic_linear)
|
else if(regressor_type == SVR_appearance_dynamic_linear)
|
||||||
{
|
{
|
||||||
AU_SVR_dynamic_appearance_lin_regressors.Read(regressor_stream, au_names);
|
AU_SVR_dynamic_appearance_lin_regressors.Read(regressor_stream, au_names);
|
||||||
}
|
}
|
||||||
else if(regressor_type == SVM_linear_stat)
|
else if(regressor_type == SVM_linear_stat)
|
||||||
{
|
{
|
||||||
AU_SVM_static_appearance_lin.Read(regressor_stream, au_names);
|
AU_SVM_static_appearance_lin.Read(regressor_stream, au_names);
|
||||||
}
|
}
|
||||||
else if(regressor_type == SVM_linear_dyn)
|
else if(regressor_type == SVM_linear_dyn)
|
||||||
{
|
{
|
||||||
AU_SVM_dynamic_appearance_lin.Read(regressor_stream, au_names);
|
AU_SVM_dynamic_appearance_lin.Read(regressor_stream, au_names);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -182,7 +182,7 @@ void FaceAnalyserParameters::init()
|
||||||
}
|
}
|
||||||
else
|
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>();
|
orientation_bins = vector<cv::Vec3d>();
|
||||||
|
@ -226,7 +226,7 @@ void FaceAnalyserParameters::OptimizeForVideos()
|
||||||
}
|
}
|
||||||
else
|
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
|
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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -234,48 +234,54 @@ void Visualizer::SetObservationPose(const cv::Vec6d& pose, double confidence)
|
||||||
void Visualizer::SetObservationActionUnits(const std::vector<std::pair<std::string, double> >& au_intensities,
|
void Visualizer::SetObservationActionUnits(const std::vector<std::pair<std::string, double> >& au_intensities,
|
||||||
const std::vector<std::pair<std::string, double> >& au_occurences)
|
const std::vector<std::pair<std::string, double> >& au_occurences)
|
||||||
{
|
{
|
||||||
const int NB_AUS = 17;
|
if(au_intensities.size() > 0 || au_occurences.size() > 0)
|
||||||
|
{
|
||||||
|
const int NB_AUS = 17;
|
||||||
|
|
||||||
const int AU_TRACKBAR_LENGTH = 400;
|
const int AU_TRACKBAR_LENGTH = 400;
|
||||||
const int AU_TRACKBAR_HEIGHT = 10;
|
const int AU_TRACKBAR_HEIGHT = 10;
|
||||||
|
|
||||||
const int MARGIN_X = 185;
|
const int MARGIN_X = 185;
|
||||||
const int MARGIN_Y = 10;
|
const int MARGIN_Y = 10;
|
||||||
|
|
||||||
action_units_image = cv::Mat(NB_AUS * (AU_TRACKBAR_HEIGHT + 10) + MARGIN_Y * 2, AU_TRACKBAR_LENGTH + MARGIN_X, CV_8UC3, cv::Scalar(255,255,255));
|
action_units_image = cv::Mat(NB_AUS * (AU_TRACKBAR_HEIGHT + 10) + MARGIN_Y * 2, AU_TRACKBAR_LENGTH + MARGIN_X, CV_8UC3, cv::Scalar(255,255,255));
|
||||||
|
|
||||||
std::map<std::string, std::pair<bool, double>> aus;
|
std::map<std::string, std::pair<bool, double>> aus;
|
||||||
|
|
||||||
// first, prepare a mapping "AU name" -> { present, intensity }
|
// first, prepare a mapping "AU name" -> { present, intensity }
|
||||||
for (size_t idx = 0; idx < au_intensities.size(); idx++) {
|
for (size_t idx = 0; idx < au_intensities.size(); idx++) {
|
||||||
aus[au_intensities[idx].first] = std::make_pair(au_occurences[idx].second != 0, au_intensities[idx].second);
|
aus[au_intensities[idx].first] = std::make_pair(au_occurences[idx].second != 0, au_intensities[idx].second);
|
||||||
}
|
}
|
||||||
|
|
||||||
// then, build the graph
|
// then, build the graph
|
||||||
size_t idx = 0;
|
size_t idx = 0;
|
||||||
for (auto& au : aus) {
|
for (auto& au : aus)
|
||||||
std::string name = au.first;
|
{
|
||||||
bool present = au.second.first;
|
std::string name = au.first;
|
||||||
double intensity = au.second.second;
|
bool present = au.second.first;
|
||||||
|
double intensity = au.second.second;
|
||||||
|
|
||||||
auto offset = MARGIN_Y + idx * (AU_TRACKBAR_HEIGHT + 10);
|
auto offset = MARGIN_Y + idx * (AU_TRACKBAR_HEIGHT + 10);
|
||||||
std::ostringstream au_i;
|
std::ostringstream au_i;
|
||||||
au_i << std::setprecision(2) << std::setw(4) << std::fixed << intensity;
|
au_i << std::setprecision(2) << std::setw(4) << std::fixed << intensity;
|
||||||
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, 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);
|
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::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::Point(MARGIN_X + AU_TRACKBAR_LENGTH * intensity/5, offset + AU_TRACKBAR_HEIGHT),
|
cv::rectangle(action_units_image, cv::Point(MARGIN_X, offset),
|
||||||
cv::Scalar(128,128,128),
|
cv::Point(MARGIN_X + AU_TRACKBAR_LENGTH * intensity/5, offset + AU_TRACKBAR_HEIGHT),
|
||||||
CV_FILLED);
|
cv::Scalar(128,128,128),
|
||||||
}
|
CV_FILLED);
|
||||||
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);
|
else
|
||||||
}
|
{
|
||||||
idx++;
|
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
|
// Eye gaze infomration drawing, first of eye landmarks then of gaze
|
||||||
|
@ -374,14 +380,14 @@ char Visualizer::ShowObservation()
|
||||||
{
|
{
|
||||||
cv::imshow("hog", hog_image);
|
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);
|
cv::imshow("action units", action_units_image);
|
||||||
}
|
}
|
||||||
if (vis_track)
|
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);
|
cv::imshow("tracking result", captured_image);
|
||||||
}
|
}
|
||||||
return cv::waitKey(1);
|
return cv::waitKey(1);
|
||||||
|
|
Loading…
Reference in a new issue