Skip to content

Commit 25d33f0

Browse files
committed
Merge branch 'devel'
2 parents 85c325a + b2f24a1 commit 25d33f0

File tree

6 files changed

+40
-13
lines changed

6 files changed

+40
-13
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
# Ignore files generated by Visual Studio's CMake:
2+
.vs/
3+
out/build/
4+
15
# Ignore (optional) configuration files with user-specific paths:
26
initial_cache.cmake
37
setup.cfg

.gitmodules

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,4 @@
2121
url = https://github.com/ToruNiina/toml11.git
2222
[submodule "3rdparty/eigen"]
2323
path = 3rdparty/eigen
24-
url = https://github.com/eigenteam/eigen-git-mirror.git
24+
url = https://gitlab.com/libeigen/eigen.git

3rdparty/eigen

Submodule eigen updated from dde02fc to 3147391

3rdparty/pybind11

Submodule pybind11 updated 223 files

examples/fit-model-ceres.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "eos/core/Landmark.hpp"
2222
#include "eos/core/LandmarkMapper.hpp"
2323
#include "eos/core/read_pts_landmarks.hpp"
24+
#include "eos/core/write_obj.hpp"
2425
#include "eos/fitting/ceres_nonlinear.hpp"
2526
#include "eos/fitting/contour_correspondence.hpp"
2627
#include "eos/fitting/fitting.hpp"

python/generate-python-bindings.cpp

Lines changed: 32 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* File: python/generate-python-bindings.cpp
55
*
6-
* Copyright 2016-2019 Patrik Huber
6+
* Copyright 2016-2022 Patrik Huber
77
*
88
* Licensed under the Apache License, Version 2.0 (the "License");
99
* you may not use this file except in compliance with the License.
@@ -85,8 +85,8 @@ PYBIND11_MODULE(eos, eos_module)
8585
.def_readwrite("coordinates", &core::Landmark<Eigen::Vector2f>::coordinates,
8686
"The position or coordinates of the landmark")
8787
.def("__repr__", [](const core::Landmark<Eigen::Vector2f>& l) {
88-
return "<eos.core.Landmark [name=" + l.name + ", [x=" + std::to_string(l.coordinates(0)) +
89-
", y=" + std::to_string(l.coordinates(1)) + "]]>";
88+
return "<eos.core.Landmark(name=\"" + l.name + "\", coordinates=[" + std::to_string(l.coordinates(0)) +
89+
", " + std::to_string(l.coordinates(1)) + "])>";
9090
});
9191

9292
py::class_<core::LandmarkMapper>(core_module, "LandmarkMapper", "Represents a mapping from one kind of landmarks to a different format(e.g.model vertices).")
@@ -95,17 +95,39 @@ PYBIND11_MODULE(eos, eos_module)
9595
.def("convert", &core::LandmarkMapper::convert, "Converts the given landmark name to the mapped name.", py::arg("landmark_name"))
9696
.def("get_mappings", &core::LandmarkMapper::get_mappings, "Returns the mappings held by this mapper.")
9797
.def("__repr__", [](const core::LandmarkMapper& m) {
98-
return "<eos.core.LandmarkMapper with " + std::to_string(m.num_mappings()) + " mappings.>";
98+
return "<eos.core.LandmarkMapper with " + std::to_string(m.num_mappings()) + " mappings>";
9999
});
100100

101-
py::class_<core::Mesh>(core_module, "Mesh", "This class represents a 3D mesh consisting of vertices, vertex colour information and texture coordinates.")
101+
py::class_<core::Mesh>(core_module, "Mesh",
102+
"This class represents a 3D mesh consisting of vertices, vertex colour "
103+
"information and texture coordinates.")
102104
.def(py::init<>(), "Creates an empty mesh.")
105+
.def(py::init([](std::vector<Eigen::Vector3f> vertices, std::vector<std::array<int, 3>> tvi,
106+
std::vector<Eigen::Vector3f> colors, std::vector<std::array<int, 3>> tci,
107+
std::vector<Eigen::Vector2f> texcoords, std::vector<std::array<int, 3>> tti) {
108+
return core::Mesh{vertices, colors, texcoords, tvi, tci, tti};
109+
}),
110+
"Creates a mesh from the given vertices and faces (tvi). Supports optional kwargs for "
111+
"per-vertex colours and/or texture coordinates.",
112+
py::arg("vertices"), py::arg("tvi"), py::kw_only(),
113+
py::arg("colors") = std::vector<Eigen::Vector3f>(),
114+
py::arg("tci") = std::vector<std::array<int, 3>>(),
115+
py::arg("texcoords") = std::vector<Eigen::Vector2f>(),
116+
py::arg("tti") = std::vector<std::array<int, 3>>())
103117
.def_readwrite("vertices", &core::Mesh::vertices, "3D vertex positions")
104-
.def_readwrite("colors", &core::Mesh::colors, "Colour information for each vertex. Expected to be in RGB order.")
118+
.def_readwrite("colors", &core::Mesh::colors,
119+
"Colour information for each vertex. Expected to be in RGB order.")
105120
.def_readwrite("texcoords", &core::Mesh::texcoords, "Texture coordinates")
106121
.def_readwrite("tvi", &core::Mesh::tvi, "Triangle vertex indices")
107122
.def_readwrite("tci", &core::Mesh::tci, "Triangle colour indices (usually the same as tvi)")
108-
.def_readwrite("tti", &core::Mesh::tti, "Triangle texture indices");
123+
.def_readwrite("tti", &core::Mesh::tti, "Triangle texture indices")
124+
.def("__repr__", [](const core::Mesh& m) {
125+
return "<eos.core.Mesh with " + std::to_string(m.vertices.size()) + " vertices, " +
126+
std::to_string(m.tvi.size()) + " tvi, " + std::to_string(m.colors.size()) +
127+
" colour values, " + std::to_string(m.tci.size()) + " tci, " +
128+
std::to_string(m.texcoords.size()) + " texcoords, " + std::to_string(m.tti.size()) +
129+
" tti>";
130+
});
109131

110132
core_module.def("write_obj", &core::write_obj, "Writes the given Mesh to an obj file.", py::arg("mesh"), py::arg("filename"));
111133
core_module.def("write_textured_obj", &core::write_textured_obj, "Writes the given Mesh to an obj file, including texture coordinates, and an mtl file containing a reference to the texture map in the form of <filename>.texture.png. That texture .png file has to be saved separately.", py::arg("mesh"), py::arg("filename"));
@@ -122,8 +144,8 @@ PYBIND11_MODULE(eos, eos_module)
122144
.def_readwrite("width", &core::Rect<int>::width, "Width of the rectangle")
123145
.def_readwrite("height", &core::Rect<int>::height, "Height of the rectangle")
124146
.def("__repr__", [](const core::Rect<int>& r) {
125-
return "<eos.core.Rect [x=" + std::to_string(r.x) + ", y=" + std::to_string(r.y) +
126-
", width=" + std::to_string(r.width) + ", height=" + std::to_string(r.height) + "]>";
147+
return "<eos.core.Rect(x=" + std::to_string(r.x) + ", y=" + std::to_string(r.y) +
148+
", width=" + std::to_string(r.width) + ", height=" + std::to_string(r.height) + ")>";
127149
});
128150

129151
/**
@@ -170,7 +192,7 @@ PYBIND11_MODULE(eos, eos_module)
170192
py::enum_<morphablemodel::MorphableModel::ExpressionModelType>(
171193
morphable_model, "ExpressionModelType",
172194
"The type of the expression model that a MorphableModel contains.")
173-
.value("None", morphablemodel::MorphableModel::ExpressionModelType::None)
195+
.value("none", morphablemodel::MorphableModel::ExpressionModelType::None)
174196
.value("Blendshapes", morphablemodel::MorphableModel::ExpressionModelType::Blendshapes)
175197
.value("PcaModel", morphablemodel::MorphableModel::ExpressionModelType::PcaModel);
176198

0 commit comments

Comments
 (0)