open source pkg v1
This commit is contained in:
10
pkg/OpenFace/exe/FaceLandmarkImg/CMakeLists.txt
Normal file
10
pkg/OpenFace/exe/FaceLandmarkImg/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
# Local libraries
|
||||
include_directories(${LandmarkDetector_SOURCE_DIR}/include)
|
||||
|
||||
add_executable(FaceLandmarkImg FaceLandmarkImg.cpp)
|
||||
target_link_libraries(FaceLandmarkImg LandmarkDetector)
|
||||
target_link_libraries(FaceLandmarkImg FaceAnalyser)
|
||||
target_link_libraries(FaceLandmarkImg GazeAnalyser)
|
||||
target_link_libraries(FaceLandmarkImg Utilities)
|
||||
|
||||
install (TARGETS FaceLandmarkImg DESTINATION bin)
|
||||
255
pkg/OpenFace/exe/FaceLandmarkImg/FaceLandmarkImg.cpp
Normal file
255
pkg/OpenFace/exe/FaceLandmarkImg/FaceLandmarkImg.cpp
Normal file
@@ -0,0 +1,255 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017, Carnegie Mellon University and University of Cambridge,
|
||||
// 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 2.0: Facial Behavior Analysis Toolkit
|
||||
// Tadas Baltrušaitis, Amir Zadeh, Yao Chong Lim, and Louis-Philippe Morency
|
||||
// in IEEE International Conference on Automatic Face and Gesture Recognition, 2018
|
||||
//
|
||||
// Convolutional experts constrained local model for facial landmark detection.
|
||||
// A. Zadeh, T. Baltrušaitis, and Louis-Philippe Morency,
|
||||
// in Computer Vision and Pattern Recognition Workshops, 2017.
|
||||
//
|
||||
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
|
||||
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
|
||||
// in IEEE International. Conference on Computer Vision (ICCV), 2015
|
||||
//
|
||||
// Cross-dataset learning and person-specific normalisation for automatic Action Unit detection
|
||||
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
|
||||
// in Facial Expression Recognition and Analysis Challenge,
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// FaceLandmarkImg.cpp : Defines the entry point for the console application for detecting landmarks in images.
|
||||
|
||||
// dlib
|
||||
#include <dlib/image_processing/frontal_face_detector.h>
|
||||
|
||||
#include "LandmarkCoreIncludes.h"
|
||||
|
||||
#include <FaceAnalyser.h>
|
||||
#include <GazeEstimation.h>
|
||||
|
||||
#include <ImageCapture.h>
|
||||
#include <Visualizer.h>
|
||||
#include <VisualizationUtils.h>
|
||||
#include <RecorderOpenFace.h>
|
||||
#include <RecorderOpenFaceParameters.h>
|
||||
|
||||
|
||||
#ifndef CONFIG_DIR
|
||||
#define CONFIG_DIR "~"
|
||||
#endif
|
||||
|
||||
std::vector<std::string> get_arguments(int argc, char **argv)
|
||||
{
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
arguments.push_back(std::string(argv[i]));
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
//Convert arguments to more convenient vector form
|
||||
std::vector<std::string> arguments = get_arguments(argc, argv);
|
||||
|
||||
// no arguments: output usage
|
||||
if (arguments.size() == 1)
|
||||
{
|
||||
std::cout << "For command line arguments see:" << std::endl;
|
||||
std::cout << " https://github.com/TadasBaltrusaitis/OpenFace/wiki/Command-line-arguments";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Prepare for image reading
|
||||
Utilities::ImageCapture image_reader;
|
||||
|
||||
// The sequence reader chooses what to open based on command line arguments provided
|
||||
if (!image_reader.Open(arguments))
|
||||
{
|
||||
std::cout << "Could not open any images" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Load the models if images found
|
||||
LandmarkDetector::FaceModelParameters det_parameters(arguments);
|
||||
|
||||
// The modules that are being used for tracking
|
||||
std::cout << "Loading the model" << std::endl;
|
||||
LandmarkDetector::CLNF face_model(det_parameters.model_location);
|
||||
|
||||
if (!face_model.loaded_successfully)
|
||||
{
|
||||
std::cout << "ERROR: Could not load the landmark detector" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
std::cout << "Model loaded" << std::endl;
|
||||
|
||||
// Load facial feature extractor and AU analyser (make sure it is static)
|
||||
FaceAnalysis::FaceAnalyserParameters face_analysis_params(arguments);
|
||||
face_analysis_params.OptimizeForImages();
|
||||
FaceAnalysis::FaceAnalyser face_analyser(face_analysis_params);
|
||||
|
||||
// If bounding boxes not provided, use a face detector
|
||||
cv::CascadeClassifier classifier(det_parameters.haar_face_detector_location);
|
||||
dlib::frontal_face_detector face_detector_hog = dlib::get_frontal_face_detector();
|
||||
LandmarkDetector::FaceDetectorMTCNN face_detector_mtcnn(det_parameters.mtcnn_face_detector_location);
|
||||
|
||||
// If can't find MTCNN face detector, default to HOG one
|
||||
if (det_parameters.curr_face_detector == LandmarkDetector::FaceModelParameters::MTCNN_DETECTOR && face_detector_mtcnn.empty())
|
||||
{
|
||||
std::cout << "INFO: defaulting to HOG-SVM face detector" << std::endl;
|
||||
det_parameters.curr_face_detector = LandmarkDetector::FaceModelParameters::HOG_SVM_DETECTOR;
|
||||
}
|
||||
|
||||
// A utility for visualizing the results
|
||||
Utilities::Visualizer visualizer(arguments);
|
||||
|
||||
cv::Mat rgb_image;
|
||||
|
||||
rgb_image = image_reader.GetNextImage();
|
||||
|
||||
if (!face_model.eye_model)
|
||||
{
|
||||
std::cout << "WARNING: no eye model found" << std::endl;
|
||||
}
|
||||
|
||||
if (face_analyser.GetAUClassNames().size() == 0 && face_analyser.GetAUClassNames().size() == 0)
|
||||
{
|
||||
std::cout << "WARNING: no Action Unit models found" << std::endl;
|
||||
}
|
||||
|
||||
std::cout << "Starting tracking" << std::endl;
|
||||
while (!rgb_image.empty())
|
||||
{
|
||||
|
||||
Utilities::RecorderOpenFaceParameters recording_params(arguments, false, false,
|
||||
image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy);
|
||||
|
||||
if (!face_model.eye_model)
|
||||
{
|
||||
recording_params.setOutputGaze(false);
|
||||
}
|
||||
Utilities::RecorderOpenFace open_face_rec(image_reader.name, recording_params, arguments);
|
||||
|
||||
visualizer.SetImage(rgb_image, image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy);
|
||||
|
||||
// Making sure the image is in uchar grayscale (some face detectors use RGB, landmark detector uses grayscale)
|
||||
cv::Mat_<uchar> grayscale_image = image_reader.GetGrayFrame();
|
||||
|
||||
// Detect faces in an image
|
||||
std::vector<cv::Rect_<float> > face_detections;
|
||||
|
||||
if (image_reader.has_bounding_boxes)
|
||||
{
|
||||
face_detections = image_reader.GetBoundingBoxes();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (det_parameters.curr_face_detector == LandmarkDetector::FaceModelParameters::HOG_SVM_DETECTOR)
|
||||
{
|
||||
std::vector<float> confidences;
|
||||
LandmarkDetector::DetectFacesHOG(face_detections, grayscale_image, face_detector_hog, confidences);
|
||||
}
|
||||
else if (det_parameters.curr_face_detector == LandmarkDetector::FaceModelParameters::HAAR_DETECTOR)
|
||||
{
|
||||
LandmarkDetector::DetectFaces(face_detections, grayscale_image, classifier);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<float> confidences;
|
||||
LandmarkDetector::DetectFacesMTCNN(face_detections, rgb_image, face_detector_mtcnn, confidences);
|
||||
}
|
||||
}
|
||||
|
||||
// Detect landmarks around detected faces
|
||||
int face_det = 0;
|
||||
// perform landmark detection for every face detected
|
||||
for (size_t face = 0; face < face_detections.size(); ++face)
|
||||
{
|
||||
|
||||
// if there are multiple detections go through them
|
||||
bool success = LandmarkDetector::DetectLandmarksInImage(rgb_image, face_detections[face], face_model, det_parameters, grayscale_image);
|
||||
|
||||
// Estimate head pose and eye gaze
|
||||
cv::Vec6d pose_estimate = LandmarkDetector::GetPose(face_model, image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy);
|
||||
|
||||
// Gaze tracking, absolute gaze direction
|
||||
cv::Point3f gaze_direction0(0, 0, -1);
|
||||
cv::Point3f gaze_direction1(0, 0, -1);
|
||||
cv::Vec2f gaze_angle(0, 0);
|
||||
|
||||
if (face_model.eye_model)
|
||||
{
|
||||
GazeAnalysis::EstimateGaze(face_model, gaze_direction0, image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy, true);
|
||||
GazeAnalysis::EstimateGaze(face_model, gaze_direction1, image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy, false);
|
||||
gaze_angle = GazeAnalysis::GetGazeAngle(gaze_direction0, gaze_direction1);
|
||||
}
|
||||
|
||||
cv::Mat sim_warped_img;
|
||||
cv::Mat_<double> hog_descriptor; int num_hog_rows = 0, num_hog_cols = 0;
|
||||
|
||||
// Perform AU detection and HOG feature extraction, as this can be expensive only compute it if needed by output or visualization
|
||||
if (recording_params.outputAlignedFaces() || recording_params.outputHOG() || recording_params.outputAUs() || visualizer.vis_align || visualizer.vis_hog)
|
||||
{
|
||||
face_analyser.PredictStaticAUsAndComputeFeatures(rgb_image, face_model.detected_landmarks);
|
||||
face_analyser.GetLatestAlignedFace(sim_warped_img);
|
||||
face_analyser.GetLatestHOG(hog_descriptor, num_hog_rows, num_hog_cols);
|
||||
}
|
||||
|
||||
// Displaying the tracking visualizations
|
||||
visualizer.SetObservationFaceAlign(sim_warped_img);
|
||||
visualizer.SetObservationHOG(hog_descriptor, num_hog_rows, num_hog_cols);
|
||||
visualizer.SetObservationLandmarks(face_model.detected_landmarks, 1.0, face_model.GetVisibilities()); // Set confidence to high to make sure we always visualize
|
||||
visualizer.SetObservationPose(pose_estimate, 1.0);
|
||||
visualizer.SetObservationGaze(gaze_direction0, gaze_direction1, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy), face_model.detection_certainty);
|
||||
visualizer.SetObservationActionUnits(face_analyser.GetCurrentAUsReg(), face_analyser.GetCurrentAUsClass());
|
||||
|
||||
// Setting up the recorder output
|
||||
open_face_rec.SetObservationHOG(face_model.detection_success, hog_descriptor, num_hog_rows, num_hog_cols, 31); // The number of channels in HOG is fixed at the moment, as using FHOG
|
||||
open_face_rec.SetObservationActionUnits(face_analyser.GetCurrentAUsReg(), face_analyser.GetCurrentAUsClass());
|
||||
open_face_rec.SetObservationLandmarks(face_model.detected_landmarks, face_model.GetShape(image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy),
|
||||
face_model.params_global, face_model.params_local, face_model.detection_certainty, face_model.detection_success);
|
||||
open_face_rec.SetObservationPose(pose_estimate);
|
||||
open_face_rec.SetObservationGaze(gaze_direction0, gaze_direction1, gaze_angle, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, image_reader.fx, image_reader.fy, image_reader.cx, image_reader.cy));
|
||||
open_face_rec.SetObservationFaceAlign(sim_warped_img);
|
||||
open_face_rec.SetObservationFaceID(face);
|
||||
open_face_rec.WriteObservation();
|
||||
|
||||
}
|
||||
if (face_detections.size() > 0)
|
||||
{
|
||||
visualizer.ShowObservation();
|
||||
}
|
||||
|
||||
open_face_rec.SetObservationVisualization(visualizer.GetVisImage());
|
||||
open_face_rec.WriteObservationTracked();
|
||||
|
||||
open_face_rec.Close();
|
||||
|
||||
// Grabbing the next frame in the sequence
|
||||
rgb_image = image_reader.GetNextImage();
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
201
pkg/OpenFace/exe/FaceLandmarkImg/FaceLandmarkImg.vcxproj
Normal file
201
pkg/OpenFace/exe/FaceLandmarkImg/FaceLandmarkImg.vcxproj
Normal file
@@ -0,0 +1,201 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{DDC3535E-526C-44EC-9DF4-739E2D3A323B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>FaceLandmarkImg</RootNamespace>
|
||||
<ProjectName>FaceLandmarkImg</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>FaceLandmarkImg</TargetName>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>FaceLandmarkImg</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>FaceLandmarkImg</TargetName>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>FaceLandmarkImg</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FaceLandmarkImg.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\lib\local\FaceAnalyser\FaceAnalyser.vcxproj">
|
||||
<Project>{0e7fc556-0e80-45ea-a876-dde4c2fedcd7}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\GazeAnalyser\GazeAnalyser.vcxproj">
|
||||
<Project>{5f915541-f531-434f-9c81-79f5db58012b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\LandmarkDetector\LandmarkDetector.vcxproj">
|
||||
<Project>{bdc1d107-de17-4705-8e7b-cdde8bfb2bf8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\Utilities\Utilities.vcxproj">
|
||||
<Project>{8e741ea2-9386-4cf2-815e-6f9b08991eac}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LocalDebuggerCommandArguments>
|
||||
</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LocalDebuggerCommandArguments>
|
||||
</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LocalDebuggerCommandArguments>
|
||||
</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LocalDebuggerCommandArguments>
|
||||
</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
10
pkg/OpenFace/exe/FaceLandmarkVid/CMakeLists.txt
Normal file
10
pkg/OpenFace/exe/FaceLandmarkVid/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
# Local libraries
|
||||
include_directories(${LandmarkDetector_SOURCE_DIR}/include)
|
||||
|
||||
add_executable(FaceLandmarkVid FaceLandmarkVid.cpp)
|
||||
target_link_libraries(FaceLandmarkVid LandmarkDetector)
|
||||
target_link_libraries(FaceLandmarkVid FaceAnalyser)
|
||||
target_link_libraries(FaceLandmarkVid GazeAnalyser)
|
||||
target_link_libraries(FaceLandmarkVid Utilities)
|
||||
|
||||
install (TARGETS FaceLandmarkVid DESTINATION bin)
|
||||
314
pkg/OpenFace/exe/FaceLandmarkVid/FaceLandmarkVid.cpp
Normal file
314
pkg/OpenFace/exe/FaceLandmarkVid/FaceLandmarkVid.cpp
Normal file
@@ -0,0 +1,314 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017, Carnegie Mellon University and University of Cambridge,
|
||||
// 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 2.0: Facial Behavior Analysis Toolkit
|
||||
// Tadas Baltrušaitis, Amir Zadeh, Yao Chong Lim, and Louis-Philippe Morency
|
||||
// in IEEE International Conference on Automatic Face and Gesture Recognition, 2018
|
||||
//
|
||||
// Convolutional experts constrained local model for facial landmark detection.
|
||||
// A. Zadeh, T. Baltrušaitis, and Louis-Philippe Morency,
|
||||
// in Computer Vision and Pattern Recognition Workshops, 2017.
|
||||
//
|
||||
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
|
||||
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
|
||||
// in IEEE International. Conference on Computer Vision (ICCV), 2015
|
||||
//
|
||||
// Cross-dataset learning and person-specific normalisation for automatic Action Unit detection
|
||||
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
|
||||
// in Facial Expression Recognition and Analysis Challenge,
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// FaceTrackingVid.cpp : Defines the entry point for the console application for tracking faces in videos.
|
||||
|
||||
// Libraries for landmark detection (includes CLNF and CLM modules)
|
||||
#include "LandmarkCoreIncludes.h"
|
||||
#include "GazeEstimation.h"
|
||||
#include <FaceAnalyser.h>
|
||||
|
||||
|
||||
#include <SequenceCapture.h>
|
||||
#include <Visualizer.h>
|
||||
#include <VisualizationUtils.h>
|
||||
#include <RecorderOpenFace.h>
|
||||
#include <RecorderOpenFaceParameters.h>
|
||||
#include <iostream>
|
||||
#include <fstream>
|
||||
|
||||
#define INFO_STREAM( stream ) \
|
||||
std::cout << stream << std::endl
|
||||
|
||||
#define WARN_STREAM( stream ) \
|
||||
std::cout << "Warning: " << stream << std::endl
|
||||
|
||||
#define ERROR_STREAM( stream ) \
|
||||
std::cout << "Error: " << stream << std::endl
|
||||
|
||||
static void printErrorAndAbort(const std::string & error)
|
||||
{
|
||||
std::cout << error << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
#define FATAL_STREAM( stream ) \
|
||||
printErrorAndAbort( std::string( "Fatal error: " ) + stream )
|
||||
|
||||
std::vector<std::string> get_arguments(int argc, std::string *out_dir, char **argv)
|
||||
{
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
arguments.push_back(std::string(argv[i]));
|
||||
if (std::string(argv[i]).compare("-out_dir") == 0)
|
||||
{
|
||||
*out_dir = std::string(argv[i+1]);
|
||||
}
|
||||
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
|
||||
|
||||
std::string out_dir = ".";
|
||||
|
||||
std::vector<std::string> arguments = get_arguments(argc, &out_dir, argv);
|
||||
|
||||
|
||||
std::cout<< "out_dir:" << out_dir <<std::endl;
|
||||
// no arguments: output usage
|
||||
if (arguments.size() == 1)
|
||||
{
|
||||
std::cout << "For command line arguments see:" << std::endl;
|
||||
std::cout << " https://github.com/TadasBaltrusaitis/OpenFace/wiki/Command-line-arguments";
|
||||
return 0;
|
||||
}
|
||||
|
||||
LandmarkDetector::FaceModelParameters det_parameters(arguments);
|
||||
|
||||
// The modules that are being used for tracking
|
||||
LandmarkDetector::CLNF face_model(det_parameters.model_location);
|
||||
if (!face_model.loaded_successfully)
|
||||
{
|
||||
std::cout << "ERROR: Could not load the landmark detector" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!face_model.eye_model)
|
||||
{
|
||||
std::cout << "WARNING: no eye model found" << std::endl;
|
||||
}
|
||||
|
||||
// Open a sequence
|
||||
Utilities::SequenceCapture sequence_reader;
|
||||
|
||||
|
||||
|
||||
|
||||
// A utility for visualizing the results (show just the tracks)
|
||||
Utilities::Visualizer visualizer(true, false, false, false);
|
||||
|
||||
// Tracking FPS for visualization
|
||||
Utilities::FpsTracker fps_tracker;
|
||||
fps_tracker.AddFrame();
|
||||
|
||||
int sequence_number = 0;
|
||||
std::string ext = ".mp4";
|
||||
|
||||
|
||||
while (true) // this is not a for loop as we might also be reading from a webcam
|
||||
{
|
||||
|
||||
// The sequence reader chooses what to open based on command line arguments provided
|
||||
if (!sequence_reader.Open(arguments))
|
||||
break;
|
||||
|
||||
INFO_STREAM("Device or file opened");
|
||||
|
||||
cv::Mat rgb_image = sequence_reader.GetNextFrame();
|
||||
|
||||
INFO_STREAM("Starting tracking");
|
||||
|
||||
std::ofstream results;
|
||||
std::ofstream confidence;
|
||||
|
||||
std::string path = sequence_reader.name;
|
||||
|
||||
std::string base_filename = path.substr(path.find_last_of("/\\") + 1);
|
||||
base_filename = base_filename.replace(base_filename.find(ext),sizeof(ext)-1,"");
|
||||
results.open(out_dir + '/' + base_filename + "_landmark_output.csv");
|
||||
// confidence.open(out_dir + '/' + base_filename + "_landmark_likelihoods.csv");
|
||||
int lx = 0;
|
||||
int ly = 0;
|
||||
for(lx = 0; lx < 2; lx++){
|
||||
for(ly = 0; ly < 68; ly++){
|
||||
|
||||
if (lx == 0){
|
||||
results << "l" << ly << "_x,";
|
||||
// confidence << "c" << ly <<",";
|
||||
}
|
||||
if (lx == 1){
|
||||
results << "l" << ly << "_y,";
|
||||
}
|
||||
}
|
||||
}
|
||||
results << "pose_Tx,pose_Ty,pose_Tz,pose_Rx,pose_Ry,pose_Rz" ;
|
||||
results << std::endl;
|
||||
// confidence << std::endl;
|
||||
|
||||
int counter = 0;
|
||||
|
||||
// FaceAnalysis::FaceAnalyserParameters face_analysis_params(arguments);
|
||||
// face_analysis_params.OptimizeForImages();
|
||||
// FaceAnalysis::FaceAnalyser face_analyser(face_analysis_params);
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
while (!rgb_image.empty()) // this is not a for loop as we might also be reading from a webcam
|
||||
{
|
||||
|
||||
// Added lines
|
||||
// Utilities::RecorderOpenFaceParameters recording_params(arguments, false, false,
|
||||
// sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy);
|
||||
// std::string stem = sequence_reader.name;
|
||||
// stem = stem.replace(stem.find(ext),sizeof(ext)-1,"_");
|
||||
// Utilities::RecorderOpenFace open_face_rec(stem+std::to_string(counter)+ext, recording_params, arguments);
|
||||
|
||||
// Reading the images
|
||||
cv::Mat_<uchar> grayscale_image = sequence_reader.GetGrayFrame();
|
||||
|
||||
|
||||
// The actual facial landmark detection / tracking
|
||||
|
||||
bool detection_success = LandmarkDetector::DetectLandmarksInVideo(rgb_image, face_model, det_parameters, grayscale_image);
|
||||
|
||||
|
||||
// Gaze tracking, absolute gaze direction
|
||||
cv::Point3f gazeDirection0(0, 0, -1);
|
||||
cv::Point3f gazeDirection1(0, 0, -1);
|
||||
cv::Vec6d pose_estimate(0, 0, 0, 0, 0, 0);
|
||||
|
||||
// If tracking succeeded and we have an eye model, estimate gaze
|
||||
if (detection_success && face_model.eye_model)
|
||||
{
|
||||
GazeAnalysis::EstimateGaze(face_model, gazeDirection0, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, true);
|
||||
GazeAnalysis::EstimateGaze(face_model, gazeDirection1, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, false);
|
||||
}
|
||||
|
||||
// Work out the pose of the head from the tracked model
|
||||
if (detection_success){
|
||||
pose_estimate = LandmarkDetector::GetPose(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy);
|
||||
}
|
||||
|
||||
|
||||
|
||||
// cv::Mat sim_warped_img;
|
||||
// face_analyser.PredictStaticAUsAndComputeFeatures(rgb_image, face_model.detected_landmarks);
|
||||
// face_analyser.GetLatestAlignedFace(sim_warped_img);
|
||||
|
||||
|
||||
|
||||
// Keeping track of FPS
|
||||
fps_tracker.AddFrame();
|
||||
|
||||
// Displaying the tracking visualizations
|
||||
// std::cout<< "setting observation landmarks"<<std::endl;
|
||||
// visualizer.SetImage(rgb_image, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy);
|
||||
// visualizer.SetObservationLandmarks(face_model.detected_landmarks, face_model.detection_certainty, face_model.GetVisibilities());
|
||||
// visualizer.SetObservationPose(pose_estimate, face_model.detection_certainty);
|
||||
// visualizer.SetObservationGaze(gazeDirection0, gazeDirection1, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy), face_model.detection_certainty);
|
||||
// visualizer.SetFps(fps_tracker.GetFPS());
|
||||
|
||||
// std::cout << "openfacerec set obs landmarks"<<std::endl;
|
||||
// std::cout<< fps_tracker.GetFPS() <<std::endl;
|
||||
|
||||
// open_face_rec.SetObservationLandmarks(face_model.detected_landmarks, face_model.GetShape(sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy),
|
||||
// face_model.params_global, face_model.params_local, face_model.detection_certainty, face_model.detection_success);
|
||||
// open_face_rec.SetObservationPose(pose_estimate);
|
||||
// open_face_rec.SetObservationFaceAlign(sim_warped_img);
|
||||
|
||||
|
||||
int i;
|
||||
for (i=0;i< 136;i++){
|
||||
results << face_model.detected_landmarks[0][i] << ",";
|
||||
}
|
||||
for (i=0;i< 6;i++){
|
||||
if (i==5){
|
||||
results << pose_estimate[i];
|
||||
|
||||
}
|
||||
else{
|
||||
results << pose_estimate[i] << ",";
|
||||
}
|
||||
}
|
||||
results <<std::endl;
|
||||
|
||||
// for(i=0;i<68;i++){
|
||||
// if (i==67){
|
||||
// confidence << face_model.landmark_likelihoods[0][i];
|
||||
// }
|
||||
// else{
|
||||
// confidence << face_model.landmark_likelihoods[0][i] << ",";
|
||||
// }
|
||||
// }
|
||||
// confidence <<std::endl;
|
||||
|
||||
// detect key presses (due to pecularities of OpenCV, you can get it when displaying images)
|
||||
//char character_press = visualizer.ShowObservation();
|
||||
char character_press = 't';
|
||||
// restart the tracker
|
||||
if (character_press == 'r')
|
||||
{
|
||||
face_model.Reset();
|
||||
}
|
||||
// quit the application
|
||||
else if (character_press == 'q')
|
||||
{
|
||||
return(0);
|
||||
}
|
||||
|
||||
// added lines
|
||||
// open_face_rec.SetObservationVisualization(visualizer.GetVisImage());
|
||||
// open_face_rec.WriteObservationTracked();
|
||||
|
||||
// open_face_rec.Close();
|
||||
|
||||
|
||||
// Grabbing the next frame in the sequence
|
||||
rgb_image = sequence_reader.GetNextFrame();
|
||||
counter++;
|
||||
}
|
||||
|
||||
// Reset the model, for the next video
|
||||
face_model.Reset();
|
||||
sequence_reader.Close();
|
||||
|
||||
sequence_number++;
|
||||
results.close();
|
||||
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
203
pkg/OpenFace/exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj
Normal file
203
pkg/OpenFace/exe/FaceLandmarkVid/FaceLandmarkVid.vcxproj
Normal file
@@ -0,0 +1,203 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{34032CF2-1B99-4A25-9050-E9C13DD4CD0A}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>FaceLandmarkVid</RootNamespace>
|
||||
<ProjectName>FaceLandmarkVid</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>FaceLandmarkVid</TargetName>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>FaceLandmarkVid</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>FaceLandmarkVid</TargetName>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>FaceLandmarkVid</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FaceLandmarkVid.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\lib\local\FaceAnalyser\FaceAnalyser.vcxproj">
|
||||
<Project>{0e7fc556-0e80-45ea-a876-dde4c2fedcd7}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\GazeAnalyser\GazeAnalyser.vcxproj">
|
||||
<Project>{5f915541-f531-434f-9c81-79f5db58012b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\LandmarkDetector\LandmarkDetector.vcxproj">
|
||||
<Project>{bdc1d107-de17-4705-8e7b-cdde8bfb2bf8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\Utilities\Utilities.vcxproj">
|
||||
<Project>{8e741ea2-9386-4cf2-815e-6f9b08991eac}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
10
pkg/OpenFace/exe/FaceLandmarkVidMulti/CMakeLists.txt
Normal file
10
pkg/OpenFace/exe/FaceLandmarkVidMulti/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
# Local libraries
|
||||
include_directories(${LandmarkDetector_SOURCE_DIR}/include)
|
||||
|
||||
add_executable(FaceLandmarkVidMulti FaceLandmarkVidMulti.cpp)
|
||||
target_link_libraries(FaceLandmarkVidMulti LandmarkDetector)
|
||||
target_link_libraries(FaceLandmarkVidMulti FaceAnalyser)
|
||||
target_link_libraries(FaceLandmarkVidMulti GazeAnalyser)
|
||||
target_link_libraries(FaceLandmarkVidMulti Utilities)
|
||||
|
||||
install (TARGETS FaceLandmarkVidMulti DESTINATION bin)
|
||||
477
pkg/OpenFace/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp
Normal file
477
pkg/OpenFace/exe/FaceLandmarkVidMulti/FaceLandmarkVidMulti.cpp
Normal file
@@ -0,0 +1,477 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017, Carnegie Mellon University and University of Cambridge,
|
||||
// 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 2.0: Facial Behavior Analysis Toolkit
|
||||
// Tadas Baltrušaitis, Amir Zadeh, Yao Chong Lim, and Louis-Philippe Morency
|
||||
// in IEEE International Conference on Automatic Face and Gesture Recognition, 2018
|
||||
//
|
||||
// Convolutional experts constrained local model for facial landmark detection.
|
||||
// A. Zadeh, T. Baltrušaitis, and Louis-Philippe Morency,
|
||||
// in Computer Vision and Pattern Recognition Workshops, 2017.
|
||||
//
|
||||
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
|
||||
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
|
||||
// in IEEE International. Conference on Computer Vision (ICCV), 2015
|
||||
//
|
||||
// Cross-dataset learning and person-specific normalisation for automatic Action Unit detection
|
||||
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
|
||||
// in Facial Expression Recognition and Analysis Challenge,
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// FaceTrackingVidMulti.cpp : Defines the entry point for the multiple face tracking console application.
|
||||
#include "LandmarkCoreIncludes.h"
|
||||
|
||||
#include "VisualizationUtils.h"
|
||||
#include "Visualizer.h"
|
||||
#include "SequenceCapture.h"
|
||||
#include <RecorderOpenFace.h>
|
||||
#include <RecorderOpenFaceParameters.h>
|
||||
#include <GazeEstimation.h>
|
||||
#include <FaceAnalyser.h>
|
||||
|
||||
#define INFO_STREAM( stream ) \
|
||||
std::cout << stream << std::endl
|
||||
|
||||
#define WARN_STREAM( stream ) \
|
||||
std::cout << "Warning: " << stream << std::endl
|
||||
|
||||
#define ERROR_STREAM( stream ) \
|
||||
std::cout << "Error: " << stream << std::endl
|
||||
|
||||
static void printErrorAndAbort(const std::string & error)
|
||||
{
|
||||
std::cout << error << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
#define FATAL_STREAM( stream ) \
|
||||
printErrorAndAbort( std::string( "Fatal error: " ) + stream )
|
||||
|
||||
std::vector<std::string> get_arguments(int argc, char **argv)
|
||||
{
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
arguments.push_back(std::string(argv[i]));
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
double IOU(cv::Rect_<float> rect1, cv::Rect_<float> rect2)
|
||||
{
|
||||
double intersection_area = (rect1 & rect2).area();
|
||||
double union_area = rect1.area() + rect2.area() - intersection_area;
|
||||
return intersection_area / union_area;
|
||||
}
|
||||
|
||||
void RemoveOverlapingModels(std::vector<LandmarkDetector::CLNF>& face_models, std::vector<bool>& active_models)
|
||||
{
|
||||
// Go over the model and eliminate detections that are not informative (there already is a tracker there)
|
||||
for (size_t model1 = 0; model1 < active_models.size(); ++model1)
|
||||
{
|
||||
if (active_models[model1])
|
||||
{
|
||||
// See if the detections intersect
|
||||
cv::Rect_<float> model1_rect = face_models[model1].GetBoundingBox();
|
||||
|
||||
for (int model2 = model1 + 1; model2 < active_models.size(); ++model2)
|
||||
{
|
||||
if(active_models[model2])
|
||||
{
|
||||
cv::Rect_<float> model2_rect = face_models[model2].GetBoundingBox();
|
||||
|
||||
// If the model is already tracking what we're detecting ignore the detection, this is determined by amount of overlap
|
||||
if (IOU(model1_rect, model2_rect) > 0.5)
|
||||
{
|
||||
active_models[model1] = false;
|
||||
face_models[model1].Reset();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
void NonOverlapingDetections(const std::vector<LandmarkDetector::CLNF>& clnf_models, std::vector<cv::Rect_<float> >& face_detections)
|
||||
{
|
||||
|
||||
// Go over the model and eliminate detections that are not informative (there already is a tracker there)
|
||||
for (size_t model = 0; model < clnf_models.size(); ++model)
|
||||
{
|
||||
|
||||
// See if the detections intersect
|
||||
cv::Rect_<float> model_rect = clnf_models[model].GetBoundingBox();
|
||||
|
||||
for (int detection = face_detections.size() - 1; detection >= 0; --detection)
|
||||
{
|
||||
// If the model is already tracking what we're detecting ignore the detection, this is determined by amount of overlap
|
||||
if (IOU(model_rect, face_detections[detection]) > 0.5)
|
||||
{
|
||||
face_detections.erase(face_detections.begin() + detection);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
std::vector<std::string> arguments = get_arguments(argc, argv);
|
||||
|
||||
// no arguments: output usage
|
||||
if (arguments.size() == 1)
|
||||
{
|
||||
std::cout << "For command line arguments see:" << std::endl;
|
||||
std::cout << " https://github.com/TadasBaltrusaitis/OpenFace/wiki/Command-line-arguments";
|
||||
return 0;
|
||||
}
|
||||
|
||||
LandmarkDetector::FaceModelParameters det_params(arguments);
|
||||
// This is so that the model would not try re-initialising itself
|
||||
det_params.reinit_video_every = -1;
|
||||
|
||||
det_params.curr_face_detector = LandmarkDetector::FaceModelParameters::MTCNN_DETECTOR;
|
||||
|
||||
std::vector<LandmarkDetector::FaceModelParameters> det_parameters;
|
||||
det_parameters.push_back(det_params);
|
||||
|
||||
// The modules that are being used for tracking
|
||||
std::vector<LandmarkDetector::CLNF> face_models;
|
||||
std::vector<bool> active_models;
|
||||
|
||||
int num_faces_max = 4;
|
||||
|
||||
LandmarkDetector::CLNF face_model(det_parameters[0].model_location);
|
||||
|
||||
if (!face_model.loaded_successfully)
|
||||
{
|
||||
std::cout << "ERROR: Could not load the landmark detector" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Loading the face detectors
|
||||
face_model.face_detector_HAAR.load(det_parameters[0].haar_face_detector_location);
|
||||
face_model.haar_face_detector_location = det_parameters[0].haar_face_detector_location;
|
||||
face_model.face_detector_MTCNN.Read(det_parameters[0].mtcnn_face_detector_location);
|
||||
face_model.mtcnn_face_detector_location = det_parameters[0].mtcnn_face_detector_location;
|
||||
|
||||
// If can't find MTCNN face detector, default to HOG one
|
||||
if (det_parameters[0].curr_face_detector == LandmarkDetector::FaceModelParameters::MTCNN_DETECTOR && face_model.face_detector_MTCNN.empty())
|
||||
{
|
||||
std::cout << "INFO: defaulting to HOG-SVM face detector" << std::endl;
|
||||
det_parameters[0].curr_face_detector = LandmarkDetector::FaceModelParameters::HOG_SVM_DETECTOR;
|
||||
}
|
||||
|
||||
face_models.reserve(num_faces_max);
|
||||
|
||||
face_models.push_back(face_model);
|
||||
active_models.push_back(false);
|
||||
|
||||
for (int i = 1; i < num_faces_max; ++i)
|
||||
{
|
||||
face_models.push_back(face_model);
|
||||
active_models.push_back(false);
|
||||
det_parameters.push_back(det_params);
|
||||
}
|
||||
|
||||
// Load facial feature extractor and AU analyser (make sure it is static, as we don't reidentify faces)
|
||||
FaceAnalysis::FaceAnalyserParameters face_analysis_params(arguments);
|
||||
face_analysis_params.OptimizeForImages();
|
||||
FaceAnalysis::FaceAnalyser face_analyser(face_analysis_params);
|
||||
|
||||
if (!face_model.eye_model)
|
||||
{
|
||||
std::cout << "WARNING: no eye model found" << std::endl;
|
||||
}
|
||||
|
||||
if (face_analyser.GetAUClassNames().size() == 0 && face_analyser.GetAUClassNames().size() == 0)
|
||||
{
|
||||
std::cout << "WARNING: no Action Unit models found" << std::endl;
|
||||
}
|
||||
|
||||
// Open a sequence
|
||||
Utilities::SequenceCapture sequence_reader;
|
||||
|
||||
// A utility for visualizing the results (show just the tracks)
|
||||
Utilities::Visualizer visualizer(arguments);
|
||||
|
||||
// Tracking FPS for visualization
|
||||
Utilities::FpsTracker fps_tracker;
|
||||
fps_tracker.AddFrame();
|
||||
|
||||
int sequence_number = 0;
|
||||
|
||||
|
||||
while (true) // this is not a for loop as we might also be reading from a webcam
|
||||
{
|
||||
// The sequence reader chooses what to open based on command line arguments provided
|
||||
if (!sequence_reader.Open(arguments))
|
||||
break;
|
||||
|
||||
INFO_STREAM("Device or file opened");
|
||||
|
||||
cv::Mat rgb_image = sequence_reader.GetNextFrame();
|
||||
|
||||
int frame_count = 0;
|
||||
|
||||
Utilities::RecorderOpenFaceParameters recording_params(arguments, true, sequence_reader.IsWebcam(),
|
||||
sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, sequence_reader.fps);
|
||||
|
||||
if (!face_model.eye_model)
|
||||
{
|
||||
recording_params.setOutputGaze(false);
|
||||
}
|
||||
|
||||
Utilities::RecorderOpenFace open_face_rec(sequence_reader.name, recording_params, arguments);
|
||||
|
||||
if (sequence_reader.IsWebcam())
|
||||
{
|
||||
INFO_STREAM("WARNING: using a webcam in feature extraction, forcing visualization of tracking to allow quitting the application (press q)");
|
||||
visualizer.vis_track = true;
|
||||
}
|
||||
|
||||
if (recording_params.outputAUs())
|
||||
{
|
||||
INFO_STREAM("WARNING: using a AU detection in multiple face mode, it might not be as accurate and is experimental");
|
||||
}
|
||||
|
||||
// For reporting progress
|
||||
double reported_completion = 0;
|
||||
|
||||
INFO_STREAM("Starting tracking");
|
||||
while (!rgb_image.empty())
|
||||
{
|
||||
|
||||
// Reading the images
|
||||
cv::Mat_<uchar> grayscale_image = sequence_reader.GetGrayFrame();
|
||||
|
||||
std::vector<cv::Rect_<float> > face_detections;
|
||||
|
||||
bool all_models_active = true;
|
||||
for (unsigned int model = 0; model < face_models.size(); ++model)
|
||||
{
|
||||
if (!active_models[model])
|
||||
{
|
||||
all_models_active = false;
|
||||
}
|
||||
}
|
||||
|
||||
// Get the detections (every 8th frame and when there are free models available for tracking)
|
||||
if (frame_count % 8 == 0 && !all_models_active)
|
||||
{
|
||||
if (det_parameters[0].curr_face_detector == LandmarkDetector::FaceModelParameters::HOG_SVM_DETECTOR)
|
||||
{
|
||||
std::vector<float> confidences;
|
||||
LandmarkDetector::DetectFacesHOG(face_detections, grayscale_image, face_models[0].face_detector_HOG, confidences);
|
||||
}
|
||||
else if (det_parameters[0].curr_face_detector == LandmarkDetector::FaceModelParameters::HAAR_DETECTOR)
|
||||
{
|
||||
LandmarkDetector::DetectFaces(face_detections, grayscale_image, face_models[0].face_detector_HAAR);
|
||||
}
|
||||
else
|
||||
{
|
||||
std::vector<float> confidences;
|
||||
LandmarkDetector::DetectFacesMTCNN(face_detections, rgb_image, face_models[0].face_detector_MTCNN, confidences);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// Keep only non overlapping detections (so as not to start tracking where the face is already tracked)
|
||||
NonOverlapingDetections(face_models, face_detections);
|
||||
std::vector<bool> face_detections_used(face_detections.size(), false);
|
||||
|
||||
// Go through every model and update the tracking
|
||||
for (unsigned int model = 0; model < face_models.size(); ++model)
|
||||
{
|
||||
|
||||
bool detection_success = false;
|
||||
|
||||
// If the current model has failed more than 4 times in a row, remove it
|
||||
if (face_models[model].failures_in_a_row > 4)
|
||||
{
|
||||
active_models[model] = false;
|
||||
face_models[model].Reset();
|
||||
}
|
||||
|
||||
// If the model is inactive reactivate it with new detections
|
||||
if (!active_models[model])
|
||||
{
|
||||
|
||||
for (size_t detection_ind = 0; detection_ind < face_detections.size(); ++detection_ind)
|
||||
{
|
||||
// if it was not taken by another tracker take it
|
||||
if (!face_detections_used[detection_ind])
|
||||
{
|
||||
face_detections_used[detection_ind] = true;
|
||||
|
||||
// Reinitialise the model
|
||||
face_models[model].Reset();
|
||||
|
||||
// This ensures that a wider window is used for the initial landmark localisation
|
||||
face_models[model].detection_success = false;
|
||||
detection_success = LandmarkDetector::DetectLandmarksInVideo(rgb_image, face_detections[detection_ind], face_models[model], det_parameters[model], grayscale_image);
|
||||
|
||||
// This activates the model
|
||||
active_models[model] = true;
|
||||
|
||||
// break out of the loop as the tracker has been reinitialised
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// The actual facial landmark detection / tracking
|
||||
detection_success = LandmarkDetector::DetectLandmarksInVideo(rgb_image, face_models[model], det_parameters[model], grayscale_image);
|
||||
}
|
||||
}
|
||||
|
||||
// Remove models that end up tracking overlapping faces
|
||||
// even if initial bounding boxes were not overlapping, they could have ended up converging to the same face
|
||||
RemoveOverlapingModels(face_models, active_models);
|
||||
|
||||
// Keeping track of FPS
|
||||
fps_tracker.AddFrame();
|
||||
|
||||
visualizer.SetImage(rgb_image, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy);
|
||||
|
||||
// Go through every model and detect eye gaze, record results and visualise the results
|
||||
for (size_t model = 0; model < face_models.size(); ++model)
|
||||
{
|
||||
// Visualising and recording the results
|
||||
if (active_models[model])
|
||||
{
|
||||
|
||||
// Estimate head pose and eye gaze
|
||||
cv::Vec6d pose_estimate = LandmarkDetector::GetPose(face_models[model], sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy);
|
||||
|
||||
cv::Point3f gaze_direction0(0, 0, 0); cv::Point3f gaze_direction1(0, 0, 0); cv::Vec2d gaze_angle(0, 0);
|
||||
|
||||
// Detect eye gazes
|
||||
if (face_models[model].detection_success && face_model.eye_model)
|
||||
{
|
||||
GazeAnalysis::EstimateGaze(face_models[model], gaze_direction0, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, true);
|
||||
GazeAnalysis::EstimateGaze(face_models[model], gaze_direction1, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, false);
|
||||
gaze_angle = GazeAnalysis::GetGazeAngle(gaze_direction0, gaze_direction1);
|
||||
}
|
||||
|
||||
// Face analysis step
|
||||
cv::Mat sim_warped_img;
|
||||
cv::Mat_<double> hog_descriptor; int num_hog_rows = 0, num_hog_cols = 0;
|
||||
|
||||
// Perform AU detection and HOG feature extraction, as this can be expensive only compute it if needed by output or visualization
|
||||
if (recording_params.outputAlignedFaces() || recording_params.outputHOG() || recording_params.outputAUs() || visualizer.vis_align || visualizer.vis_hog)
|
||||
{
|
||||
face_analyser.PredictStaticAUsAndComputeFeatures(rgb_image, face_models[model].detected_landmarks);
|
||||
face_analyser.GetLatestAlignedFace(sim_warped_img);
|
||||
face_analyser.GetLatestHOG(hog_descriptor, num_hog_rows, num_hog_cols);
|
||||
}
|
||||
|
||||
// Visualize the features
|
||||
visualizer.SetObservationFaceAlign(sim_warped_img);
|
||||
visualizer.SetObservationHOG(hog_descriptor, num_hog_rows, num_hog_cols);
|
||||
visualizer.SetObservationLandmarks(face_models[model].detected_landmarks, face_models[model].detection_certainty);
|
||||
visualizer.SetObservationPose(LandmarkDetector::GetPose(face_models[model], sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy), face_models[model].detection_certainty);
|
||||
visualizer.SetObservationGaze(gaze_direction0, gaze_direction1, LandmarkDetector::CalculateAllEyeLandmarks(face_models[model]), LandmarkDetector::Calculate3DEyeLandmarks(face_models[model], sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy), face_models[model].detection_certainty);
|
||||
visualizer.SetObservationActionUnits(face_analyser.GetCurrentAUsReg(), face_analyser.GetCurrentAUsClass());
|
||||
|
||||
// Output features
|
||||
open_face_rec.SetObservationHOG(face_models[model].detection_success, hog_descriptor, num_hog_rows, num_hog_cols, 31); // The number of channels in HOG is fixed at the moment, as using FHOG
|
||||
open_face_rec.SetObservationActionUnits(face_analyser.GetCurrentAUsReg(), face_analyser.GetCurrentAUsClass());
|
||||
open_face_rec.SetObservationLandmarks(face_models[model].detected_landmarks, face_models[model].GetShape(sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy),
|
||||
face_models[model].params_global, face_models[model].params_local, face_models[model].detection_certainty, face_models[model].detection_success);
|
||||
open_face_rec.SetObservationPose(pose_estimate);
|
||||
open_face_rec.SetObservationGaze(gaze_direction0, gaze_direction1, gaze_angle, LandmarkDetector::CalculateAllEyeLandmarks(face_models[model]), LandmarkDetector::Calculate3DEyeLandmarks(face_models[model], sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy));
|
||||
open_face_rec.SetObservationFaceAlign(sim_warped_img);
|
||||
open_face_rec.SetObservationFaceID(model);
|
||||
open_face_rec.SetObservationTimestamp(sequence_reader.time_stamp);
|
||||
open_face_rec.SetObservationFrameNumber(sequence_reader.GetFrameNumber());
|
||||
open_face_rec.WriteObservation();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
visualizer.SetFps(fps_tracker.GetFPS());
|
||||
|
||||
// Record frame
|
||||
open_face_rec.SetObservationVisualization(visualizer.GetVisImage());
|
||||
open_face_rec.WriteObservationTracked();
|
||||
|
||||
// show visualization and detect key presses
|
||||
char character_press = visualizer.ShowObservation();
|
||||
|
||||
// restart the trackers
|
||||
if (character_press == 'r')
|
||||
{
|
||||
for (size_t i = 0; i < face_models.size(); ++i)
|
||||
{
|
||||
face_models[i].Reset();
|
||||
active_models[i] = false;
|
||||
}
|
||||
}
|
||||
// quit the application
|
||||
else if (character_press == 'q')
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Reporting progress
|
||||
if (sequence_reader.GetProgress() >= reported_completion / 10.0)
|
||||
{
|
||||
std::cout << reported_completion * 10 << "% ";
|
||||
if (reported_completion == 10)
|
||||
{
|
||||
std::cout << std::endl;
|
||||
}
|
||||
reported_completion = reported_completion + 1;
|
||||
}
|
||||
|
||||
// Update the frame count
|
||||
frame_count++;
|
||||
|
||||
// Grabbing the next frame in the sequence
|
||||
rgb_image = sequence_reader.GetNextFrame();
|
||||
|
||||
}
|
||||
|
||||
frame_count = 0;
|
||||
|
||||
// Reset the model, for the next video
|
||||
for (size_t model = 0; model < face_models.size(); ++model)
|
||||
{
|
||||
face_models[model].Reset();
|
||||
active_models[model] = false;
|
||||
}
|
||||
|
||||
INFO_STREAM("Closing output recorder");
|
||||
open_face_rec.Close();
|
||||
INFO_STREAM("Closing input reader");
|
||||
sequence_reader.Close();
|
||||
INFO_STREAM("Closed successfully");
|
||||
|
||||
sequence_number++;
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,185 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{C3FAF36F-44BC-4454-87C2-C5106575FE50}</ProjectGuid>
|
||||
<RootNamespace>FaceLandmarkVidMulti</RootNamespace>
|
||||
<ProjectName>FaceLandmarkVidMulti</ProjectName>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<TargetName>FaceLandmarkVidMulti</TargetName>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<TargetName>FaceLandmarkVidMulti</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<TargetName>FaceLandmarkVidMulti</TargetName>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<TargetName>FaceLandmarkVidMulti</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\Utilities\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\Utilities\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\Utilities\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\Utilities\include;$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\GazeAnalyser\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<PreprocessorDefinitions>WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FaceLandmarkVidMulti.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\lib\local\FaceAnalyser\FaceAnalyser.vcxproj">
|
||||
<Project>{0e7fc556-0e80-45ea-a876-dde4c2fedcd7}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\GazeAnalyser\GazeAnalyser.vcxproj">
|
||||
<Project>{5f915541-f531-434f-9c81-79f5db58012b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\LandmarkDetector\LandmarkDetector.vcxproj">
|
||||
<Project>{bdc1d107-de17-4705-8e7b-cdde8bfb2bf8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\Utilities\Utilities.vcxproj">
|
||||
<Project>{8e741ea2-9386-4cf2-815e-6f9b08991eac}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
10
pkg/OpenFace/exe/FeatureExtraction/CMakeLists.txt
Normal file
10
pkg/OpenFace/exe/FeatureExtraction/CMakeLists.txt
Normal file
@@ -0,0 +1,10 @@
|
||||
# Local libraries
|
||||
include_directories(${LandmarkDetector_SOURCE_DIR}/include)
|
||||
|
||||
add_executable(FeatureExtraction FeatureExtraction.cpp)
|
||||
target_link_libraries(FeatureExtraction LandmarkDetector)
|
||||
target_link_libraries(FeatureExtraction FaceAnalyser)
|
||||
target_link_libraries(FeatureExtraction GazeAnalyser)
|
||||
target_link_libraries(FeatureExtraction Utilities)
|
||||
|
||||
install (TARGETS FeatureExtraction DESTINATION bin)
|
||||
273
pkg/OpenFace/exe/FeatureExtraction/FeatureExtraction.cpp
Normal file
273
pkg/OpenFace/exe/FeatureExtraction/FeatureExtraction.cpp
Normal file
@@ -0,0 +1,273 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017, Carnegie Mellon University and University of Cambridge,
|
||||
// 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 2.0: Facial Behavior Analysis Toolkit
|
||||
// Tadas Baltrušaitis, Amir Zadeh, Yao Chong Lim, and Louis-Philippe Morency
|
||||
// in IEEE International Conference on Automatic Face and Gesture Recognition, 2018
|
||||
//
|
||||
// Convolutional experts constrained local model for facial landmark detection.
|
||||
// A. Zadeh, T. Baltrušaitis, and Louis-Philippe Morency,
|
||||
// in Computer Vision and Pattern Recognition Workshops, 2017.
|
||||
//
|
||||
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
|
||||
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
|
||||
// in IEEE International. Conference on Computer Vision (ICCV), 2015
|
||||
//
|
||||
// Cross-dataset learning and person-specific normalisation for automatic Action Unit detection
|
||||
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
|
||||
// in Facial Expression Recognition and Analysis Challenge,
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
|
||||
// FeatureExtraction.cpp : Defines the entry point for the feature extraction console application.
|
||||
|
||||
// Local includes
|
||||
#include "LandmarkCoreIncludes.h"
|
||||
|
||||
#include <Face_utils.h>
|
||||
#include <FaceAnalyser.h>
|
||||
#include <GazeEstimation.h>
|
||||
#include <RecorderOpenFace.h>
|
||||
#include <RecorderOpenFaceParameters.h>
|
||||
#include <SequenceCapture.h>
|
||||
#include <Visualizer.h>
|
||||
#include <VisualizationUtils.h>
|
||||
|
||||
#ifndef CONFIG_DIR
|
||||
#define CONFIG_DIR "~"
|
||||
#endif
|
||||
|
||||
#define INFO_STREAM( stream ) \
|
||||
std::cout << stream << std::endl
|
||||
|
||||
#define WARN_STREAM( stream ) \
|
||||
std::cout << "Warning: " << stream << std::endl
|
||||
|
||||
#define ERROR_STREAM( stream ) \
|
||||
std::cout << "Error: " << stream << std::endl
|
||||
|
||||
static void printErrorAndAbort(const std::string & error)
|
||||
{
|
||||
std::cout << error << std::endl;
|
||||
}
|
||||
|
||||
#define FATAL_STREAM( stream ) \
|
||||
printErrorAndAbort( std::string( "Fatal error: " ) + stream )
|
||||
|
||||
std::vector<std::string> get_arguments(int argc, char **argv)
|
||||
{
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
|
||||
// First argument is reserved for the name of the executable
|
||||
for (int i = 0; i < argc; ++i)
|
||||
{
|
||||
arguments.push_back(std::string(argv[i]));
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
std::vector<std::string> arguments = get_arguments(argc, argv);
|
||||
|
||||
// no arguments: output usage
|
||||
if (arguments.size() == 1)
|
||||
{
|
||||
std::cout << "For command line arguments see:" << std::endl;
|
||||
std::cout << " https://github.com/TadasBaltrusaitis/OpenFace/wiki/Command-line-arguments";
|
||||
return 0;
|
||||
}
|
||||
|
||||
// Load the modules that are being used for tracking and face analysis
|
||||
// Load face landmark detector
|
||||
LandmarkDetector::FaceModelParameters det_parameters(arguments);
|
||||
// Always track gaze in feature extraction
|
||||
LandmarkDetector::CLNF face_model(det_parameters.model_location);
|
||||
|
||||
if (!face_model.loaded_successfully)
|
||||
{
|
||||
std::cout << "ERROR: Could not load the landmark detector" << std::endl;
|
||||
return 1;
|
||||
}
|
||||
|
||||
// Load facial feature extractor and AU analyser
|
||||
FaceAnalysis::FaceAnalyserParameters face_analysis_params(arguments);
|
||||
FaceAnalysis::FaceAnalyser face_analyser(face_analysis_params);
|
||||
|
||||
if (!face_model.eye_model)
|
||||
{
|
||||
std::cout << "WARNING: no eye model found" << std::endl;
|
||||
}
|
||||
|
||||
if (face_analyser.GetAUClassNames().size() == 0 && face_analyser.GetAUClassNames().size() == 0)
|
||||
{
|
||||
std::cout << "WARNING: no Action Unit models found" << std::endl;
|
||||
}
|
||||
|
||||
Utilities::SequenceCapture sequence_reader;
|
||||
|
||||
// A utility for visualizing the results
|
||||
Utilities::Visualizer visualizer(arguments);
|
||||
|
||||
// Tracking FPS for visualization
|
||||
Utilities::FpsTracker fps_tracker;
|
||||
fps_tracker.AddFrame();
|
||||
|
||||
while (true) // this is not a for loop as we might also be reading from a webcam
|
||||
{
|
||||
|
||||
// The sequence reader chooses what to open based on command line arguments provided
|
||||
if (!sequence_reader.Open(arguments))
|
||||
break;
|
||||
|
||||
INFO_STREAM("Device or file opened");
|
||||
|
||||
if (sequence_reader.IsWebcam())
|
||||
{
|
||||
INFO_STREAM("WARNING: using a webcam in feature extraction, Action Unit predictions will not be as accurate in real-time webcam mode");
|
||||
INFO_STREAM("WARNING: using a webcam in feature extraction, forcing visualization of tracking to allow quitting the application (press q)");
|
||||
visualizer.vis_track = true;
|
||||
}
|
||||
|
||||
cv::Mat captured_image;
|
||||
|
||||
Utilities::RecorderOpenFaceParameters recording_params(arguments, true, sequence_reader.IsWebcam(),
|
||||
sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, sequence_reader.fps);
|
||||
if (!face_model.eye_model)
|
||||
{
|
||||
recording_params.setOutputGaze(false);
|
||||
}
|
||||
Utilities::RecorderOpenFace open_face_rec(sequence_reader.name, recording_params, arguments);
|
||||
|
||||
if (recording_params.outputGaze() && !face_model.eye_model)
|
||||
std::cout << "WARNING: no eye model defined, but outputting gaze" << std::endl;
|
||||
|
||||
captured_image = sequence_reader.GetNextFrame();
|
||||
|
||||
// For reporting progress
|
||||
double reported_completion = 0;
|
||||
|
||||
INFO_STREAM("Starting tracking");
|
||||
while (!captured_image.empty())
|
||||
{
|
||||
// Converting to grayscale
|
||||
cv::Mat_<uchar> grayscale_image = sequence_reader.GetGrayFrame();
|
||||
|
||||
|
||||
// The actual facial landmark detection / tracking
|
||||
bool detection_success = LandmarkDetector::DetectLandmarksInVideo(captured_image, face_model, det_parameters, grayscale_image);
|
||||
|
||||
// Gaze tracking, absolute gaze direction
|
||||
cv::Point3f gazeDirection0(0, 0, 0); cv::Point3f gazeDirection1(0, 0, 0); cv::Vec2d gazeAngle(0, 0);
|
||||
|
||||
if (detection_success && face_model.eye_model)
|
||||
{
|
||||
GazeAnalysis::EstimateGaze(face_model, gazeDirection0, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, true);
|
||||
GazeAnalysis::EstimateGaze(face_model, gazeDirection1, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy, false);
|
||||
gazeAngle = GazeAnalysis::GetGazeAngle(gazeDirection0, gazeDirection1);
|
||||
}
|
||||
|
||||
// Do face alignment
|
||||
cv::Mat sim_warped_img;
|
||||
cv::Mat_<double> hog_descriptor; int num_hog_rows = 0, num_hog_cols = 0;
|
||||
|
||||
// Perform AU detection and HOG feature extraction, as this can be expensive only compute it if needed by output or visualization
|
||||
if (recording_params.outputAlignedFaces() || recording_params.outputHOG() || recording_params.outputAUs() || visualizer.vis_align || visualizer.vis_hog || visualizer.vis_aus)
|
||||
{
|
||||
face_analyser.AddNextFrame(captured_image, face_model.detected_landmarks, face_model.detection_success, sequence_reader.time_stamp, sequence_reader.IsWebcam());
|
||||
face_analyser.GetLatestAlignedFace(sim_warped_img);
|
||||
face_analyser.GetLatestHOG(hog_descriptor, num_hog_rows, num_hog_cols);
|
||||
}
|
||||
|
||||
// Work out the pose of the head from the tracked model
|
||||
cv::Vec6d pose_estimate = LandmarkDetector::GetPose(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy);
|
||||
|
||||
// Keeping track of FPS
|
||||
fps_tracker.AddFrame();
|
||||
|
||||
// Displaying the tracking visualizations
|
||||
visualizer.SetImage(captured_image, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy);
|
||||
visualizer.SetObservationFaceAlign(sim_warped_img);
|
||||
visualizer.SetObservationHOG(hog_descriptor, num_hog_rows, num_hog_cols);
|
||||
visualizer.SetObservationLandmarks(face_model.detected_landmarks, face_model.detection_certainty, face_model.GetVisibilities());
|
||||
visualizer.SetObservationPose(pose_estimate, face_model.detection_certainty);
|
||||
visualizer.SetObservationGaze(gazeDirection0, gazeDirection1, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy), face_model.detection_certainty);
|
||||
visualizer.SetObservationActionUnits(face_analyser.GetCurrentAUsReg(), face_analyser.GetCurrentAUsClass());
|
||||
visualizer.SetFps(fps_tracker.GetFPS());
|
||||
|
||||
// detect key presses
|
||||
char character_press = visualizer.ShowObservation();
|
||||
|
||||
// quit processing the current sequence (useful when in Webcam mode)
|
||||
if (character_press == 'q')
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
||||
// Setting up the recorder output
|
||||
open_face_rec.SetObservationHOG(detection_success, hog_descriptor, num_hog_rows, num_hog_cols, 31); // The number of channels in HOG is fixed at the moment, as using FHOG
|
||||
open_face_rec.SetObservationVisualization(visualizer.GetVisImage());
|
||||
open_face_rec.SetObservationActionUnits(face_analyser.GetCurrentAUsReg(), face_analyser.GetCurrentAUsClass());
|
||||
open_face_rec.SetObservationLandmarks(face_model.detected_landmarks, face_model.GetShape(sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy),
|
||||
face_model.params_global, face_model.params_local, face_model.detection_certainty, detection_success);
|
||||
open_face_rec.SetObservationPose(pose_estimate);
|
||||
open_face_rec.SetObservationGaze(gazeDirection0, gazeDirection1, gazeAngle, LandmarkDetector::CalculateAllEyeLandmarks(face_model), LandmarkDetector::Calculate3DEyeLandmarks(face_model, sequence_reader.fx, sequence_reader.fy, sequence_reader.cx, sequence_reader.cy));
|
||||
open_face_rec.SetObservationTimestamp(sequence_reader.time_stamp);
|
||||
open_face_rec.SetObservationFaceID(0);
|
||||
open_face_rec.SetObservationFrameNumber(sequence_reader.GetFrameNumber());
|
||||
open_face_rec.SetObservationFaceAlign(sim_warped_img);
|
||||
open_face_rec.WriteObservation();
|
||||
open_face_rec.WriteObservationTracked();
|
||||
|
||||
// Reporting progress
|
||||
if (sequence_reader.GetProgress() >= reported_completion / 10.0)
|
||||
{
|
||||
std::cout << reported_completion * 10 << "% ";
|
||||
if (reported_completion == 10)
|
||||
{
|
||||
std::cout << std::endl;
|
||||
}
|
||||
reported_completion = reported_completion + 1;
|
||||
}
|
||||
|
||||
// Grabbing the next frame in the sequence
|
||||
captured_image = sequence_reader.GetNextFrame();
|
||||
|
||||
}
|
||||
|
||||
INFO_STREAM("Closing output recorder");
|
||||
open_face_rec.Close();
|
||||
INFO_STREAM("Closing input reader");
|
||||
sequence_reader.Close();
|
||||
INFO_STREAM("Closed successfully");
|
||||
|
||||
if (recording_params.outputAUs())
|
||||
{
|
||||
INFO_STREAM("Postprocessing the Action Unit predictions");
|
||||
face_analyser.PostprocessOutputFile(open_face_rec.GetCSVFile());
|
||||
}
|
||||
|
||||
// Reset the models for the next video
|
||||
face_analyser.Reset();
|
||||
face_model.Reset();
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
204
pkg/OpenFace/exe/FeatureExtraction/FeatureExtraction.vcxproj
Normal file
204
pkg/OpenFace/exe/FeatureExtraction/FeatureExtraction.vcxproj
Normal file
@@ -0,0 +1,204 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{8A23C00D-767D-422D-89A3-CF225E3DAB4B}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>FeatureExtraction</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>FeatureExtraction</TargetName>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<LinkIncremental>true</LinkIncremental>
|
||||
<TargetName>FeatureExtraction</TargetName>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>FeatureExtraction</TargetName>
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<LinkIncremental>false</LinkIncremental>
|
||||
<TargetName>FeatureExtraction</TargetName>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<PreprocessorDefinitions>WIN64;_DEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN32;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>NotUsing</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<PreprocessorDefinitions>WIN64;NDEBUG;_CONSOLE;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>$(SolutionDir)\lib\local\FaceAnalyser\include;$(SolutionDir)\lib\local\LandmarkDetector\include;$(SolutionDir)\lib\local\GazeAnalyser\include;$(SolutionDir)\lib\local\Utilities\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Console</SubSystem>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="FeatureExtraction.cpp" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\lib\local\FaceAnalyser\FaceAnalyser.vcxproj">
|
||||
<Project>{0e7fc556-0e80-45ea-a876-dde4c2fedcd7}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\GazeAnalyser\GazeAnalyser.vcxproj">
|
||||
<Project>{5f915541-f531-434f-9c81-79f5db58012b}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\LandmarkDetector\LandmarkDetector.vcxproj">
|
||||
<Project>{bdc1d107-de17-4705-8e7b-cdde8bfb2bf8}</Project>
|
||||
</ProjectReference>
|
||||
<ProjectReference Include="..\..\lib\local\Utilities\Utilities.vcxproj">
|
||||
<Project>{8e741ea2-9386-4cf2-815e-6f9b08991eac}</Project>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
201
pkg/OpenFace/exe/Recording/Record.cpp
Normal file
201
pkg/OpenFace/exe/Recording/Record.cpp
Normal file
@@ -0,0 +1,201 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// Copyright (C) 2017, Carnegie Mellon University and University of Cambridge,
|
||||
// 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 2.0: Facial Behavior Analysis Toolkit
|
||||
// Tadas Baltrušaitis, Amir Zadeh, Yao Chong Lim, and Louis-Philippe Morency
|
||||
// in IEEE International Conference on Automatic Face and Gesture Recognition, 2018
|
||||
//
|
||||
// Convolutional experts constrained local model for facial landmark detection.
|
||||
// A. Zadeh, T. Baltrušaitis, and Louis-Philippe Morency,
|
||||
// in Computer Vision and Pattern Recognition Workshops, 2017.
|
||||
//
|
||||
// Rendering of Eyes for Eye-Shape Registration and Gaze Estimation
|
||||
// Erroll Wood, Tadas Baltrušaitis, Xucong Zhang, Yusuke Sugano, Peter Robinson, and Andreas Bulling
|
||||
// in IEEE International. Conference on Computer Vision (ICCV), 2015
|
||||
//
|
||||
// Cross-dataset learning and person-specific normalisation for automatic Action Unit detection
|
||||
// Tadas Baltrušaitis, Marwa Mahmoud, and Peter Robinson
|
||||
// in Facial Expression Recognition and Analysis Challenge,
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
// Record.cpp : A useful function for quick recording from a webcam for test purposes
|
||||
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
|
||||
#include <iostream>
|
||||
|
||||
#include <windows.h>
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
|
||||
#include <stdio.h>
|
||||
#include <time.h>
|
||||
|
||||
#include <filesystem>
|
||||
|
||||
#define INFO_STREAM( stream ) \
|
||||
std::cout << stream << std::endl
|
||||
|
||||
#define WARN_STREAM( stream ) \
|
||||
std::cout << "Warning: " << stream << std::endl
|
||||
|
||||
#define ERROR_STREAM( stream ) \
|
||||
std::cout << "Error: " << stream << std::endl
|
||||
|
||||
static void printErrorAndAbort( const std::string & error )
|
||||
{
|
||||
std::cout << error << std::endl;
|
||||
abort();
|
||||
}
|
||||
|
||||
#define FATAL_STREAM( stream ) \
|
||||
printErrorAndAbort( std::string( "Fatal error: " ) + stream )
|
||||
|
||||
// Get current date/time, format is YYYY-MM-DD.HH:mm:ss
|
||||
const std::string currentDateTime() {
|
||||
time_t now = time(0);
|
||||
struct tm tstruct;
|
||||
char buf[80];
|
||||
localtime_s(&tstruct, &now);
|
||||
// Visit http://www.cplusplus.com/reference/clibrary/ctime/strftime/
|
||||
// for more information about date/time format
|
||||
strftime(buf, sizeof(buf), "%Y-%m-%d-%H-%M", &tstruct);
|
||||
|
||||
return buf;
|
||||
}
|
||||
|
||||
std::vector<std::string> get_arguments(int argc, char **argv)
|
||||
{
|
||||
|
||||
std::vector<std::string> arguments;
|
||||
|
||||
for(int i = 1; i < argc; ++i)
|
||||
{
|
||||
arguments.push_back(std::string(argv[i]));
|
||||
}
|
||||
return arguments;
|
||||
}
|
||||
|
||||
int main (int argc, char **argv)
|
||||
{
|
||||
|
||||
std::vector<std::string> arguments = get_arguments(argc, argv);
|
||||
|
||||
// Some initial parameters that can be overriden from command line
|
||||
std::string outroot, outfile;
|
||||
|
||||
TCHAR NPath[200];
|
||||
GetCurrentDirectory(200, NPath);
|
||||
|
||||
// By default write to same directory
|
||||
outroot = NPath;
|
||||
outroot = outroot + "/recording/";
|
||||
outfile = currentDateTime() + ".avi";
|
||||
|
||||
// By default try webcam
|
||||
int device = 0;
|
||||
|
||||
for (size_t i = 0; i < arguments.size(); i++)
|
||||
{
|
||||
if( strcmp( arguments[i].c_str(), "-dev") == 0 )
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << arguments[i+1].c_str();
|
||||
ss >> device;
|
||||
}
|
||||
else if (strcmp(arguments[i].c_str(), "-r") == 0)
|
||||
{
|
||||
outroot = arguments[i+1];
|
||||
}
|
||||
else if (strcmp(arguments[i].c_str(), "-of") == 0)
|
||||
{
|
||||
outroot = arguments[i+1];
|
||||
}
|
||||
else
|
||||
{
|
||||
WARN_STREAM( "invalid argument" );
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
// Do some grabbing
|
||||
cv::VideoCapture vCap;
|
||||
INFO_STREAM( "Attempting to capture from device: " << device );
|
||||
vCap = cv::VideoCapture( device );
|
||||
|
||||
if (!vCap.isOpened()) {
|
||||
FATAL_STREAM("Failed to open video source");
|
||||
return 1;
|
||||
}
|
||||
|
||||
cv::Mat img;
|
||||
vCap >> img;
|
||||
|
||||
std::filesystem::path dir(outroot);
|
||||
std::filesystem::create_directory(dir);
|
||||
|
||||
std::string out_file = outroot + outfile;
|
||||
// saving the videos
|
||||
cv::VideoWriter video_writer(out_file, cv::VideoWriter::fourcc('D','I','V','X'), 30, img.size(), true);
|
||||
|
||||
std::ofstream outlog;
|
||||
outlog.open((outroot + outfile + ".log").c_str(), std::ios_base::out);
|
||||
outlog << "frame, time(ms)" << std::endl;
|
||||
|
||||
double freq = cv::getTickFrequency();
|
||||
|
||||
double init_time = (double)cv::getTickCount();
|
||||
|
||||
int frameProc = 0;
|
||||
while(!img.empty())
|
||||
{
|
||||
|
||||
cv::namedWindow("rec",1);
|
||||
|
||||
vCap >> img;
|
||||
double curr_time = (cv::getTickCount() - init_time) / freq;
|
||||
curr_time *= 1000;
|
||||
|
||||
video_writer << img;
|
||||
|
||||
outlog << frameProc + 1 << " " << curr_time;
|
||||
outlog << std::endl;
|
||||
|
||||
|
||||
cv::imshow("rec", img);
|
||||
|
||||
frameProc++;
|
||||
|
||||
// detect key presses
|
||||
char c = cv::waitKey(1);
|
||||
|
||||
// quit the application
|
||||
if(c=='q')
|
||||
{
|
||||
outlog.close();
|
||||
|
||||
return(0);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
146
pkg/OpenFace/exe/Recording/Recording.vcxproj
Normal file
146
pkg/OpenFace/exe/Recording/Recording.vcxproj
Normal file
@@ -0,0 +1,146 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectGuid>{2D80FA0B-2DE8-4475-BA5A-C08A9E1EDAAC}</ProjectGuid>
|
||||
<RootNamespace>Recording</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>Application</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\lib\3rdParty\OpenCV\openCV.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<IntDir>$(ProjectDir)$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>Disabled</Optimization>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<CallingConvention>Cdecl</CallingConvention>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<Profile>true</Profile>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<Optimization>MaxSpeed</Optimization>
|
||||
<FunctionLevelLinking>true</FunctionLevelLinking>
|
||||
<IntrinsicFunctions>true</IntrinsicFunctions>
|
||||
<OpenMPSupport>false</OpenMPSupport>
|
||||
<CallingConvention>Cdecl</CallingConvention>
|
||||
<MultiProcessorCompilation>true</MultiProcessorCompilation>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<GenerateDebugInformation>true</GenerateDebugInformation>
|
||||
<EnableCOMDATFolding>true</EnableCOMDATFolding>
|
||||
<OptimizeReferences>true</OptimizeReferences>
|
||||
<Profile>true</Profile>
|
||||
<AdditionalDependencies>%(AdditionalDependencies)</AdditionalDependencies>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Record.cpp" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
17
pkg/OpenFace/exe/Recording/Recording.vcxproj.user
Normal file
17
pkg/OpenFace/exe/Recording/Recording.vcxproj.user
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<LocalDebuggerCommandArguments>
|
||||
</LocalDebuggerCommandArguments>
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
|
||||
</PropertyGroup>
|
||||
</Project>
|
||||
158
pkg/OpenFace/exe/releases/package_windows_executables.m
Normal file
158
pkg/OpenFace/exe/releases/package_windows_executables.m
Normal file
@@ -0,0 +1,158 @@
|
||||
clear;
|
||||
version = '2.2.0';
|
||||
|
||||
out_x86 = sprintf('OpenFace_%s_win_x86', version);
|
||||
out_x64 = sprintf('OpenFace_%s_win_x64', version);
|
||||
|
||||
mkdir(out_x86);
|
||||
mkdir(out_x64);
|
||||
|
||||
in_x86 = '../../Release/';
|
||||
in_x64 = '../../x64/Release/';
|
||||
|
||||
% Copy models
|
||||
copyfile([in_x86, 'AU_predictors'], [out_x86, '/AU_predictors'])
|
||||
copyfile([in_x86, 'classifiers'], [out_x86, '/classifiers'])
|
||||
copyfile([in_x86, 'model'], [out_x86, '/model'])
|
||||
|
||||
copyfile([in_x64, 'AU_predictors'], [out_x64, '/AU_predictors'])
|
||||
copyfile([in_x64, 'classifiers'], [out_x64, '/classifiers'])
|
||||
copyfile([in_x64, 'model'], [out_x64, '/model'])
|
||||
|
||||
|
||||
copyfile('readme.txt', out_x86);
|
||||
copyfile('../../download_models.ps1', out_x86);
|
||||
copyfile('readme.txt', out_x64);
|
||||
copyfile('../../download_models.ps1', out_x64);
|
||||
|
||||
%% Copy libraries
|
||||
libs_x86 = dir([in_x86, '*.lib'])';
|
||||
|
||||
for lib = libs_x86
|
||||
|
||||
copyfile([in_x86, '/', lib.name], [out_x86, '/', lib.name])
|
||||
|
||||
end
|
||||
|
||||
libs_x64 = dir([in_x64, '*.lib'])';
|
||||
|
||||
for lib = libs_x64
|
||||
|
||||
copyfile([in_x64, '/', lib.name], [out_x64, '/', lib.name])
|
||||
|
||||
end
|
||||
|
||||
%% Copy dlls
|
||||
dlls_x86 = dir([in_x86, '*.dll'])';
|
||||
|
||||
for dll = dlls_x86
|
||||
|
||||
copyfile([in_x86, '/', dll.name], [out_x86, '/', dll.name])
|
||||
|
||||
end
|
||||
|
||||
dlls_x64 = dir([in_x64, '*.dll'])';
|
||||
|
||||
for dll = dlls_x64
|
||||
|
||||
copyfile([in_x64, '/', dll.name], [out_x64, '/', dll.name])
|
||||
|
||||
end
|
||||
|
||||
% Copy zmq dll's
|
||||
mkdir([out_x64, '/amd64']);
|
||||
copyfile([in_x64, '/amd64'], [out_x64, '/amd64']);
|
||||
mkdir([out_x64, '/i386']);
|
||||
copyfile([in_x64, '/i386'], [out_x64, '/i386']);
|
||||
|
||||
mkdir([out_x86, '/amd64']);
|
||||
copyfile([in_x86, '/amd64'], [out_x86, '/amd64']);
|
||||
mkdir([out_x86, '/i386']);
|
||||
copyfile([in_x86, '/i386'], [out_x86, '/i386']);
|
||||
|
||||
%% Copy exe's
|
||||
exes_x86 = dir([in_x86, '*.exe'])';
|
||||
|
||||
for exe = exes_x86
|
||||
|
||||
copyfile([in_x86, '/', exe.name], [out_x86, '/', exe.name])
|
||||
|
||||
end
|
||||
|
||||
exes_x64 = dir([in_x64, '*.exe'])';
|
||||
|
||||
for exe = exes_x64
|
||||
|
||||
copyfile([in_x64, '/', exe.name], [out_x64, '/', exe.name])
|
||||
|
||||
end
|
||||
|
||||
%% Copy license and copyright
|
||||
copyfile('../../Copyright.txt', [out_x86, '/Copyright.txt']);
|
||||
copyfile('../../OpenFace-license.txt', [out_x86, '/OpenFace-license.txt']);
|
||||
|
||||
copyfile('../../Copyright.txt', [out_x64, '/Copyright.txt']);
|
||||
copyfile('../../OpenFace-license.txt', [out_x64, '/OpenFace-license.txt']);
|
||||
|
||||
%% Copy icons etc. needed for GUI
|
||||
img_x86 = dir([in_x86, '*.ico'])';
|
||||
|
||||
for img = img_x86
|
||||
|
||||
copyfile([in_x86, '/', img.name], [out_x86, '/', img.name])
|
||||
|
||||
end
|
||||
|
||||
img_x64 = dir([in_x64, '*.ico'])';
|
||||
|
||||
for img = img_x64
|
||||
|
||||
copyfile([in_x64, '/', img.name], [out_x64, '/', img.name])
|
||||
|
||||
end
|
||||
|
||||
img_x86 = dir([in_x86, '*.png'])';
|
||||
|
||||
for img = img_x86
|
||||
|
||||
copyfile([in_x86, '/', img.name], [out_x86, '/', img.name])
|
||||
|
||||
end
|
||||
|
||||
img_x64 = dir([in_x86, '*.png'])';
|
||||
|
||||
for img = img_x64
|
||||
|
||||
copyfile([in_x64, '/', img.name], [out_x64, '/', img.name])
|
||||
|
||||
end
|
||||
|
||||
%% Copy sample images for testing
|
||||
copyfile('../../samples', [out_x86, '/samples']);
|
||||
copyfile('../../samples', [out_x64 '/samples']);
|
||||
|
||||
%% Test if everything worked by running examples
|
||||
cd(out_x64);
|
||||
vid_test = sprintf('FaceLandmarkVid.exe -f samples/default.wmv');
|
||||
dos(vid_test);
|
||||
feat_test = sprintf('FeatureExtraction.exe -f samples/default.wmv -verbose');
|
||||
dos(feat_test);
|
||||
img_test = sprintf('FaceLandmarkImg.exe -fdir samples -verbose');
|
||||
dos(img_test);
|
||||
vid_test = sprintf('FaceLandmarkVidMulti.exe -f samples/multi_face.avi -verbose');
|
||||
dos(vid_test);
|
||||
rmdir('processed', 's');
|
||||
|
||||
%%
|
||||
cd('..');
|
||||
cd(out_x86);
|
||||
vid_test = sprintf('FaceLandmarkVid.exe -f samples/default.wmv');
|
||||
dos(vid_test);
|
||||
feat_test = sprintf('FeatureExtraction.exe -f samples/default.wmv -verbose');
|
||||
dos(feat_test);
|
||||
img_test = sprintf('FaceLandmarkImg.exe -fdir samples -verbose');
|
||||
dos(img_test);
|
||||
vid_test = sprintf('FaceLandmarkVidMulti.exe -f samples/multi_face.avi -verbose');
|
||||
dos(vid_test);
|
||||
rmdir('processed', 's');
|
||||
cd('..');
|
||||
156
pkg/OpenFace/exe/releases/package_windows_executables_no_au.m
Normal file
156
pkg/OpenFace/exe/releases/package_windows_executables_no_au.m
Normal file
@@ -0,0 +1,156 @@
|
||||
clear;
|
||||
version = '0.4.1';
|
||||
|
||||
out_x86 = sprintf('OpenFace_%s_win_x86_landmarks', version);
|
||||
out_x64 = sprintf('OpenFace_%s_win_x64_landmarks', version);
|
||||
|
||||
mkdir(out_x86);
|
||||
mkdir(out_x64);
|
||||
|
||||
in_x86 = '../../Release/';
|
||||
in_x64 = '../../x64/Release/';
|
||||
|
||||
% Copy models
|
||||
copyfile([in_x86, 'AU_predictors'], [out_x86, '/AU_predictors'])
|
||||
rmdir([ out_x86, '/AU_predictors/svm_combined'], 's');
|
||||
rmdir([ out_x86, '/AU_predictors/svr_combined'], 's');
|
||||
copyfile([in_x86, 'classifiers'], [out_x86, '/classifiers'])
|
||||
copyfile([in_x86, 'model'], [out_x86, '/model'])
|
||||
|
||||
copyfile([in_x64, 'AU_predictors'], [out_x64, '/AU_predictors'])
|
||||
rmdir([ out_x64, '/AU_predictors/svm_combined'], 's');
|
||||
rmdir([ out_x64, '/AU_predictors/svr_combined'], 's');
|
||||
copyfile([in_x64, 'classifiers'], [out_x64, '/classifiers'])
|
||||
copyfile([in_x64, 'model'], [out_x64, '/model'])
|
||||
|
||||
%% Copy libraries
|
||||
libs_x86 = dir([in_x86, '*.lib'])';
|
||||
|
||||
for lib = libs_x86
|
||||
|
||||
copyfile([in_x86, '/', lib.name], [out_x86, '/', lib.name])
|
||||
|
||||
end
|
||||
|
||||
libs_x64 = dir([in_x64, '*.lib'])';
|
||||
|
||||
for lib = libs_x64
|
||||
|
||||
copyfile([in_x64, '/', lib.name], [out_x64, '/', lib.name])
|
||||
|
||||
end
|
||||
|
||||
%% Copy dlls
|
||||
dlls_x86 = dir([in_x86, '*.dll'])';
|
||||
|
||||
for dll = dlls_x86
|
||||
|
||||
copyfile([in_x86, '/', dll.name], [out_x86, '/', dll.name])
|
||||
|
||||
end
|
||||
|
||||
dlls_x64 = dir([in_x64, '*.dll'])';
|
||||
|
||||
for dll = dlls_x64
|
||||
|
||||
copyfile([in_x64, '/', dll.name], [out_x64, '/', dll.name])
|
||||
|
||||
end
|
||||
|
||||
% Copy zmq dll's
|
||||
mkdir([out_x64, '/amd64']);
|
||||
copyfile([in_x64, '/amd64'], [out_x64, '/amd64']);
|
||||
mkdir([out_x64, '/i386']);
|
||||
copyfile([in_x64, '/i386'], [out_x64, '/i386']);
|
||||
|
||||
mkdir([out_x86, '/amd64']);
|
||||
copyfile([in_x86, '/amd64'], [out_x86, '/amd64']);
|
||||
mkdir([out_x86, '/i386']);
|
||||
copyfile([in_x86, '/i386'], [out_x86, '/i386']);
|
||||
|
||||
%% Copy exe's
|
||||
exes_x86 = dir([in_x86, '*.exe'])';
|
||||
|
||||
for exe = exes_x86
|
||||
|
||||
copyfile([in_x86, '/', exe.name], [out_x86, '/', exe.name])
|
||||
|
||||
end
|
||||
|
||||
exes_x64 = dir([in_x64, '*.exe'])';
|
||||
|
||||
for exe = exes_x64
|
||||
|
||||
copyfile([in_x64, '/', exe.name], [out_x64, '/', exe.name])
|
||||
|
||||
end
|
||||
|
||||
%% Copy license and copyright
|
||||
copyfile('../../Copyright.txt', [out_x86, '/Copyright.txt']);
|
||||
copyfile('../../OpenFace-license.txt', [out_x86, '/OpenFace-license.txt']);
|
||||
|
||||
copyfile('../../Copyright.txt', [out_x64, '/Copyright.txt']);
|
||||
copyfile('../../OpenFace-license.txt', [out_x64, '/OpenFace-license.txt']);
|
||||
|
||||
%% Copy icons etc. needed for GUI
|
||||
img_x86 = dir([in_x86, '*.ico'])';
|
||||
|
||||
for img = img_x86
|
||||
|
||||
copyfile([in_x86, '/', img.name], [out_x86, '/', img.name])
|
||||
|
||||
end
|
||||
|
||||
img_x64 = dir([in_x64, '*.ico'])';
|
||||
|
||||
for img = img_x64
|
||||
|
||||
copyfile([in_x64, '/', img.name], [out_x64, '/', img.name])
|
||||
|
||||
end
|
||||
|
||||
img_x86 = dir([in_x86, '*.png'])';
|
||||
|
||||
for img = img_x86
|
||||
|
||||
copyfile([in_x86, '/', img.name], [out_x86, '/', img.name])
|
||||
|
||||
end
|
||||
|
||||
img_x64 = dir([in_x86, '*.png'])';
|
||||
|
||||
for img = img_x64
|
||||
|
||||
copyfile([in_x64, '/', img.name], [out_x64, '/', img.name])
|
||||
|
||||
end
|
||||
|
||||
%% Copy sample images for testing
|
||||
copyfile('../../samples', [out_x86, '/samples']);
|
||||
copyfile('../../samples', [out_x64 '/samples']);
|
||||
|
||||
%% Test if everything worked by running examples
|
||||
cd(out_x64);
|
||||
vid_test = sprintf('FaceLandmarkVid.exe -f samples/default.wmv');
|
||||
dos(vid_test);
|
||||
feat_test = sprintf('FeatureExtraction.exe -f samples/default.wmv -verbose');
|
||||
dos(feat_test);
|
||||
img_test = sprintf('FaceLandmarkImg.exe -fdir samples -verbose');
|
||||
dos(img_test);
|
||||
vid_test = sprintf('FaceLandmarkVidMulti.exe -f samples/multi_face.avi -verbose');
|
||||
dos(vid_test);
|
||||
rmdir('processed', 's');
|
||||
|
||||
%%
|
||||
cd('..');
|
||||
cd(out_x86);
|
||||
vid_test = sprintf('FaceLandmarkVid.exe -f samples/default.wmv');
|
||||
dos(vid_test);
|
||||
feat_test = sprintf('FeatureExtraction.exe -f samples/default.wmv -verbose');
|
||||
dos(feat_test);
|
||||
img_test = sprintf('FaceLandmarkImg.exe -fdir samples -verbose');
|
||||
dos(img_test);
|
||||
vid_test = sprintf('FaceLandmarkVidMulti.exe -f samples/multi_face.avi -verbose');
|
||||
dos(vid_test);
|
||||
rmdir('processed', 's');
|
||||
cd('..');
|
||||
1
pkg/OpenFace/exe/releases/readme.txt
Normal file
1
pkg/OpenFace/exe/releases/readme.txt
Normal file
@@ -0,0 +1 @@
|
||||
Please run the download_models.ps1 script or visit https://github.com/TadasBaltrusaitis/OpenFace/wiki/Model-download for information of how to get the models required to run the executables.
|
||||
Reference in New Issue
Block a user