Commit 6d5f252b authored by Patrik Huber's avatar Patrik Huber

Merge branch 'python-bindings' into devel

parents 66a712dd cb6dd354
[submodule "3rdparty/pybind11"]
path = 3rdparty/pybind11
url = https://github.com/pybind/pybind11.git
Subproject commit 29b5064e9c80be7034fc9d6ac15dbb7ebe304fc5
project(eos)
cmake_minimum_required(VERSION 2.8.10)
cmake_minimum_required(VERSION 2.8.12)
set(eos_VERSION_MAJOR 0)
set(eos_VERSION_MINOR 7)
set(eos_VERSION_PATCH 1)
......@@ -60,6 +60,8 @@ option(BUILD_UTILS "Build utility applications." OFF)
message(STATUS "BUILD_UTILS: ${BUILD_UTILS}")
option(BUILD_DOCUMENTATION "Build the library documentation." OFF)
message(STATUS "BUILD_DOCUMENTATION: ${BUILD_DOCUMENTATION}")
option(GENERATE_PYTHON_BINDINGS "Build python bindings. Needs BUILD_UTILS enabled too." OFF)
message(STATUS "GENERATE_PYTHON_BINDINGS: ${GENERATE_PYTHON_BINDINGS}")
# Build a CPack driven installer package:
include(InstallRequiredSystemLibraries) # This module will include any runtime libraries that are needed by the project for the current platform
......@@ -145,6 +147,13 @@ source_group(fitting\\detail include/eos/fitting/detail/*)
source_group(render include/eos/render/*)
source_group(render\\detail include/eos/render/detail/*)
# Generate python bindings using pybind11:
if(GENERATE_PYTHON_BINDINGS)
set(PYBIND11_PATH "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/pybind11")
add_subdirectory(${PYBIND11_PATH})
# If this fails, the repo has probably not been cloned with submodules. Run: git submodule update --init
endif()
# The install target:
install(DIRECTORY ${CMAKE_SOURCE_DIR}/include/ DESTINATION include) # our library headers
install(DIRECTORY ${CMAKE_SOURCE_DIR}/share/ DESTINATION share) # the model and metadata
......
......@@ -26,3 +26,4 @@ set(BUILD_EXAMPLES ON CACHE BOOL "Build the example applications." FORCE)
set(BUILD_CERES_EXAMPLE OFF CACHE BOOL "Build the fit-model-ceres example (requires Ceres)." FORCE)
set(BUILD_UTILS OFF CACHE BOOL "Build utility applications." FORCE)
set(BUILD_DOCUMENTATION OFF CACHE BOOL "Build the library documentation." FORCE)
set(GENERATE_PYTHON_BINDINGS OFF CACHE BOOL "Build python bindings. Needs BUILD_UTILS enabled too." FORCE)
project(utils)
cmake_minimum_required(VERSION 2.8.10)
cmake_minimum_required(VERSION 2.8.12)
# The utils need a few additional dependencies (e.g. boost filesystem and OpenCV highgui):
......@@ -41,6 +41,13 @@ target_link_libraries(scm-to-cereal ${OpenCV_LIBS} ${Boost_LIBRARIES})
# Store a json file as cereal .bin:
add_executable(json-to-cereal-binary json-to-cereal-binary.cpp)
target_link_libraries(json-to-cereal-binary ${OpenCV_LIBS} ${Boost_LIBRARIES})
# Generate python bindings using pybind11:
if(GENERATE_PYTHON_BINDINGS)
pybind11_add_module(eos_py create-python-bindings.cpp)
target_link_libraries(eos_py PRIVATE ${OpenCV_LIBS} ${Boost_LIBRARIES})
install(TARGETS eos_py DESTINATION bin)
endif()
# install target:
install(TARGETS scm-to-cereal DESTINATION bin)
install(TARGETS json-to-cereal-binary DESTINATION bin)
/*
* eos - A 3D Morphable Model fitting library written in modern C++11/14.
*
* File: utils/create-python-bindings.cpp
*
* Copyright 2016 Patrik Huber
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#include "eos/morphablemodel/PcaModel.hpp"
#include "pybind11/pybind11.h"
namespace py = pybind11;
/**
* Create python bindings for the eos library using pybind11.
*/
PYBIND11_PLUGIN(eos_py) {
py::module m("eos_py", "Python bindings to the 3D Morphable Face Model fitting library");
py::class_<eos::morphablemodel::PcaModel>(m, "PcaModel")
.def(py::init<>())
.def("get_mean_at_point", &eos::morphablemodel::PcaModel::get_mean_at_point);
return m.ptr();
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment