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

@@ -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; };