face_video_segment  0.8
Adaptation of The Video Segmentation Project for face segmentation.
keyframer.h
1 // Copyright (c) 2010-2014, The Video Segmentation Project
2 // All rights reserved.
3 
4 // Redistribution and use in source and binary forms, with or without
5 // modification, are permitted provided that the following conditions are met:
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above copyright
9 // notice, this list of conditions and the following disclaimer in the
10 // documentation and/or other materials provided with the distribution.
11 // * Neither the name of the The Video Segmentation Project nor the
12 // names of its contributors may be used to endorse or promote products
13 // derived from this software without specific prior written permission.
14 
15 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
16 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
17 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
18 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
19 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
20 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
21 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
22 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
23 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
25 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 //
27 // ---
28 
29 #ifndef FVS_KEYFRAMER_H__
30 #define FVS_KEYFRAMER_H__
31 
32 #include "face_video_segment.pb.h"
33 
34 // std
35 #include <list>
36 
37 // sfl
38 #include <sfl/sequence_face_landmarks.h>
39 
40 // OpenCV
41 #include <opencv2/core.hpp>
42 
43 namespace fvs {
44 
51  class Keyframer
52  {
53  public:
54 
55  struct Keyframe
56  {
57  int id;
58  cv::Point3f euler_angles;
59  };
60 
61  struct FaceData
62  {
63  std::list<Keyframe> keyframes;
64  std::list<std::vector<cv::Point>> history;
65  int frame_updated_ind;
66  };
67 
73  Keyframer(int start_frame = 10, int stability_range = 5);
74 
79  void addFrame(const sfl::Frame& sfl_frame, Frame& fvs_frame);
80 
81  private:
86  bool addFace(const sfl::Face& sfl_face, Face& fvs_face);
87 
88  private:
89  //std::list<Keyframe> m_keyframes;
90  //std::list<std::vector<cv::Point>> m_history;
91  std::map<int, FaceData> m_face_data_map;
92  int m_start_frame;
93  int m_stability_range;
94  int m_frame_counter;
95  };
96 
97 } // namespace fvs
98 
99 #endif // FVS_KEYFRAMER_H__
Definition: keyframer.h:55
Definition: keyframer.h:61
void addFrame(const sfl::Frame &sfl_frame, Frame &fvs_frame)
Add a new frame.
Definition: keyframer.cpp:44
Keyframer(int start_frame=10, int stability_range=5)
Constructor.
Definition: keyframer.cpp:37
cv::Point3f euler_angles
Face orientation in euler angles.
Definition: keyframer.h:58
Definition: face_regions.cpp:43
int id
Frame sequence id.
Definition: keyframer.h:57
Divides a sequence of frames containing faces into keyframes.
Definition: keyframer.h:51