eos  0.7.1
coefficients.hpp
1 /*
2  * Eos - A 3D Morphable Model fitting library written in modern C++11/14.
3  *
4  * File: include/eos/morphablemodel/coefficients.hpp
5  *
6  * Copyright 2016 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 COEFFICIENTS_HPP_
23 #define COEFFICIENTS_HPP_
24 
25 #include "cereal/cereal.hpp"
26 #include "cereal/archives/json.hpp"
27 
28 #include <vector>
29 #include <string>
30 
31 namespace eos {
32  namespace morphablemodel {
33 
41 void save_coefficients(std::vector<float> coefficients, std::string filename)
42 {
43  std::ofstream file(filename);
44  if (file.fail()) {
45  throw std::runtime_error("Error opening file for writing: " + filename);
46  }
47  cereal::JSONOutputArchive output_archive(file);
48  output_archive(cereal::make_nvp("shape_coefficients", coefficients));
49 };
50 
51  } /* namespace morphablemodel */
52 } /* namespace eos */
53 
54 #endif /* COEFFICIENTS_HPP_ */
Namespace containing all of eos&#39;s 3D model fitting functionality.
void save_coefficients(std::vector< float > coefficients, std::string filename)
Definition: coefficients.hpp:41