mirror of
https://gitcode.com/gh_mirrors/ope/OpenFace.git
synced 2026-05-16 20:28:00 +00:00
Feature/opencv4 (#706)
* Travis OpenCV4 update, testing Ubuntu with new OpenCV * Fix to Ubuntu travis * Another attempt at OpenCV 4.0 for Ubuntu * And another OpenCV attempt. * Simplifying the travis script * Ubuntu OpenCV 4 support. * Updating to OpenCV 4, for x64 windows. * Fixes to move to OpenCV 4 on windows. * Travis fix for OpenCV 4 on OSX * Renaming a lib. * Travis opencv4 fix. * Building OpenCV4 versions using appveyor. * Attempt mac travis fix. * Small travis fix. * Travis fix attempt. * First iteration in boost removal and upgrade to C++17 * Test with ocv 4.0 * Moving filesystem out of stdafx * Some more boost testing with cmake. * More CMAKE options * More compiler flag changes * Another attempt at compiler options. * Another attempt. * More filesystem stuff. * Linking to filesystem. * Cmake fix with target linking. * Attempting travis with g++-8 * Attempting to setup g++8 on travis linux. * Another travis change. * Adding OpenBLAS to travis and removing g++-8 * Fixing typo * More travis experiments. * More travis debugging. * A small directory change. * Adding some more travis changes. * travis typo fix. * Some reordering of travis, for cleaner yml * Removing `using namespace std` in order to avoid clash with byte and to make the code more consistent. * Working towards removing std::filesystem requirement, allow boost::filesystem as well. * Making boost an optional dependency * Fixing std issue. * Fixing cmake issue. * Fixing the precompiled header issue. * Another cmake boost fix. * Including missing files. * Removing unnecessary includes. * Removing more includes. * Changes to appveyor build, proper removal of VS2015 * If boost is present, do not need to link to filesystem. * Removing un-needed link library. * oops * Mac attempt at opencv4 travis. * Upgrading OCV to 4.1 on VS2018 * Downloading OpenCV binaries through a script * Triger an appveyor build. * Upgrading VS version. * Attempting VS2017 build * Adding win-32 libraries for OpenCV 4.1 * Adding OpenCV 32 bit libraries.
This commit is contained in:
committed by
GitHub
parent
330383fef7
commit
9147dfe2f3
@@ -5,6 +5,7 @@ SET(SOURCE
|
||||
src/RecorderOpenFace.cpp
|
||||
src/RecorderOpenFaceParameters.cpp
|
||||
src/SequenceCapture.cpp
|
||||
src/stdafx_ut.cpp
|
||||
src/VisualizationUtils.cpp
|
||||
src/Visualizer.cpp
|
||||
)
|
||||
@@ -16,6 +17,7 @@ SET(HEADERS
|
||||
include/RecorderOpenFace.h
|
||||
include/RecorderOpenFaceParameters.h
|
||||
include/SequenceCapture.h
|
||||
include/stdafx_ut.h
|
||||
include/VisualizationUtils.h
|
||||
include/Visualizer.h
|
||||
)
|
||||
@@ -28,12 +30,17 @@ target_include_directories(Utilities PUBLIC
|
||||
$<INSTALL_INTERFACE:$<INSTALL_PREFIX>/include/OpenFace>)
|
||||
|
||||
target_include_directories(Utilities PRIVATE ${UTILITIES_SOURCE_DIR}/include)
|
||||
target_include_directories(Utilities PUBLIC ${Boost_INCLUDE_DIRS})
|
||||
target_include_directories(Utilities PUBLIC ${Boost_INCLUDE_DIRS}/boost)
|
||||
target_include_directories(Utilities PUBLIC ${OpenCV_INCLUDE_DIRS})
|
||||
|
||||
target_link_libraries(Utilities PUBLIC ${OpenCV_LIBS} ${Boost_LIBRARIES})
|
||||
target_link_libraries(Utilities PUBLIC ${OpenCV_LIBS})
|
||||
target_link_libraries(Utilities PUBLIC dlib::dlib)
|
||||
|
||||
if(${Boost_FOUND})
|
||||
target_include_directories(Utilities PUBLIC ${Boost_INCLUDE_DIRS})
|
||||
target_link_libraries(Utilities PUBLIC ${Boost_LIBRARIES})
|
||||
else()
|
||||
target_link_libraries(Utilities PUBLIC stdc++fs)
|
||||
endif()
|
||||
|
||||
install (TARGETS Utilities EXPORT OpenFaceTargets LIBRARY DESTINATION lib ARCHIVE DESTINATION lib)
|
||||
install (FILES ${HEADERS} DESTINATION include/OpenFace)
|
||||
@@ -22,33 +22,33 @@
|
||||
<ProjectGuid>{8E741EA2-9386-4CF2-815E-6F9B08991EAC}</ProjectGuid>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
<RootNamespace>Utilities</RootNamespace>
|
||||
<WindowsTargetPlatformVersion>8.1</WindowsTargetPlatformVersion>
|
||||
<WindowsTargetPlatformVersion>10.0.17134.0</WindowsTargetPlatformVersion>
|
||||
<ProjectName>Utilities</ProjectName>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>true</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<UseDebugLibraries>false</UseDebugLibraries>
|
||||
<PlatformToolset>v140</PlatformToolset>
|
||||
<PlatformToolset>v141</PlatformToolset>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
@@ -59,30 +59,26 @@
|
||||
</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="..\..\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
<Import Project="..\..\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\3rdParty\OpenBLAS\OpenBLAS_x86.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="..\..\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
<Import Project="..\..\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\3rdParty\OpenBLAS\OpenBLAS_x86.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\3rdParty\boost\boost_d.props" />
|
||||
<Import Project="..\..\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
<Import Project="..\..\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\3rdParty\boost\boost.props" />
|
||||
<Import Project="..\..\3rdParty\dlib\dlib.props" />
|
||||
<Import Project="..\..\3rdParty\OpenCV3.4\openCV3.4.props" />
|
||||
<Import Project="..\..\3rdParty\OpenCV\openCV.props" />
|
||||
<Import Project="..\..\3rdParty\OpenBLAS\OpenBLAS_64.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
@@ -96,6 +92,7 @@
|
||||
<PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<AdditionalIncludeDirectories>./include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -111,6 +108,7 @@
|
||||
<AdditionalIncludeDirectories>./include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -119,8 +117,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
@@ -130,6 +127,8 @@
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<FavorSizeOrSpeed>Speed</FavorSizeOrSpeed>
|
||||
<EnableEnhancedInstructionSet>StreamingSIMDExtensions2</EnableEnhancedInstructionSet>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<PrecompiledHeaderFile>stdafx_ut.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -140,8 +139,7 @@
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<ClCompile>
|
||||
<WarningLevel>Level3</WarningLevel>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
<PrecompiledHeader>Use</PrecompiledHeader>
|
||||
<Optimization>Full</Optimization>
|
||||
<FunctionLevelLinking>
|
||||
</FunctionLevelLinking>
|
||||
@@ -152,6 +150,8 @@
|
||||
<InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
|
||||
<EnableEnhancedInstructionSet>
|
||||
</EnableEnhancedInstructionSet>
|
||||
<LanguageStandard>stdcpp17</LanguageStandard>
|
||||
<PrecompiledHeaderFile>stdafx_ut.h</PrecompiledHeaderFile>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<SubSystem>Windows</SubSystem>
|
||||
@@ -166,6 +166,10 @@
|
||||
<ClCompile Include="src\RecorderOpenFace.cpp" />
|
||||
<ClCompile Include="src\RecorderOpenFaceParameters.cpp" />
|
||||
<ClCompile Include="src\SequenceCapture.cpp" />
|
||||
<ClCompile Include="src\stdafx_ut.cpp">
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">Create</PrecompiledHeader>
|
||||
<PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|x64'">Create</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\VisualizationUtils.cpp" />
|
||||
<ClCompile Include="src\Visualizer.cpp" />
|
||||
</ItemGroup>
|
||||
@@ -179,6 +183,7 @@
|
||||
<ClInclude Include="include\RecorderOpenFaceParameters.h" />
|
||||
<ClInclude Include="include\RotationHelpers.h" />
|
||||
<ClInclude Include="include\SequenceCapture.h" />
|
||||
<ClInclude Include="include\stdafx_ut.h" />
|
||||
<ClInclude Include="include\VisualizationUtils.h" />
|
||||
<ClInclude Include="include\Visualizer.h" />
|
||||
</ItemGroup>
|
||||
|
||||
@@ -39,6 +39,9 @@
|
||||
<ClCompile Include="src\ImageCapture.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\stdafx_ut.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\RecorderCSV.h">
|
||||
@@ -74,5 +77,8 @@
|
||||
<ClInclude Include="include\ConcurrentQueue.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\stdafx_ut.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -38,12 +38,6 @@
|
||||
#include <vector>
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
// Boost includes
|
||||
#include <filesystem.hpp>
|
||||
#include <filesystem/fstream.hpp>
|
||||
|
||||
using namespace std;
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
|
||||
|
||||
@@ -33,11 +33,7 @@
|
||||
|
||||
#ifndef VISUALIZATION_UTILS_H
|
||||
#define VISUALIZATION_UTILS_H
|
||||
|
||||
#include <opencv2/core/core.hpp>
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <stdafx_ut.h>
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
|
||||
62
lib/local/Utilities/include/stdafx_ut.h
Normal file
62
lib/local/Utilities/include/stdafx_ut.h
Normal file
@@ -0,0 +1,62 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
//
|
||||
|
||||
// Precompiled headers stuff
|
||||
|
||||
#ifndef __STDAFX_UT_h_
|
||||
#define __STDAFX_UT_h_
|
||||
|
||||
// OpenCV includes
|
||||
#include <opencv2/core/core.hpp>
|
||||
#include <opencv2/highgui/highgui.hpp>
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
// For FHOG visualisation
|
||||
#include <dlib/opencv.h>
|
||||
#include <dlib/image_processing/frontal_face_detector.h>
|
||||
|
||||
// C++ standard stuff
|
||||
#include <stdio.h>
|
||||
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
#include <locale>
|
||||
#include <iomanip>
|
||||
|
||||
#include <vector>
|
||||
#include <queue>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
// For sorting
|
||||
#include <algorithm>
|
||||
|
||||
// For threading and timing
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
|
||||
// Filesystem stuff
|
||||
// It can either be in std filesystem (C++17), or in experimental/filesystem (partial C++17 support) or in boost
|
||||
#if __has_include(<filesystem>)
|
||||
#include <filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#elif __has_include(<experimental/filesystem>)
|
||||
#include <experimental/filesystem>
|
||||
namespace fs = std::filesystem;
|
||||
#else
|
||||
#include <boost/filesystem.hpp>
|
||||
#include <boost/filesystem/fstream.hpp>
|
||||
namespace fs = boost::filesystem;
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -30,18 +30,10 @@
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx_ut.h"
|
||||
|
||||
#include "ImageCapture.h"
|
||||
#include "ImageManipulationHelpers.h"
|
||||
#include <iostream>
|
||||
|
||||
// Boost includes
|
||||
#include <filesystem.hpp>
|
||||
#include <filesystem/fstream.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
// OpenCV includes
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
@@ -69,7 +61,7 @@ bool ImageCapture::Open(std::vector<std::string>& arguments)
|
||||
std::string input_root = "";
|
||||
fx = -1; fy = -1; cx = -1; cy = -1;
|
||||
|
||||
std::string separator = std::string(1, boost::filesystem::path::preferred_separator);
|
||||
std::string separator = std::string(1, fs::path::preferred_separator);
|
||||
|
||||
// First check if there is a root argument (so that videos and input directories could be defined more easily)
|
||||
for (size_t i = 0; i < arguments.size(); ++i)
|
||||
@@ -224,16 +216,16 @@ bool ImageCapture::OpenDirectory(std::string directory, std::string bbox_directo
|
||||
|
||||
image_files.clear();
|
||||
|
||||
boost::filesystem::path image_directory(directory);
|
||||
std::vector<boost::filesystem::path> file_in_directory;
|
||||
copy(boost::filesystem::directory_iterator(image_directory), boost::filesystem::directory_iterator(), back_inserter(file_in_directory));
|
||||
fs::path image_directory(directory);
|
||||
std::vector<fs::path> file_in_directory;
|
||||
copy(fs::directory_iterator(image_directory), fs::directory_iterator(), back_inserter(file_in_directory));
|
||||
|
||||
// Sort the images in the directory first
|
||||
sort(file_in_directory.begin(), file_in_directory.end());
|
||||
|
||||
std::vector<std::string> curr_dir_files;
|
||||
|
||||
for (std::vector<boost::filesystem::path>::const_iterator file_iterator(file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator)
|
||||
for (std::vector<fs::path>::const_iterator file_iterator(file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator)
|
||||
{
|
||||
// Possible image extension .jpg and .png
|
||||
if (file_iterator->extension().string().compare(".jpg") == 0 || file_iterator->extension().string().compare(".jpeg") == 0 || file_iterator->extension().string().compare(".png") == 0 || file_iterator->extension().string().compare(".bmp") == 0)
|
||||
@@ -243,11 +235,11 @@ bool ImageCapture::OpenDirectory(std::string directory, std::string bbox_directo
|
||||
// If bounding box directory is specified, read the bounding boxes from it
|
||||
if (!bbox_directory.empty())
|
||||
{
|
||||
boost::filesystem::path current_file = *file_iterator;
|
||||
boost::filesystem::path bbox_file = bbox_directory / current_file.filename().replace_extension("txt");
|
||||
fs::path current_file = *file_iterator;
|
||||
fs::path bbox_file = bbox_directory / current_file.filename().replace_extension("txt");
|
||||
|
||||
// If there is a bounding box file push it to the list of bounding boxes
|
||||
if (boost::filesystem::exists(bbox_file))
|
||||
if (fs::exists(bbox_file))
|
||||
{
|
||||
std::ifstream in_bbox(bbox_file.string().c_str(), std::ios_base::in);
|
||||
|
||||
|
||||
@@ -30,17 +30,10 @@
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx_ut.h"
|
||||
|
||||
#include "RecorderCSV.h"
|
||||
|
||||
// For sorting
|
||||
#include <algorithm>
|
||||
|
||||
// For standard out
|
||||
#include <iostream>
|
||||
#include <iomanip>
|
||||
#include <locale>
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
// Default constructor initializes the variables
|
||||
|
||||
@@ -30,11 +30,10 @@
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx_ut.h"
|
||||
|
||||
#include "RecorderHOG.h"
|
||||
|
||||
#include <fstream>
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
// Default constructor initializes the variables
|
||||
|
||||
@@ -30,27 +30,10 @@
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx_ut.h"
|
||||
|
||||
#include "RecorderOpenFace.h"
|
||||
|
||||
// For sorting
|
||||
#include <algorithm>
|
||||
|
||||
// File manipulation
|
||||
#include <fstream>
|
||||
#include <sstream>
|
||||
#include <iostream>
|
||||
|
||||
// Boost includes for file system manipulation
|
||||
#include <filesystem.hpp>
|
||||
#include <filesystem/fstream.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
// For threading
|
||||
#include <chrono>
|
||||
|
||||
using namespace boost::filesystem;
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
#define WARN_STREAM( stream ) \
|
||||
@@ -64,16 +47,14 @@ void CreateDirectory(std::string output_path)
|
||||
output_path = output_path.substr(0, output_path.size() - 1);
|
||||
}
|
||||
|
||||
// Creating the right directory structure
|
||||
auto p = path(output_path);
|
||||
|
||||
if (!boost::filesystem::exists(p))
|
||||
// Creating the right directory structure
|
||||
if (!fs::exists(output_path))
|
||||
{
|
||||
bool success = boost::filesystem::create_directories(p);
|
||||
bool success = fs::create_directories(output_path);
|
||||
|
||||
if (!success)
|
||||
{
|
||||
std::cout << "ERROR: failed to create output directory:" << p.string() << ", do you have permission to create directory" << std::endl;
|
||||
std::cout << "ERROR: failed to create output directory:" << output_path << ", do you have permission to create directory" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
}
|
||||
@@ -141,36 +122,37 @@ void RecorderOpenFace::PrepareRecording(const std::string& in_filename)
|
||||
CreateDirectory(record_root);
|
||||
|
||||
// Create the filename for the general output file that contains all of the meta information about the recording
|
||||
path of_det_name(out_name);
|
||||
of_det_name = path(record_root) / path(out_name + "_of_details.txt");
|
||||
fs::path of_det_name(out_name);
|
||||
of_det_name = fs::path(record_root) / fs::path(out_name + "_of_details.txt");
|
||||
|
||||
// Write in the of file what we are outputing what is the input etc.
|
||||
metadata_file.open(of_det_name.string(), std::ios_base::out);
|
||||
if (!metadata_file.is_open())
|
||||
{
|
||||
cout << "ERROR: could not open the output file:" << of_det_name << ", either the path of the output directory is wrong or you do not have the permissions to write to it" << endl;
|
||||
std::cout << "ERROR: could not open the output file:" << of_det_name << ", either the path of the output directory is wrong or you do not have the permissions to write to it" << std::endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Populate relative and full path names in the meta file, unless it is a webcam
|
||||
if (!params.isFromWebcam())
|
||||
{
|
||||
string input_filename_relative = in_filename;
|
||||
string input_filename_full = in_filename;
|
||||
if (!boost::filesystem::path(input_filename_full).is_absolute())
|
||||
std::string input_filename_relative = in_filename;
|
||||
std::string input_filename_full = in_filename;
|
||||
|
||||
if (!fs::path(input_filename_full).is_absolute())
|
||||
{
|
||||
input_filename_full = boost::filesystem::canonical(input_filename_relative).string();
|
||||
input_filename_full = fs::canonical(input_filename_relative).string();
|
||||
}
|
||||
metadata_file << "Input:" << input_filename_relative << endl;
|
||||
metadata_file << "Input full path:" << input_filename_full << endl;
|
||||
metadata_file << "Input:" << input_filename_relative << std::endl;
|
||||
metadata_file << "Input full path:" << input_filename_full << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
// Populate the metadata file
|
||||
metadata_file << "Input:webcam" << endl;
|
||||
metadata_file << "Input:webcam" << std::endl;
|
||||
}
|
||||
|
||||
metadata_file << "Camera parameters:" << params.getFx() << "," << params.getFy() << "," << params.getCx() << "," << params.getCy() << endl;
|
||||
metadata_file << "Camera parameters:" << params.getFx() << "," << params.getFy() << "," << params.getCx() << "," << params.getCy() << std::endl;
|
||||
|
||||
// Create the required individual recorders, CSV, HOG, aligned, video
|
||||
csv_filename = out_name + ".csv";
|
||||
@@ -180,8 +162,8 @@ void RecorderOpenFace::PrepareRecording(const std::string& in_filename)
|
||||
{
|
||||
// Output the data based on record_root, but do not include record_root in the meta file, as it is also in that directory
|
||||
std::string hog_filename = out_name + ".hog";
|
||||
metadata_file << "Output HOG:" << hog_filename << endl;
|
||||
hog_filename = (path(record_root) / hog_filename).string();
|
||||
metadata_file << "Output HOG:" << hog_filename << std::endl;
|
||||
hog_filename = (fs::path(record_root) / hog_filename).string();
|
||||
hog_recorder.Open(hog_filename);
|
||||
}
|
||||
|
||||
@@ -192,14 +174,14 @@ void RecorderOpenFace::PrepareRecording(const std::string& in_filename)
|
||||
{
|
||||
// Output the data based on record_root, but do not include record_root in the meta file, as it is also in that directory
|
||||
this->media_filename = out_name + ".avi";
|
||||
metadata_file << "Output video:" << this->media_filename << endl;
|
||||
this->media_filename = (path(record_root) / this->media_filename).string();
|
||||
metadata_file << "Output video:" << this->media_filename << std::endl;
|
||||
this->media_filename = (fs::path(record_root) / this->media_filename).string();
|
||||
}
|
||||
else
|
||||
{
|
||||
this->media_filename = out_name + "." + params.imageFormatVisualization();
|
||||
metadata_file << "Output image:" << this->media_filename << endl;
|
||||
this->media_filename = (path(record_root) / this->media_filename).string();
|
||||
metadata_file << "Output image:" << this->media_filename << std::endl;
|
||||
this->media_filename = (fs::path(record_root) / this->media_filename).string();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -207,8 +189,8 @@ void RecorderOpenFace::PrepareRecording(const std::string& in_filename)
|
||||
if (params.outputAlignedFaces())
|
||||
{
|
||||
aligned_output_directory = out_name + "_aligned";
|
||||
metadata_file << "Output aligned directory:" << this->aligned_output_directory << endl;
|
||||
this->aligned_output_directory = (path(record_root) / this->aligned_output_directory).string();
|
||||
metadata_file << "Output aligned directory:" << this->aligned_output_directory << std::endl;
|
||||
this->aligned_output_directory = (fs::path(record_root) / this->aligned_output_directory).string();
|
||||
CreateDirectory(aligned_output_directory);
|
||||
}
|
||||
|
||||
@@ -221,13 +203,13 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, const Recorder
|
||||
{
|
||||
|
||||
// From the filename, strip out the name without directory and extension
|
||||
if (boost::filesystem::is_directory(in_filename))
|
||||
if (fs::is_directory(in_filename))
|
||||
{
|
||||
out_name = boost::filesystem::canonical(boost::filesystem::path(in_filename)).filename().string();
|
||||
out_name = fs::canonical(in_filename).filename().string();
|
||||
}
|
||||
else
|
||||
{
|
||||
out_name = boost::filesystem::path(in_filename).filename().replace_extension("").string();
|
||||
out_name = fs::path(in_filename).filename().replace_extension("").string();
|
||||
}
|
||||
|
||||
// Consuming the input arguments
|
||||
@@ -252,8 +234,8 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, const Recorder
|
||||
{
|
||||
if (!output_found && arguments[i].compare("-of") == 0)
|
||||
{
|
||||
record_root = (boost::filesystem::path(record_root) / boost::filesystem::path(arguments[i + 1])).remove_filename().string();
|
||||
out_name = path(boost::filesystem::path(arguments[i + 1])).replace_extension("").filename().string();
|
||||
record_root = (fs::path(record_root) / fs::path(arguments[i + 1])).remove_filename().string();
|
||||
out_name = fs::path(fs::path(arguments[i + 1])).replace_extension("").filename().string();
|
||||
valid[i] = false;
|
||||
valid[i + 1] = false;
|
||||
i++;
|
||||
@@ -280,13 +262,13 @@ RecorderOpenFace::RecorderOpenFace(const std::string in_filename, const Recorder
|
||||
RecorderOpenFace::RecorderOpenFace(const std::string in_filename, const RecorderOpenFaceParameters& parameters, std::string output_directory):video_writer(), params(parameters)
|
||||
{
|
||||
// From the filename, strip out the name without directory and extension
|
||||
if (boost::filesystem::is_directory(in_filename))
|
||||
if (fs::is_directory(in_filename))
|
||||
{
|
||||
out_name = boost::filesystem::canonical(boost::filesystem::path(in_filename)).filename().string();
|
||||
out_name = fs::canonical(fs::path(in_filename)).filename().string();
|
||||
}
|
||||
else
|
||||
{
|
||||
out_name = boost::filesystem::path(in_filename).filename().replace_extension("").string();
|
||||
out_name = fs::path(in_filename).filename().replace_extension("").string();
|
||||
}
|
||||
|
||||
record_root = output_directory;
|
||||
@@ -340,15 +322,15 @@ void RecorderOpenFace::WriteObservation()
|
||||
|
||||
std::sort(au_names_reg.begin(), au_names_reg.end());
|
||||
|
||||
metadata_file << "Output csv:" << csv_filename << endl;
|
||||
metadata_file << "Gaze: " << params.outputGaze() << endl;
|
||||
metadata_file << "AUs: " << params.outputAUs() << endl;
|
||||
metadata_file << "Landmarks 2D: " << params.output2DLandmarks() << endl;
|
||||
metadata_file << "Landmarks 3D: " << params.output3DLandmarks() << endl;
|
||||
metadata_file << "Pose: " << params.outputPose() << endl;
|
||||
metadata_file << "Shape parameters: " << params.outputPDMParams() << endl;
|
||||
metadata_file << "Output csv:" << csv_filename << std::endl;
|
||||
metadata_file << "Gaze: " << params.outputGaze() << std::endl;
|
||||
metadata_file << "AUs: " << params.outputAUs() << std::endl;
|
||||
metadata_file << "Landmarks 2D: " << params.output2DLandmarks() << std::endl;
|
||||
metadata_file << "Landmarks 3D: " << params.output3DLandmarks() << std::endl;
|
||||
metadata_file << "Pose: " << params.outputPose() << std::endl;
|
||||
metadata_file << "Shape parameters: " << params.outputPDMParams() << std::endl;
|
||||
|
||||
csv_filename = (path(record_root) / csv_filename).string();
|
||||
csv_filename = (fs::path(record_root) / csv_filename).string();
|
||||
csv_recorder.Open(csv_filename, params.isSequence(), params.output2DLandmarks(), params.output3DLandmarks(), params.outputPDMParams(), params.outputPose(),
|
||||
params.outputAUs(), params.outputGaze(), num_face_landmarks, num_model_modes, num_eye_landmarks, au_names_class, au_names_reg);
|
||||
}
|
||||
@@ -385,11 +367,7 @@ void RecorderOpenFace::WriteObservation()
|
||||
std::sprintf(name, "face_det_%06d.", face_id);
|
||||
|
||||
// Construct the output filename
|
||||
boost::filesystem::path slash("/");
|
||||
|
||||
std::string preferredSlash = slash.make_preferred().string();
|
||||
|
||||
string out_file = aligned_output_directory + preferredSlash + string(name) + params.imageFormatAligned();
|
||||
std::string out_file = (fs::path(aligned_output_directory) / fs::path(std::string(name) + params.imageFormatAligned())).string();
|
||||
|
||||
if(params.outputBadAligned() || landmark_detection_success)
|
||||
{
|
||||
@@ -525,8 +503,8 @@ RecorderOpenFace::~RecorderOpenFace()
|
||||
void RecorderOpenFace::Close()
|
||||
{
|
||||
// Insert terminating frames to the queues
|
||||
vis_to_out_queue.push(std::pair<string, cv::Mat>("", cv::Mat()));
|
||||
aligned_face_queue.push(std::pair<string, cv::Mat>("", cv::Mat()));
|
||||
vis_to_out_queue.push(std::pair<std::string, cv::Mat>("", cv::Mat()));
|
||||
aligned_face_queue.push(std::pair<std::string, cv::Mat>("", cv::Mat()));
|
||||
|
||||
// Make sure the recording threads complete
|
||||
if (video_writing_thread.joinable())
|
||||
|
||||
@@ -30,11 +30,10 @@
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx_ut.h"
|
||||
|
||||
#include "RecorderOpenFaceParameters.h"
|
||||
|
||||
using namespace std;
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
RecorderOpenFaceParameters::RecorderOpenFaceParameters(std::vector<std::string> &arguments, bool sequence, bool from_webcam, float fx, float fy, float cx, float cy, double fps_vid_out)
|
||||
|
||||
@@ -30,24 +30,11 @@
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx_ut.h"
|
||||
|
||||
#include "SequenceCapture.h"
|
||||
#include "ImageManipulationHelpers.h"
|
||||
|
||||
#include <iostream>
|
||||
|
||||
// Boost includes
|
||||
#include <filesystem.hpp>
|
||||
#include <filesystem/fstream.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
|
||||
// OpenCV includes
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
// For timing
|
||||
#include <chrono>
|
||||
#include <ctime>
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
#define INFO_STREAM( stream ) \
|
||||
@@ -74,7 +61,7 @@ bool SequenceCapture::Open(std::vector<std::string>& arguments)
|
||||
std::string input_root = "";
|
||||
fx = -1; fy = -1; cx = -1; cy = -1;
|
||||
|
||||
std::string separator = std::string(1, boost::filesystem::path::preferred_separator);
|
||||
std::string separator = std::string(1, fs::path::preferred_separator);
|
||||
|
||||
// First check if there is a root argument (so that videos and input directories could be defined more easily)
|
||||
for (size_t i = 0; i < arguments.size(); ++i)
|
||||
@@ -357,23 +344,23 @@ bool SequenceCapture::OpenImageSequence(std::string directory, float fx, float f
|
||||
|
||||
image_files.clear();
|
||||
|
||||
boost::filesystem::path image_directory(directory);
|
||||
fs::path image_directory(directory);
|
||||
|
||||
if (!boost::filesystem::exists(image_directory))
|
||||
if (!fs::exists(image_directory))
|
||||
{
|
||||
std::cout << "Provided directory does not exist: " << directory << std::endl;
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<boost::filesystem::path> file_in_directory;
|
||||
copy(boost::filesystem::directory_iterator(image_directory), boost::filesystem::directory_iterator(), back_inserter(file_in_directory));
|
||||
std::vector<fs::path> file_in_directory;
|
||||
copy(fs::directory_iterator(image_directory), fs::directory_iterator(), back_inserter(file_in_directory));
|
||||
|
||||
// Sort the images in the directory first
|
||||
sort(file_in_directory.begin(), file_in_directory.end());
|
||||
|
||||
std::vector<std::string> curr_dir_files;
|
||||
|
||||
for (std::vector<boost::filesystem::path>::const_iterator file_iterator(file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator)
|
||||
for (std::vector<fs::path>::const_iterator file_iterator(file_in_directory.begin()); file_iterator != file_in_directory.end(); ++file_iterator)
|
||||
{
|
||||
// Possible image extension .jpg and .png
|
||||
if (file_iterator->extension().string().compare(".jpg") == 0 || file_iterator->extension().string().compare(".jpeg") == 0 || file_iterator->extension().string().compare(".png") == 0 || file_iterator->extension().string().compare(".bmp") == 0)
|
||||
|
||||
@@ -30,17 +30,11 @@
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx_ut.h"
|
||||
|
||||
#include "VisualizationUtils.h"
|
||||
#include "RotationHelpers.h"
|
||||
|
||||
// For FHOG visualisation
|
||||
#include <dlib/opencv.h>
|
||||
#include <dlib/image_processing/frontal_face_detector.h>
|
||||
|
||||
// For drawing on images
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
namespace Utilities
|
||||
{
|
||||
|
||||
|
||||
@@ -30,20 +30,13 @@
|
||||
// IEEE International Conference on Automatic Face and Gesture Recognition, 2015
|
||||
//
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
#include "stdafx_ut.h"
|
||||
|
||||
#include "Visualizer.h"
|
||||
#include "VisualizationUtils.h"
|
||||
#include "RotationHelpers.h"
|
||||
#include "ImageManipulationHelpers.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
#include <map>
|
||||
#include <set>
|
||||
|
||||
// For drawing on images
|
||||
#include <opencv2/imgproc.hpp>
|
||||
|
||||
using namespace Utilities;
|
||||
|
||||
// For subpixel accuracy drawing
|
||||
|
||||
12
lib/local/Utilities/src/stdafx_ut.cpp
Normal file
12
lib/local/Utilities/src/stdafx_ut.cpp
Normal file
@@ -0,0 +1,12 @@
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
// 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
|
||||
//
|
||||
#include "stdafx_ut.h"
|
||||
Reference in New Issue
Block a user