Feature/opencv4 (#706)

* Travis OpenCV4 update, testing Ubuntu with new OpenCV

* Fix to Ubuntu travis

* Another attempt at OpenCV 4.0 for Ubuntu

* And another OpenCV attempt.

* Simplifying the travis script

* Ubuntu OpenCV 4 support.

* Updating to OpenCV 4, for x64 windows.

* Fixes to move to OpenCV 4 on windows.

* Travis fix for OpenCV 4 on OSX

* Renaming a lib.

* Travis opencv4 fix.

* Building OpenCV4 versions using appveyor.

* Attempt mac travis fix.

* Small travis fix.

* Travis fix attempt.

* First iteration in boost removal and upgrade to C++17

* Test with ocv 4.0

* Moving filesystem out of stdafx

* Some more boost testing with cmake.

* More CMAKE options

* More compiler flag changes

* Another attempt at compiler options.

* Another attempt.

* More filesystem stuff.

* Linking to filesystem.

* Cmake fix with target linking.

* Attempting travis with g++-8

* Attempting to setup g++8 on travis linux.

* Another travis change.

* Adding OpenBLAS to travis and removing g++-8

* Fixing typo

* More travis experiments.

* More travis debugging.

* A small directory change.

* Adding some more travis changes.

* travis typo fix.

* Some reordering of travis, for cleaner yml

* Removing `using namespace std` in order to avoid clash with byte and to make the code more consistent.

* Working towards removing std::filesystem requirement, allow boost::filesystem as well.

* Making boost an optional dependency

* Fixing std issue.

* Fixing cmake issue.

* Fixing the precompiled header issue.

* Another cmake boost fix.

* Including missing files.

* Removing unnecessary includes.

* Removing more includes.

* Changes to appveyor build, proper removal of VS2015

* If boost is present, do not need to link to filesystem.

* Removing un-needed link library.

* oops

* Mac attempt at opencv4 travis.

* Upgrading OCV to 4.1 on VS2018

* Downloading OpenCV binaries through a script

* Triger an appveyor build.

* Upgrading VS version.

* Attempting VS2017 build

* Adding win-32 libraries for OpenCV 4.1

* Adding OpenCV 32 bit libraries.
This commit is contained in:
Tadas Baltrusaitis
2019-05-28 19:49:17 +01:00
committed by GitHub
parent 330383fef7
commit 9147dfe2f3
2762 changed files with 37401 additions and 353002 deletions

View File

@@ -37,8 +37,6 @@
// OpenCV includes
#include <opencv2/core/core.hpp>
using namespace std;
namespace LandmarkDetector
{
//===========================================================================
@@ -54,7 +52,9 @@ namespace LandmarkDetector
void max_pooling(std::vector<cv::Mat_<float> >& outputs, const std::vector<cv::Mat_<float> >& input_maps, int stride_x, int stride_y, int kernel_size_x, int kernel_size_y);
// Convolution using FFT optimization rather than matrix multiplication, TODO do these still work
void convolution_fft2(std::vector<cv::Mat_<float> >& outputs, const std::vector<cv::Mat_<float> >& input_maps, const std::vector<std::vector<cv::Mat_<float> > >& kernels, const std::vector<float >& biases, vector<map<int, vector<cv::Mat_<double> > > >& precomp_dfts);
void convolution_fft2(std::vector<cv::Mat_<float> >& outputs, const std::vector<cv::Mat_<float> >& input_maps,
const std::vector<std::vector<cv::Mat_<float> > >& kernels, const std::vector<float >& biases,
std::vector<std::map<int, std::vector<cv::Mat_<double> > > >& precomp_dfts);
// Convolution using matrix multiplication and OpenBLAS optimization, can also provide a pre-allocated im2col result for faster processing
void convolution_direct_blas(std::vector<cv::Mat_<float> >& outputs, const std::vector<cv::Mat_<float> >& input_maps, const cv::Mat_<float>& weight_matrix, int height_k, int width_k, cv::Mat_<float>& pre_alloc_im2col);

View File

@@ -40,8 +40,6 @@
// System includes
#include <vector>
using namespace std;
namespace LandmarkDetector
{
class CNN
@@ -60,7 +58,7 @@ namespace LandmarkDetector
std::vector<cv::Mat_<float> > Inference(const cv::Mat& input_img, bool direct = true, bool thread_safe = false);
// Reading in the model
void Read(const string& location);
void Read(const std::string& location);
// Clearing precomputed DFTs
void ClearPrecomp();
@@ -73,25 +71,25 @@ namespace LandmarkDetector
// CNN layers
// Layer -> Weight matrix
vector<cv::Mat_<float> > cnn_convolutional_layers_weights;
std::vector<cv::Mat_<float> > cnn_convolutional_layers_weights;
// Keeping some pre-allocated im2col data as malloc is a significant time cost (not thread safe though)
vector<cv::Mat_<float> > conv_layer_pre_alloc_im2col;
std::vector<cv::Mat_<float> > conv_layer_pre_alloc_im2col;
// Layer -> kernel -> input maps
vector<vector<vector<cv::Mat_<float> > > > cnn_convolutional_layers;
vector<vector<float > > cnn_convolutional_layers_bias;
std::vector<std::vector<std::vector<cv::Mat_<float> > > > cnn_convolutional_layers;
std::vector<std::vector<float > > cnn_convolutional_layers_bias;
// Layer matrix + bas
vector<cv::Mat_<float> > cnn_fully_connected_layers_weights;
vector<cv::Mat_<float> > cnn_fully_connected_layers_biases;
vector<cv::Mat_<float> > cnn_prelu_layer_weights;
vector<std::tuple<int, int, int, int> > cnn_max_pooling_layers;
std::vector<cv::Mat_<float> > cnn_fully_connected_layers_weights;
std::vector<cv::Mat_<float> > cnn_fully_connected_layers_biases;
std::vector<cv::Mat_<float> > cnn_prelu_layer_weights;
std::vector<std::tuple<int, int, int, int> > cnn_max_pooling_layers;
// Precomputations for faster convolution
vector<vector<map<int, vector<cv::Mat_<double> > > > > cnn_convolutional_layers_dft;
std::vector<std::vector<std::map<int, std::vector<cv::Mat_<double> > > > > cnn_convolutional_layers_dft;
// CNN: 0 - convolutional, 1 - max pooling, 2 - fully connected, 3 - prelu, 4 - sigmoid
vector<int > cnn_layer_types;
std::vector<int > cnn_layer_types;
};
//===========================================================================
//
@@ -107,16 +105,17 @@ namespace LandmarkDetector
// Default constructor
FaceDetectorMTCNN() { ; }
FaceDetectorMTCNN(const string& location);
FaceDetectorMTCNN(const std::string& location);
// Copy constructor
FaceDetectorMTCNN(const FaceDetectorMTCNN& other);
// Given an image, orientation and detected landmarks output the result of the appropriate regressor
bool DetectFaces(vector<cv::Rect_<float> >& o_regions, const cv::Mat& input_img, std::vector<float>& o_confidences, int min_face = 60, float t1 = 0.6, float t2 = 0.7, float t3 = 0.7);
bool DetectFaces(std::vector<cv::Rect_<float> >& o_regions, const cv::Mat& input_img,
std::vector<float>& o_confidences, int min_face = 60, float t1 = 0.6, float t2 = 0.7, float t3 = 0.7);
// Reading in the model
void Read(const string& location);
void Read(const std::string& location);
// Indicate if the model has been read in
bool empty() { return PNet.NumberOfLayers() == 0 || RNet.NumberOfLayers() == 0 || ONet.NumberOfLayers() == 0; };

View File

@@ -44,8 +44,6 @@
// Local includes
#include "PAW.h"
using namespace std;
namespace LandmarkDetector
{
//===========================================================================
@@ -60,31 +58,31 @@ class DetectionValidator
public:
// The orientations of each of the landmark detection validator
vector<cv::Vec3d> orientations;
std::vector<cv::Vec3d> orientations;
// Piecewise affine warps to the reference shape (per orientation)
vector<PAW> paws;
std::vector<PAW> paws;
//==========================================
// Convolutional Neural Network
// CNN layers for each view
// view -> layer
vector<vector<vector<vector<cv::Mat_<float> > > > > cnn_convolutional_layers;
vector<vector<cv::Mat_<float> > > cnn_convolutional_layers_weights;
vector<vector<cv::Mat_<float> > > cnn_convolutional_layers_im2col_precomp;
std::vector<std::vector<std::vector<std::vector<cv::Mat_<float> > > > > cnn_convolutional_layers;
std::vector<std::vector<cv::Mat_<float> > > cnn_convolutional_layers_weights;
std::vector<std::vector<cv::Mat_<float> > > cnn_convolutional_layers_im2col_precomp;
vector< vector<int> > cnn_subsampling_layers;
vector< vector<cv::Mat_<float> > > cnn_fully_connected_layers_weights;
vector< vector<cv::Mat_<float> > > cnn_fully_connected_layers_biases;
std::vector< std::vector<int> > cnn_subsampling_layers;
std::vector< std::vector<cv::Mat_<float> > > cnn_fully_connected_layers_weights;
std::vector< std::vector<cv::Mat_<float> > > cnn_fully_connected_layers_biases;
// NEW CNN: 0 - convolutional, 1 - max pooling (2x2 stride 2), 2 - fully connected, 3 - relu, 4 - sigmoid
vector<vector<int> > cnn_layer_types;
std::vector<std::vector<int> > cnn_layer_types;
//==========================================
// Normalisation for face validation
vector<cv::Mat_<float> > mean_images;
vector<cv::Mat_<float> > standard_deviations;
std::vector<cv::Mat_<float> > mean_images;
std::vector<cv::Mat_<float> > standard_deviations;
// Default constructor
DetectionValidator(){;}
@@ -96,7 +94,7 @@ public:
float Check(const cv::Vec3d& orientation, const cv::Mat_<uchar>& intensity_img, cv::Mat_<float>& detected_landmarks);
// Reading in the model
void Read(string location);
void Read(std::string location);
// Getting the closest view center based on orientation
int GetViewId(const cv::Vec3d& orientation) const;

View File

@@ -45,8 +45,6 @@
#include <LandmarkDetectorUtils.h>
#include <LandmarkDetectorModel.h>
using namespace std;
namespace LandmarkDetector
{

View File

@@ -49,8 +49,6 @@
#include "LandmarkDetectorParameters.h"
#include "FaceDetectorMTCNN.h"
using namespace std;
namespace LandmarkDetector
{
@@ -79,10 +77,10 @@ public:
cv::Vec6f params_global;
// A collection of hierarchical CLNF models that can be used for refinement
vector<CLNF> hierarchical_models;
vector<string> hierarchical_model_names;
vector<vector<pair<int,int>>> hierarchical_mapping;
vector<FaceModelParameters> hierarchical_params;
std::vector<CLNF> hierarchical_models;
std::vector<std::string> hierarchical_model_names;
std::vector<std::vector<std::pair<int,int>>> hierarchical_mapping;
std::vector<FaceModelParameters> hierarchical_params;
//==================== Helpers for face detection and landmark detection validation =========================================
@@ -90,13 +88,13 @@ public:
// Haar cascade classifier for face detection
cv::CascadeClassifier face_detector_HAAR;
string haar_face_detector_location;
std::string haar_face_detector_location;
// A HOG SVM-struct based face detector
dlib::frontal_face_detector face_detector_HOG;
FaceDetectorMTCNN face_detector_MTCNN;
string mtcnn_face_detector_location;
std::string mtcnn_face_detector_location;
// Validate if the detected landmarks are correct using an SVR regressor
DetectionValidator landmark_validator;
@@ -114,7 +112,7 @@ public:
bool eye_model;
// the triangulation per each view (for drawing purposes only)
vector<cv::Mat_<int> > triangulations;
std::vector<cv::Mat_<int> > triangulations;
//===========================================================================
// Member variables that retain the state of the tracking (reflecting the state of the lastly tracked (detected) image
@@ -146,7 +144,7 @@ public:
CLNF();
// Constructor from a model file
CLNF(string fname);
CLNF(std::string fname);
// Copy constructor (makes a deep copy of the detector)
CLNF(const CLNF& other);
@@ -183,25 +181,30 @@ public:
void Reset(double x, double y);
// Reading the model in
void Read(string name);
void Read(std::string name);
private:
// Helper reading function
bool Read_CLNF(string clnf_location);
bool Read_CLNF(std::string clnf_location);
// the speedup of RLMS using precalculated KDE responses (described in Saragih 2011 RLMS paper)
map<int, cv::Mat_<float> > kde_resp_precalc;
std::map<int, cv::Mat_<float> > kde_resp_precalc;
// The model fitting: patch response computation and optimisation steps
bool Fit(const cv::Mat_<float>& intensity_image, const std::vector<int>& window_sizes, const FaceModelParameters& parameters);
// Mean shift computation that uses precalculated kernel density estimators (the one actually used)
void NonVectorisedMeanShift_precalc_kde(cv::Mat_<float>& out_mean_shifts, const vector<cv::Mat_<float> >& patch_expert_responses, const cv::Mat_<float> &dxs, const cv::Mat_<float> &dys, int resp_size, float a, int scale, int view_id, map<int, cv::Mat_<float> >& mean_shifts);
void NonVectorisedMeanShift_precalc_kde(cv::Mat_<float>& out_mean_shifts, const std::vector<cv::Mat_<float> >& patch_expert_responses,
const cv::Mat_<float> &dxs, const cv::Mat_<float> &dys, int resp_size, float a, int scale, int view_id,
std::map<int, cv::Mat_<float> >& mean_shifts);
// The actual model optimisation (update step), returns the model likelihood
float NU_RLMS(cv::Vec6f& final_global, cv::Mat_<float>& final_local, const vector<cv::Mat_<float> >& patch_expert_responses, const cv::Vec6f& initial_global, const cv::Mat_<float>& initial_local,
const cv::Mat_<float>& base_shape, const cv::Matx22f& sim_img_to_ref, const cv::Matx22f& sim_ref_to_img, int resp_size, int view_idx, bool rigid, int scale, cv::Mat_<float>& landmark_lhoods, const FaceModelParameters& parameters, bool compute_lhood);
float NU_RLMS(cv::Vec6f& final_global, cv::Mat_<float>& final_local, const std::vector<cv::Mat_<float> >& patch_expert_responses,
const cv::Vec6f& initial_global, const cv::Mat_<float>& initial_local,
const cv::Mat_<float>& base_shape, const cv::Matx22f& sim_img_to_ref,
const cv::Matx22f& sim_ref_to_img, int resp_size, int view_idx, bool rigid, int scale,
cv::Mat_<float>& landmark_lhoods, const FaceModelParameters& parameters, bool compute_lhood);
// Generating the weight matrix for the Weighted least squares
void GetWeightMatrix(cv::Mat_<float>& WeightMatrix, int scale, int view_id, const FaceModelParameters& parameters);

View File

@@ -38,8 +38,6 @@
#include <vector>
using namespace std;
namespace LandmarkDetector
{
@@ -59,20 +57,20 @@ struct FaceModelParameters
float validation_boundary;
// Used when tracking is going well
vector<int> window_sizes_small;
std::vector<int> window_sizes_small;
// Used when initialising or tracking fails
vector<int> window_sizes_init;
std::vector<int> window_sizes_init;
// Used for the current frame
vector<int> window_sizes_current;
std::vector<int> window_sizes_current;
// How big is the tracking template that helps with large motions
float face_template_scale;
bool use_face_template;
// Where to load the model from
string model_location;
std::string model_location;
// this is used for the smooting of response maps (KDE sigma)
float sigma;
@@ -95,8 +93,8 @@ struct FaceModelParameters
// MTCNN detector is much more accurate that the other two, and is even suitable for profile faces, but it is somewhat slower
enum FaceDetector{HAAR_DETECTOR, HOG_SVM_DETECTOR, MTCNN_DETECTOR};
string haar_face_detector_location;
string mtcnn_face_detector_location;
std::string haar_face_detector_location;
std::string mtcnn_face_detector_location;
FaceDetector curr_face_detector;
// Should the model be refined hierarchically (if available)
@@ -107,7 +105,7 @@ struct FaceModelParameters
FaceModelParameters();
FaceModelParameters(vector<string> &arguments);
FaceModelParameters(std::vector<std::string> &arguments);
private:
void init();

View File

@@ -42,8 +42,6 @@
#include "FaceDetectorMTCNN.h"
using namespace std;
namespace LandmarkDetector
{
//===========================================================================
@@ -55,38 +53,39 @@ namespace LandmarkDetector
// This is a modified version of openCV code that allows for precomputed dfts of templates and for precomputed dfts of an image
// _img is the input img, _img_dft it's dft (optional), _integral_img the images integral image (optional), squared integral image (optional),
// templ is the template we are convolving with, templ_dfts it's dfts at varying windows sizes (optional), _result - the output, method the type of convolution
void matchTemplate_m(const cv::Mat_<float>& input_img, cv::Mat_<double>& img_dft, cv::Mat& _integral_img, cv::Mat& _integral_img_sq, const cv::Mat_<float>& templ, map<int, cv::Mat_<double> >& templ_dfts, cv::Mat_<float>& result, int method);
void matchTemplate_m(const cv::Mat_<float>& input_img, cv::Mat_<double>& img_dft, cv::Mat& _integral_img, cv::Mat& _integral_img_sq,
const cv::Mat_<float>& templ, std::map<int, cv::Mat_<double> >& templ_dfts, cv::Mat_<float>& result, int method);
// Useful utility for grabing a bounding box around a set of 2D landmarks (as a 1D 2n x 1 vector of xs followed by doubles or as an n x 2 vector)
void ExtractBoundingBox(const cv::Mat_<float>& landmarks, float &min_x, float &max_x, float &min_y, float &max_y);
vector<cv::Point2f> CalculateVisibleLandmarks(const cv::Mat_<float>& shape2D, const cv::Mat_<int>& visibilities);
vector<cv::Point2f> CalculateVisibleLandmarks(const CLNF& clnf_model);
vector<cv::Point2f> CalculateVisibleEyeLandmarks(const CLNF& clnf_model);
std::vector<cv::Point2f> CalculateVisibleLandmarks(const cv::Mat_<float>& shape2D, const cv::Mat_<int>& visibilities);
std::vector<cv::Point2f> CalculateVisibleLandmarks(const CLNF& clnf_model);
std::vector<cv::Point2f> CalculateVisibleEyeLandmarks(const CLNF& clnf_model);
vector<cv::Point2f> CalculateAllLandmarks(const cv::Mat_<float>& shape2D);
vector<cv::Point2f> CalculateAllLandmarks(const CLNF& clnf_model);
vector<cv::Point2f> CalculateAllEyeLandmarks(const CLNF& clnf_model);
vector<cv::Point3f> Calculate3DEyeLandmarks(const CLNF& clnf_model, float fx, float fy, float cx, float cy);
std::vector<cv::Point2f> CalculateAllLandmarks(const cv::Mat_<float>& shape2D);
std::vector<cv::Point2f> CalculateAllLandmarks(const CLNF& clnf_model);
std::vector<cv::Point2f> CalculateAllEyeLandmarks(const CLNF& clnf_model);
std::vector<cv::Point3f> Calculate3DEyeLandmarks(const CLNF& clnf_model, float fx, float fy, float cx, float cy);
//============================================================================
// Face detection helpers
//============================================================================
// Face detection using Haar cascade classifier
bool DetectFaces(vector<cv::Rect_<float> >& o_regions, const cv::Mat_<uchar>& intensity, float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
bool DetectFaces(vector<cv::Rect_<float> >& o_regions, const cv::Mat_<uchar>& intensity, cv::CascadeClassifier& classifier, float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
bool DetectFaces(std::vector<cv::Rect_<float> >& o_regions, const cv::Mat_<uchar>& intensity, float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
bool DetectFaces(std::vector<cv::Rect_<float> >& o_regions, const cv::Mat_<uchar>& intensity, cv::CascadeClassifier& classifier, float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
// The preference point allows for disambiguation if multiple faces are present (pick the closest one), if it is not set the biggest face is chosen
bool DetectSingleFace(cv::Rect_<float>& o_region, const cv::Mat_<uchar>& intensity, cv::CascadeClassifier& classifier, const cv::Point preference = cv::Point(-1, -1), float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
// Face detection using HOG-SVM classifier
bool DetectFacesHOG(vector<cv::Rect_<float> >& o_regions, const cv::Mat_<uchar>& intensity, std::vector<float>& confidences, float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
bool DetectFacesHOG(vector<cv::Rect_<float> >& o_regions, const cv::Mat_<uchar>& intensity, dlib::frontal_face_detector& classifier, std::vector<float>& confidences, float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
bool DetectFacesHOG(std::vector<cv::Rect_<float> >& o_regions, const cv::Mat_<uchar>& intensity, std::vector<float>& confidences, float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
bool DetectFacesHOG(std::vector<cv::Rect_<float> >& o_regions, const cv::Mat_<uchar>& intensity, dlib::frontal_face_detector& classifier, std::vector<float>& confidences, float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
// The preference point allows for disambiguation if multiple faces are present (pick the closest one), if it is not set the biggest face is chosen
bool DetectSingleFaceHOG(cv::Rect_<float>& o_region, const cv::Mat_<uchar>& intensity, dlib::frontal_face_detector& classifier, float& confidence, const cv::Point preference = cv::Point(-1, -1), float min_width = -1, cv::Rect_<float> roi = cv::Rect_<float>(0.0, 0.0, 1.0, 1.0));
// Face detection using Multi-task Convolutional Neural Network
bool DetectFacesMTCNN(vector<cv::Rect_<float> >& o_regions, const cv::Mat& image, LandmarkDetector::FaceDetectorMTCNN& detector, std::vector<float>& confidences);
bool DetectFacesMTCNN(std::vector<cv::Rect_<float> >& o_regions, const cv::Mat& image, LandmarkDetector::FaceDetectorMTCNN& detector, std::vector<float>& confidences);
// The preference point allows for disambiguation if multiple faces are present (pick the closest one), if it is not set the biggest face is chosen
bool DetectSingleFaceMTCNN(cv::Rect_<float>& o_region, const cv::Mat& image, LandmarkDetector::FaceDetectorMTCNN& detector, float& confidence, const cv::Point preference = cv::Point(-1, -1));

View File

@@ -64,7 +64,7 @@ class PDM{
// A copy constructor
PDM(const PDM& other);
bool Read(string location);
bool Read(std::string location);
// Number of vertices
inline int NumberOfPoints() const {return mean_shape.rows/3;}

View File

@@ -56,36 +56,36 @@ class Patch_experts
public:
// The collection of SVR patch experts (for intensity/grayscale images), the experts are laid out scale->view->landmark
vector<vector<vector<Multi_SVR_patch_expert> > > svr_expert_intensity;
std::vector<std::vector<std::vector<Multi_SVR_patch_expert> > > svr_expert_intensity;
// The collection of LNF (CCNF) patch experts (for intensity images), the experts are laid out scale->view->landmark
vector<vector<vector<CCNF_patch_expert> > > ccnf_expert_intensity;
std::vector<std::vector<std::vector<CCNF_patch_expert> > > ccnf_expert_intensity;
// The node connectivity for CCNF experts, at different window sizes and corresponding to separate edge features
vector<vector<cv::Mat_<float> > > sigma_components;
std::vector<std::vector<cv::Mat_<float> > > sigma_components;
// The collection of CEN patch experts (for intensity images), the experts are laid out scale->view->landmark
vector<vector<vector<CEN_patch_expert> > > cen_expert_intensity;
std::vector<std::vector<std::vector<CEN_patch_expert> > > cen_expert_intensity;
//Useful to pre-allocate data for im2col so that it is not allocated for every iteration and every patch
vector< map<int, cv::Mat_<float> > > preallocated_im2col;
std::vector< std::map<int, cv::Mat_<float> > > preallocated_im2col;
// The available scales for intensity patch experts
vector<double> patch_scaling;
std::vector<double> patch_scaling;
// The available views for the patch experts at every scale (in radians)
vector<vector<cv::Vec3d> > centers;
std::vector<std::vector<cv::Vec3d> > centers;
// Landmark visibilities for each scale and view
vector<vector<cv::Mat_<int> > > visibilities;
std::vector<std::vector<cv::Mat_<int> > > visibilities;
cv::Mat_<int> mirror_inds;
cv::Mat_<int> mirror_views;
// Early termination calibration values, useful for CE-CLM model to speed up the multi-hypothesis setup
vector<double> early_term_weights;
vector<double> early_term_biases;
vector<double> early_term_cutoffs;
std::vector<double> early_term_weights;
std::vector<double> early_term_biases;
std::vector<double> early_term_cutoffs;
// A default constructor
@@ -98,7 +98,7 @@ public:
// Additionally returns the transform from the image coordinates to the response coordinates (and vice versa).
// The computation also requires the current landmark locations to compute response around, the PDM corresponding to the desired model, and the parameters describing its instance
// Also need to provide the size of the area of interest and the desired scale of analysis
void Response(vector<cv::Mat_<float> >& patch_expert_responses, cv::Matx22f& sim_ref_to_img, cv::Matx22f& sim_img_to_ref, const cv::Mat_<float>& grayscale_image,
void Response(std::vector<cv::Mat_<float> >& patch_expert_responses, cv::Matx22f& sim_ref_to_img, cv::Matx22f& sim_img_to_ref, const cv::Mat_<float>& grayscale_image,
const PDM& pdm, const cv::Vec6f& params_global, const cv::Mat_<float>& params_local, int window_size, int scale);
// Getting the best view associated with the current orientation
@@ -108,16 +108,17 @@ public:
inline int nViews(size_t scale = 0) const { return (int)centers[scale].size(); };
// Reading in all of the patch experts
bool Read(vector<string> intensity_svr_expert_locations, vector<string> intensity_ccnf_expert_locations, vector<string> intensity_cen_expert_locations, string early_term_loc = "");
bool Read(std::vector<std::string> intensity_svr_expert_locations, std::vector<std::string> intensity_ccnf_expert_locations,
std::vector<std::string> intensity_cen_expert_locations, std::string early_term_loc = "");
private:
bool Read_SVR_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<Multi_SVR_patch_expert> >& patches, double& scale);
bool Read_CCNF_patch_experts(string patchesFileLocation, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CCNF_patch_expert> >& patches, double& patchScaling);
bool Read_CEN_patch_experts(string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CEN_patch_expert> >& patches, double& scale);
bool Read_SVR_patch_experts(std::string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<Multi_SVR_patch_expert> >& patches, double& scale);
bool Read_CCNF_patch_experts(std::string patchesFileLocation, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CCNF_patch_expert> >& patches, double& patchScaling);
bool Read_CEN_patch_experts(std::string expert_location, std::vector<cv::Vec3d>& centers, std::vector<cv::Mat_<int> >& visibility, std::vector<std::vector<CEN_patch_expert> >& patches, double& scale);
// Helper for collecting visibilities
std::vector<int> Collect_visible_landmarks(vector<vector<cv::Mat_<int> > > visibilities, int scale, int view_id, int n);
std::vector<int> Collect_visible_landmarks(std::vector<std::vector<cv::Mat_<int> > > visibilities, int scale, int view_id, int n);
};
}

View File

@@ -27,7 +27,7 @@
#include <dlib/image_processing/frontal_face_detector.h>
#include <dlib/opencv.h>
// C++ stuff
// C++ standard stuff
#include <stdio.h>
#include <fstream>
@@ -40,9 +40,19 @@
#define _USE_MATH_DEFINES
#include <cmath>
// Boost stuff
#include <filesystem.hpp>
#include <filesystem/fstream.hpp>
// Filesystem stuff
// It can either be in std filesystem (C++17), or in experimental/filesystem (partial C++17 support) or in boost
#if __has_include(<filesystem>)
#include <filesystem>
namespace fs = std::filesystem;
#elif __has_include(<experimental/filesystem>)
#include <experimental/filesystem>
namespace fs = std::filesystem;
#else
#include <boost/filesystem.hpp>
#include <boost/filesystem/fstream.hpp>
namespace fs = boost::filesystem;
#endif
// OpenBLAS stuff