eos  0.7.1
Blendshape.hpp
1 /*
2  * Eos - A 3D Morphable Model fitting library written in modern C++11/14.
3  *
4  * File: include/eos/morphablemodel/Blendshape.hpp
5  *
6  * Copyright 2015 Patrik Huber
7  *
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  *
12  * http://www.apache.org/licenses/LICENSE-2.0
13  *
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  */
20 #pragma once
21 
22 #ifndef BLENDSHAPE_HPP_
23 #define BLENDSHAPE_HPP_
24 
25 #include "eos/morphablemodel/io/mat_cerealisation.hpp"
26 #include "cereal/types/string.hpp"
27 #include "cereal/archives/binary.hpp"
28 
29 #include "opencv2/core/core.hpp"
30 
31 #include <string>
32 #include <fstream>
33 
34 namespace eos {
35  namespace morphablemodel {
36 
44 struct Blendshape
45 {
46  std::string name;
47  cv::Mat deformation;
48 
49  friend class cereal::access;
55  template<class Archive>
56  void serialize(Archive& archive)
57  {
58  archive(name, deformation);
59  };
60 };
61 
70 std::vector<Blendshape> load_blendshapes(std::string filename)
71 {
72  std::vector<Blendshape> blendshapes;
73 
74  std::ifstream file(filename, std::ios::binary);
75  if (file.fail()) {
76  throw std::runtime_error("Error opening given file: " + filename);
77  }
78  cereal::BinaryInputArchive input_archive(file);
79  input_archive(blendshapes);
80 
81  return blendshapes;
82 };
83 
84  } /* namespace morphablemodel */
85 } /* namespace eos */
86 
87 #endif /* BLENDSHAPE_HPP_ */
std::vector< Blendshape > load_blendshapes(std::string filename)
Definition: Blendshape.hpp:70
cv::Mat deformation
A 3m x 1 col-vector (xyzxyz...)&#39;, where m is the number of model-vertices. Has the same format as Pca...
Definition: Blendshape.hpp:47
void serialize(Archive &archive)
Definition: Blendshape.hpp:56
Namespace containing all of eos&#39;s 3D model fitting functionality.
A class representing a 3D blendshape.
Definition: Blendshape.hpp:44
std::string name
Name of the blendshape.
Definition: Blendshape.hpp:46