Skip to content

Commit

Permalink
Merge branch 'cpp14-optional'
Browse files Browse the repository at this point in the history
  • Loading branch information
patrikhuber committed Mar 12, 2018
2 parents b29487e + b1d23f3 commit 7a917cc
Show file tree
Hide file tree
Showing 23 changed files with 1,311 additions and 80 deletions.
53 changes: 35 additions & 18 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,28 +1,45 @@
sudo: required
dist: trusty
dist: trusty # Use 'trusty' unless specified otherwise
os: linux # Use Linux unless specified otherwise
sudo: false

language: cpp

env:
- C_COMPILER=gcc-7 CXX_COMPILER=g++-7
- C_COMPILER=clang-5.0 CXX_COMPILER=clang++-5.0
matrix:
include:
- env: C_COMPILER=gcc-7 CXX_COMPILER=g++-7 GENERATOR_NAME="Unix Makefiles"
addons: { apt: { packages: ["g++-7"], sources: ["ubuntu-toolchain-r-test"] } }

before_install:
- pyenv global system 3.6 # Workaround for travis-ci/issues/8363
- sudo add-apt-repository ppa:ubuntu-toolchain-r/test -y
- wget -O - http://llvm.org/apt/llvm-snapshot.gpg.key | sudo apt-key add -
- echo "deb http://llvm.org/apt/trusty/ llvm-toolchain-trusty-5.0 main" | sudo tee -a /etc/apt/sources.list
- sudo apt-get update -q
- sudo apt-get install gcc-7 g++-7 -y
- sudo apt-get install clang-5.0 -y
- sudo apt-get install libboost-all-dev libopencv-dev -y
- wget https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.tar.gz
- tar -xvzf cmake-3.8.2-Linux-x86_64.tar.gz
- env: C_COMPILER=clang-5.0 CXX_COMPILER=clang++-5.0 GENERATOR_NAME="Unix Makefiles"
addons: { apt: { packages: ["g++-7", "clang-5.0"], sources: ["llvm-toolchain-trusty-5.0", "ubuntu-toolchain-r-test"] } }
# g++-7 is needed here - otherwise the build will fail because g++-4.8 libstdc++ is used.

- os: osx
env: C_COMPILER=clang CXX_COMPILER=clang++ GENERATOR_NAME="Xcode"
osx_image: xcode9.2

install:
- |
if [[ "${TRAVIS_OS_NAME}" == "linux" ]]; then
wget https://cmake.org/files/v3.8/cmake-3.8.2-Linux-x86_64.tar.gz
CMAKE_DIR=${TRAVIS_BUILD_DIR}/cmake && mkdir ${CMAKE_DIR}
tar -xvzf cmake-3.8.2-Linux-x86_64.tar.gz --strip-components=1 -C ${CMAKE_DIR} # extract from inside the top-level directory to CMAKE_DIR
export PATH=${CMAKE_DIR}/bin:${PATH}
pyenv global system 3.6 # Workaround for travis-ci/issues/8363
sudo apt-get update -q
sudo apt-get install libboost-all-dev libopencv-dev -y
else
brew install cmake || brew upgrade cmake
brew install boost
/usr/bin/yes | pip2 uninstall numpy # see: travis-ci/issues/6688
brew install opencv
fi
- cmake --version

before_script:
- mkdir build
- cd build
- ../cmake-3.8.2-Linux-x86_64/bin/cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} -DEOS_BUILD_EXAMPLES=on -DEOS_BUILD_UTILS=on -DEOS_GENERATE_PYTHON_BINDINGS=on -DPYTHON_EXECUTABLE=`which python3.6` ..
- cmake -G "${GENERATOR_NAME}" -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${CXX_COMPILER} -DCMAKE_INSTALL_PREFIX=../install -DEOS_BUILD_EXAMPLES=on -DEOS_BUILD_UTILS=on -DEOS_GENERATE_PYTHON_BINDINGS=on -DPYTHON_EXECUTABLE=`which python3.6` ..

script:
- make VERBOSE=1
- cmake --build . --config Release
- cmake --build . --target install --config Release
2 changes: 1 addition & 1 deletion 3rdparty/cereal
Submodule cereal updated 39 files
+4 −2 .gitignore
+159 −17 .travis.yml
+11 −9 CMakeLists.txt
+6 −6 include/cereal/archives/binary.hpp
+40 −0 include/cereal/archives/json.hpp
+13 −13 include/cereal/archives/portable_binary.hpp
+75 −16 include/cereal/archives/xml.hpp
+60 −9 include/cereal/cereal.hpp
+36 −2 include/cereal/details/helpers.hpp
+61 −29 include/cereal/details/polymorphic_impl.hpp
+3 −2 include/cereal/details/static_object.hpp
+19 −6 include/cereal/details/traits.hpp
+8 −1 include/cereal/external/base64.hpp
+7 −0 include/cereal/external/rapidjson/internal/regex.h
+44 −44 include/cereal/external/rapidxml/rapidxml.hpp
+2 −0 include/cereal/external/rapidxml/rapidxml_print.hpp
+11 −0 include/cereal/macros.hpp
+55 −0 include/cereal/types/atomic.hpp
+20 −18 include/cereal/types/memory.hpp
+66 −0 include/cereal/types/optional.hpp
+13 −11 include/cereal/types/polymorphic.hpp
+4 −4 include/cereal/types/tuple.hpp
+104 −0 include/cereal/types/variant.hpp
+6 −6 include/cereal/types/vector.hpp
+4 −0 unittests/CMakeLists.txt
+52 −0 unittests/atomic.cpp
+170 −0 unittests/atomic.hpp
+20 −0 unittests/common.hpp
+38 −0 unittests/cpp17/CMakeLists.txt
+57 −0 unittests/cpp17/optional.cpp
+92 −0 unittests/cpp17/optional.hpp
+97 −0 unittests/cpp17/variant.cpp
+97 −0 unittests/cpp17/variant.hpp
+52 −0 unittests/defer.cpp
+193 −0 unittests/defer.hpp
+43 −0 unittests/load_construct.hpp
+36 −4 unittests/memory.hpp
+277 −2 unittests/polymorphic.hpp
+1 −1 unittests/portable_binary_archive.hpp
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,9 @@ set(HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/render/detail/Vertex.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/video/Keyframe.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/video/keyframe_merging.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/cpp17/optional.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/cpp17/detail/akrzemi1_optional.hpp
${CMAKE_CURRENT_SOURCE_DIR}/include/eos/cpp17/detail/akrzemi1_optional_serialization.hpp
)

add_library(eos INTERFACE)
Expand All @@ -137,6 +140,8 @@ source_group(fitting\\detail REGULAR_EXPRESSION include/eos/fitting/detail/*)
source_group(render REGULAR_EXPRESSION include/eos/render/*)
source_group(render\\detail REGULAR_EXPRESSION include/eos/render/detail/*)
source_group(video REGULAR_EXPRESSION include/eos/video/*)
source_group(cpp17 REGULAR_EXPRESSION include/eos/cpp17/*)
source_group(cpp17\\detail REGULAR_EXPRESSION include/eos/cpp17/detail/*)

# The eos install target:
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include/ DESTINATION include) # our library headers
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# eos: A lightweight header-only 3D Morphable Face Model fitting library in modern C++11/14.
[![Latest release](http://img.shields.io/github/release/patrikhuber/eos.svg?style=flat-square)][release]
[![Linux build status of master branch](https://img.shields.io/travis/patrikhuber/eos/master.svg?style=flat-square&label=Linux%3A%20build)][travis]
[![Linux build status of master branch](https://img.shields.io/travis/patrikhuber/eos/master.svg?style=flat-square&label=Linux/macOS%3A%20build)][travis]
[![Windows build status of master branch](https://ci.appveyor.com/api/projects/status/gekekpn08cdgqcsk/branch/master?svg=true&passingText=Windows%3A%20build%20passing&failingText=Windows%3A%20build%20failing&pendingText=Windows%3A%20build%20pending)][appveyor]
[![Apache License 2.0](https://img.shields.io/badge/license-Apache%20License%202.0-blue.svg?style=flat-square)][license]

Expand Down Expand Up @@ -28,7 +28,7 @@ An experimental model viewer to visualise 3D Morphable Models and blendshapes is

## Usage

* Tested with the following compilers: >=gcc-7, >=clang-5, Visual Studio 2017 Update 3.
* Tested with the following compilers: >=gcc-7, >=clang-5, >=Visual Studio 2017 15.5, >=Xcode 9.2.
* The library and python bindings are free of any external dependencies. The example applications require Boost (>=1.50.0) and OpenCV (>=2.4.3).

To use the library in your own project, just add the following directories to your include path:
Expand Down
5 changes: 5 additions & 0 deletions doc/namespaces.doxygen
Original file line number Diff line number Diff line change
Expand Up @@ -32,3 +32,8 @@
* @namespace eos::video
* @brief Video keyframe extraction and fusion.
*/

/**
* @namespace eos::cpp17
* @brief Replacement type for std::optional for compilers who don't have it (Apple at the moment).
*/
4 changes: 2 additions & 2 deletions examples/fit-model-multi.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
#include "eos/render/texture_extraction.hpp"
#include "eos/render/render.hpp"
#include "eos/render/draw_utils.hpp"
#include "eos/cpp17/optional.hpp"

#include "opencv2/core/core.hpp"
#include "opencv2/highgui/highgui.hpp"
Expand All @@ -40,7 +41,6 @@
#include <vector>
#include <iostream>
#include <fstream>
#include <optional>

using namespace eos;
namespace po = boost::program_options;
Expand Down Expand Up @@ -248,7 +248,7 @@ int main(int argc, char *argv[])

std::tie(per_frame_meshes, per_frame_rendering_params) = fitting::fit_shape_and_pose(
morphable_model, blendshapes, per_frame_landmarks, landmark_mapper, image_widths, image_heights, edge_topology,
ibug_contour, model_contour, 5, std::nullopt, 30.0f, std::nullopt, pca_shape_coefficients,
ibug_contour, model_contour, 5, cpp17::nullopt, 30.0f, cpp17::nullopt, pca_shape_coefficients,
blendshape_coefficients, fitted_image_points);

cout << "Final pca shape coefficients: ";
Expand Down
4 changes: 2 additions & 2 deletions examples/fit-model.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#include "eos/morphablemodel/MorphableModel.hpp"
#include "eos/render/draw_utils.hpp"
#include "eos/render/texture_extraction.hpp"
#include "eos/cpp17/optional.hpp"

#include "Eigen/Core"

Expand All @@ -38,7 +39,6 @@
#include "opencv2/imgproc/imgproc.hpp"

#include <iostream>
#include <optional>
#include <string>
#include <vector>

Expand Down Expand Up @@ -160,7 +160,7 @@ int main(int argc, char* argv[])
fitting::RenderingParameters rendering_params;
std::tie(mesh, rendering_params) = fitting::fit_shape_and_pose(
morphable_model, blendshapes, landmarks, landmark_mapper, image.cols, image.rows, edge_topology,
ibug_contour, model_contour, 5, std::nullopt, 30.0f);
ibug_contour, model_contour, 5, cpp17::nullopt, 30.0f);

// The 3D head pose can be recovered as follows:
float yaw_angle = glm::degrees(glm::yaw(rendering_params.get_rotation()));
Expand Down
3 changes: 2 additions & 1 deletion examples/generate-obj.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include "eos/core/Image_opencv_interop.hpp"
#include "eos/morphablemodel/MorphableModel.hpp"
#include "eos/render/render.hpp"
#include "eos/cpp17/optional.hpp"

#include "glm/gtc/matrix_transform.hpp"

Expand Down Expand Up @@ -107,7 +108,7 @@ int main(int argc, char* argv[])
core::Image4u rendering;
std::tie(rendering, std::ignore) =
render::render(sample_mesh, glm::mat4x4(1.0f), glm::ortho(-130.0f, 130.0f, -130.0f, 130.0f), 512, 512,
std::nullopt, true, false, false);
cpp17::nullopt, true, false, false);
fs::path filename_rendering(output_file);
filename_rendering.replace_extension(".png");
cv::imwrite(filename_rendering.string(), core::to_mat(rendering));
Expand Down
7 changes: 4 additions & 3 deletions include/eos/core/LandmarkMapper.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@
#ifndef LANDMARKMAPPER_HPP_
#define LANDMARKMAPPER_HPP_

#include "eos/cpp17/optional.hpp"

#include "toml.hpp"

#include <optional>
#include <stdexcept>
#include <string>
#include <unordered_map>
Expand Down Expand Up @@ -102,7 +103,7 @@ class LandmarkMapper
* @param[in] landmark_name A landmark name to convert.
* @return The mapped landmark name if a mapping exists, an empty optional otherwise.
*/
std::optional<std::string> convert(std::string landmark_name) const
cpp17::optional<std::string> convert(std::string landmark_name) const
{
if (landmark_mappings.empty())
{
Expand All @@ -117,7 +118,7 @@ class LandmarkMapper
return converted_landmark->second;
} else
{ // landmark_name does not match the key of any element in the map
return std::nullopt;
return cpp17::nullopt;
}
};

Expand Down
6 changes: 3 additions & 3 deletions include/eos/core/read_obj.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@
#define READ_OBJ_HPP_

#include "eos/core/Mesh.hpp"
#include "eos/cpp17/optional.hpp"

#include "Eigen/Core"

#include <cassert>
#include <fstream>
#include <optional>
#include <string>
#include <tuple>
#include <utility>
Expand Down Expand Up @@ -103,13 +103,13 @@ void tokenize(const std::string& str, ContainerType& tokens, const std::string&
* Todo: Consider using std::string_view for these instead of const string&.
* And should change to glm::vec3, and just divide by 'w'. As soon as we change the Mesh to vec3.
*/
inline std::pair<Eigen::Vector4f, std::optional<Eigen::Vector3f>> parse_vertex(const std::string& line)
inline std::pair<Eigen::Vector4f, cpp17::optional<Eigen::Vector3f>> parse_vertex(const std::string& line)
{
std::vector<std::string> tokens;
tokenize(line, tokens, " ");
assert(tokens.size() == 3 || tokens.size() == 6); // Maybe we should throw instead?
const Eigen::Vector4f vertex(std::stof(tokens[0]), std::stof(tokens[1]), std::stof(tokens[2]), 1.0);
std::optional<Eigen::Vector3f> vertex_color;
cpp17::optional<Eigen::Vector3f> vertex_color;
if (tokens.size() == 6)
{
vertex_color = Eigen::Vector3f(std::stof(tokens[3]), std::stof(tokens[4]), std::stof(tokens[5]));
Expand Down
Loading

0 comments on commit 7a917cc

Please sign in to comment.