Dewobble
Video motion stabilization with awareness of lens projection
stabilizer.hpp
1 #ifndef DEWOBBLE_STABILIZER_HPP
2 #define DEWOBBLE_STABILIZER_HPP
3 
4 #include <gram_savitzky_golay/spatial_filters.h>
5 #include <opencv2/core.hpp>
6 #include <queue>
7 
8 #include "frame.hpp"
9 #include "rotation_detector.hpp"
10 
11 namespace dewobble
12 {
13 class StabilizedFrame : public Frame
14 {
15  public:
16  StabilizedFrame(
17  Frame frame,
18  cv::Mat corrective_rotation,
19  FrameDebugInfo debug_info);
20  cv::Mat corrective_rotation;
21  FrameDebugInfo debug_info;
22 };
23 
33 {
34  protected:
35  std::queue<StabilizedFrame> m_buffered_frames;
36  bool m_input_ended = false;
37 
38  public:
39  virtual ~Stabilizer() = default;
40  virtual void push_frame(Frame frame) = 0;
41  virtual void end_input();
42  virtual bool frame_ready();
43  virtual StabilizedFrame pop_stabilized_frame();
44 };
45 
51 {
52  const unsigned int m_radius;
53  std::queue<FrameWithOrientation> m_buffered_frames;
54  RotationDetector m_rotation_detector;
55  gram_sg::RotationFilter m_rotation_filter;
56  void try_pull_frames_from_detector();
57 
58  public:
70  Camera camera,
71  unsigned int radius,
72  int interpolation_horizon = 0);
73  void push_frame(Frame frame);
74  void end_input();
75  bool frame_ready();
76  StabilizedFrame pop_stabilized_frame();
77 };
78 
83 class StabilizerNone : public Stabilizer
84 {
85  public:
86  void push_frame(Frame frame);
87 };
88 
94 {
95  const Camera m_camera;
96  RotationDetector m_rotation_detector;
97  void flush_frames();
98 
99  public:
108  StabilizerFixed(Camera camera, int interpolation_horizon = 0);
109  void push_frame(Frame frame);
110  void end_input();
111 };
112 } // namespace dewobble
113 
114 #endif // DEWOBBLE_STABILIZER_HPP
Definition: camera.hpp:28
Definition: stabilizer.hpp:94
StabilizerFixed(Camera camera, int interpolation_horizon=0)
Construct a new fixed stabilizer.
Definition: stabilizer.hpp:84
Definition: stabilizer.hpp:51
StabilizerSavitzkyGolay(Camera camera, unsigned int radius, int interpolation_horizon=0)
Construct a new Savitzky-Golay stabilizer.
Definition: stabilizer.hpp:33