2017-11-11 11:57:57 +00:00
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
// Copyright (C) 2017, Tadas Baltrusaitis all rights reserved.
|
|
|
|
|
//
|
|
|
|
|
// ACADEMIC OR NON-PROFIT ORGANIZATION NONCOMMERCIAL RESEARCH USE ONLY
|
|
|
|
|
//
|
|
|
|
|
// BY USING OR DOWNLOADING THE SOFTWARE, YOU ARE AGREEING TO THE TERMS OF THIS LICENSE AGREEMENT.
|
|
|
|
|
// IF YOU DO NOT AGREE WITH THESE TERMS, YOU MAY NOT USE OR DOWNLOAD THE SOFTWARE.
|
|
|
|
|
//
|
|
|
|
|
// License can be found in OpenFace-license.txt
|
|
|
|
|
//
|
|
|
|
|
// * Any publications arising from the use of this software, including but
|
|
|
|
|
// not limited to academic journal and conference publications, technical
|
|
|
|
|
// reports and manuals, must cite at least one of the following works:
|
|
|
|
|
//
|
|
|
|
|
// OpenFace: an open source facial behavior analysis toolkit
|
|
|
|
|
// Tadas Baltru<72>aitis, Peter Robinson, and Louis-Philippe Morency
|
|
|
|
|
// in IEEE Winter Conference on Applications of Computer Vision, 2016
|
|
|
|
|
//
|
|
|
|
|
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
|
|
|
|
|
// Erroll Wood, Tadas Baltru<72>aitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
|
|
|
|
|
// in IEEE International. Conference on Computer Vision (ICCV), 2015
|
|
|
|
|
//
|
|
|
|
|
// Cross-dataset learning and person-speci?c normalisation for automatic Action Unit detection
|
|
|
|
|
// Tadas Baltru<72>aitis, Marwa Mahmoud, and Peter Robinson
|
|
|
|
|
// in Facial Expression Recognition and Analysis Challenge,
|
|
|
|
|
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
|
|
|
|
//
|
|
|
|
|
// Constrained Local Neural Fields for robust facial landmark detection in the wild.
|
|
|
|
|
// Tadas Baltru<72>aitis, Peter Robinson, and Louis-Philippe Morency.
|
|
|
|
|
// in IEEE Int. Conference on Computer Vision Workshops, 300 Faces in-the-Wild Challenge, 2013.
|
|
|
|
|
//
|
|
|
|
|
///////////////////////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#ifndef __VISUALIZER_h_
|
|
|
|
|
#define __VISUALIZER_h_
|
|
|
|
|
|
|
|
|
|
// System includes
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
|
|
// OpenCV includes
|
|
|
|
|
#include <opencv2/core/core.hpp>
|
|
|
|
|
#include <opencv2/highgui/highgui.hpp>
|
|
|
|
|
|
|
|
|
|
namespace Utilities
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
//===========================================================================
|
|
|
|
|
/**
|
|
|
|
|
A class for recording data processed by OpenFace (facial landmarks, head pose, facial action units, aligned face, HOG features, and tracked video
|
|
|
|
|
*/
|
|
|
|
|
class Visualizer {
|
|
|
|
|
|
|
|
|
|
public:
|
|
|
|
|
|
|
|
|
|
// The constructor for the visualizer that specifies what to visualize
|
|
|
|
|
Visualizer(std::vector<std::string> arguments);
|
2018-03-24 10:30:30 +00:00
|
|
|
|
Visualizer(bool vis_track, bool vis_hog, bool vis_align, bool vis_aus);
|
2017-12-15 19:56:58 +00:00
|
|
|
|
|
2017-11-11 11:57:57 +00:00
|
|
|
|
// Adding observations to the visualizer
|
|
|
|
|
|
|
|
|
|
// Pose related observations
|
|
|
|
|
void SetImage(const cv::Mat& canvas, float fx, float fy, float cx, float cy);
|
|
|
|
|
|
|
|
|
|
// All observations relevant to facial landmarks (optional visibilities parameter to not display all landmarks)
|
2018-01-19 16:17:22 +00:00
|
|
|
|
void SetObservationLandmarks(const cv::Mat_<double>& landmarks_2D, double confidence, const cv::Mat_<int>& visibilities = cv::Mat_<int>());
|
2017-11-11 11:57:57 +00:00
|
|
|
|
|
|
|
|
|
// Pose related observations
|
|
|
|
|
void SetObservationPose(const cv::Vec6d& pose, double confidence);
|
2018-03-12 17:34:04 +00:00
|
|
|
|
|
|
|
|
|
void SetObservationActionUnits(const std::vector<std::pair<std::string, double> >& au_intensities, const std::vector<std::pair<std::string, double> >& au_occurences);
|
|
|
|
|
|
2017-11-11 11:57:57 +00:00
|
|
|
|
// Gaze related observations
|
2017-11-13 17:30:19 +00:00
|
|
|
|
void SetObservationGaze(const cv::Point3f& gazeDirection0, const cv::Point3f& gazeDirection1, const std::vector<cv::Point2d>& eye_landmarks, const std::vector<cv::Point3d>& eye_landmarks3d, double confidence);
|
2017-11-11 11:57:57 +00:00
|
|
|
|
|
|
|
|
|
// Face alignment related observations
|
|
|
|
|
void SetObservationFaceAlign(const cv::Mat& aligned_face);
|
|
|
|
|
|
|
|
|
|
// HOG feature related observations
|
|
|
|
|
void SetObservationHOG(const cv::Mat_<double>& hog_descriptor, int num_cols, int num_rows);
|
|
|
|
|
|
2017-11-13 09:07:52 +00:00
|
|
|
|
void SetFps(double fps);
|
|
|
|
|
|
2017-11-22 17:53:15 +00:00
|
|
|
|
// Return key-press that could have resulted in the open windows
|
|
|
|
|
char ShowObservation();
|
2017-11-11 11:57:57 +00:00
|
|
|
|
|
|
|
|
|
cv::Mat GetVisImage();
|
2018-01-19 16:33:17 +00:00
|
|
|
|
cv::Mat GetHOGVis();
|
2017-11-11 11:57:57 +00:00
|
|
|
|
|
|
|
|
|
// Keeping track of what we're visualizing
|
|
|
|
|
bool vis_track;
|
|
|
|
|
bool vis_hog;
|
|
|
|
|
bool vis_align;
|
2018-03-12 17:34:04 +00:00
|
|
|
|
bool vis_aus;
|
2017-11-12 21:40:30 +00:00
|
|
|
|
|
|
|
|
|
// Can be adjusted to show less confident frames
|
|
|
|
|
double visualisation_boundary = 0.4;
|
2017-11-11 11:57:57 +00:00
|
|
|
|
|
2017-11-11 21:13:29 +00:00
|
|
|
|
private:
|
|
|
|
|
|
2017-11-11 11:57:57 +00:00
|
|
|
|
// Temporary variables for visualization
|
|
|
|
|
cv::Mat captured_image; // out canvas
|
|
|
|
|
cv::Mat tracked_image;
|
|
|
|
|
cv::Mat hog_image;
|
|
|
|
|
cv::Mat aligned_face_image;
|
2018-03-12 17:34:04 +00:00
|
|
|
|
cv::Mat action_units_image;
|
2017-11-11 11:57:57 +00:00
|
|
|
|
|
|
|
|
|
// Useful for drawing 3d
|
|
|
|
|
float fx, fy, cx, cy;
|
|
|
|
|
|
|
|
|
|
};
|
|
|
|
|
}
|
2018-03-12 17:34:04 +00:00
|
|
|
|
#endif
|