eos  0.7.1
Landmark.hpp
1 /*
2  * Eos - A 3D Morphable Model fitting library written in modern C++11/14.
3  *
4  * File: include/eos/core/Landmark.hpp
5  *
6  * Copyright 2014, 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 EOS_LANDMARK_HPP_
23 #define EOS_LANDMARK_HPP_
24 
25 #include <string>
26 #include <vector>
27 #include <algorithm>
28 
29 namespace eos {
30  namespace core {
31 
36 template<class LandmarkType>
37 struct Landmark
38 {
39  std::string name;
40  LandmarkType coordinates;
41 };
42 
46 template<class LandmarkType> using LandmarkCollection = std::vector<Landmark<LandmarkType>>;
47 
56 template<class T>
57 LandmarkCollection<T> filter(const LandmarkCollection<T>& landmarks, const std::vector<std::string>& filter)
58 {
59  LandmarkCollection<T> filtered_landmarks;
60  using std::begin;
61  using std::end;
62  std::copy_if(begin(landmarks), end(landmarks), std::back_inserter(filtered_landmarks),
63  [&](const Landmark<T>& lm) { return std::find(begin(filter), end(filter), lm.name) != end(filter); }
64  );
65  return filtered_landmarks;
66 };
67 
68  } /* namespace core */
69 } /* namespace eos */
70 
71 #endif /* EOS_LANDMARK_HPP_ */
std::string name
Name of the landmark, often used as identifier.
Definition: Landmark.hpp:39
std::vector< Landmark< LandmarkType >> LandmarkCollection
A trivial collection of landmarks that belong together.
Definition: Landmark.hpp:46
LandmarkType coordinates
The position or coordinates of the landmark.
Definition: Landmark.hpp:40
LandmarkCollection< T > filter(const LandmarkCollection< T > &landmarks, const std::vector< std::string > &filter)
Filters the given LandmarkCollection and returns a new LandmarkCollection containing all landmarks wh...
Definition: Landmark.hpp:57
Representation of a landmark, consisting of a landmark name and coordinates of the given type...
Definition: Landmark.hpp:37
Namespace containing all of eos&#39;s 3D model fitting functionality.