OpenShot Library | libopenshot  0.4.0
Stabilizer.h
Go to the documentation of this file.
1 
10 // Copyright (c) 2008-2019 OpenShot Studios, LLC
11 //
12 // SPDX-License-Identifier: LGPL-3.0-or-later
13 
14 #ifndef OPENSHOT_STABILIZER_EFFECT_H
15 #define OPENSHOT_STABILIZER_EFFECT_H
16 
17 #include "EffectBase.h"
18 
19 #include <memory>
20 
21 #include "Json.h"
22 #include "KeyFrame.h"
23 
24 // Store the relative transformation parameters between consecutive frames
26 {
28  EffectTransformParam(double _dx, double _dy, double _da) {
29  dx = _dx;
30  dy = _dy;
31  da = _da;
32  }
33 
34  double dx;
35  double dy;
36  double da; // angle
37 };
38 
39 // Stores the global camera trajectory for one frame
41 {
43  EffectCamTrajectory(double _x, double _y, double _a) {
44  x = _x;
45  y = _y;
46  a = _a;
47  }
48 
49  double x;
50  double y;
51  double a; // angle
52 };
53 
54 
55 namespace openshot
56 {
57  // Forwward decls
58  class Frame;
59 
66  class Stabilizer : public EffectBase
67  {
68  private:
70  void init_effect_details();
71  std::string protobuf_data_path;
72  Keyframe zoom;
73 
74  public:
75  std::string teste;
76  std::map <size_t,EffectCamTrajectory> trajectoryData; // Save camera trajectory data
77  std::map <size_t,EffectTransformParam> transformationData; // Save transormation data
78 
79  Stabilizer();
80 
81  Stabilizer(std::string clipTrackerDataPath);
82 
92  std::shared_ptr<Frame> GetFrame(std::shared_ptr<Frame> frame, int64_t frame_number) override;
93 
94  std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override {
95  return GetFrame(std::make_shared<openshot::Frame>(), frame_number);
96  };
97 
99  bool LoadStabilizedData(std::string inputFilePath);
100 
101  // Get and Set JSON methods
102  std::string Json() const override;
103  void SetJson(const std::string value) override;
104  Json::Value JsonValue() const override;
105  void SetJsonValue(const Json::Value root) override;
106 
109  std::string PropertiesJSON(int64_t requested_frame) const override;
110  };
111 
112 }
113 
114 #endif
EffectCamTrajectory::EffectCamTrajectory
EffectCamTrajectory(double _x, double _y, double _a)
Definition: Stabilizer.h:43
openshot::EffectBase
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:53
openshot::Stabilizer::SetJsonValue
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: Stabilizer.cpp:194
openshot::Stabilizer::teste
std::string teste
Definition: Stabilizer.h:75
EffectTransformParam::da
double da
Definition: Stabilizer.h:36
openshot::Stabilizer::Json
std::string Json() const override
Generate JSON string of this object.
Definition: Stabilizer.cpp:157
openshot::Stabilizer
This class stabilizes a video clip to remove undesired shaking and jitter.
Definition: Stabilizer.h:66
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
EffectTransformParam::EffectTransformParam
EffectTransformParam()
Definition: Stabilizer.h:27
openshot::Stabilizer::GetFrame
std::shared_ptr< openshot::Frame > GetFrame(int64_t frame_number) override
This method is required for all derived classes of ClipBase, and returns a new openshot::Frame object...
Definition: Stabilizer.h:94
EffectCamTrajectory::EffectCamTrajectory
EffectCamTrajectory()
Definition: Stabilizer.h:42
openshot::Stabilizer::trajectoryData
std::map< size_t, EffectCamTrajectory > trajectoryData
Definition: Stabilizer.h:76
openshot::Stabilizer::Stabilizer
Stabilizer()
Definition: Stabilizer.cpp:38
EffectBase.h
Header file for EffectBase class.
openshot::Stabilizer::PropertiesJSON
std::string PropertiesJSON(int64_t requested_frame) const override
Definition: Stabilizer.cpp:213
KeyFrame.h
Header file for the Keyframe class.
openshot::Stabilizer::LoadStabilizedData
bool LoadStabilizedData(std::string inputFilePath)
Load protobuf data file.
Definition: Stabilizer.cpp:106
EffectCamTrajectory::a
double a
Definition: Stabilizer.h:51
openshot::Keyframe
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:53
openshot::Stabilizer::transformationData
std::map< size_t, EffectTransformParam > transformationData
Definition: Stabilizer.h:77
EffectTransformParam::dx
double dx
Definition: Stabilizer.h:34
EffectTransformParam::EffectTransformParam
EffectTransformParam(double _dx, double _dy, double _da)
Definition: Stabilizer.h:28
openshot::Stabilizer::JsonValue
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: Stabilizer.cpp:164
openshot::Stabilizer::SetJson
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: Stabilizer.cpp:177
EffectTransformParam
Definition: Stabilizer.h:25
openshot::Stabilizer::GetFrame
std::shared_ptr< Frame > GetFrame(std::shared_ptr< Frame > frame, int64_t frame_number) override
This method is required for all derived classes of EffectBase, and returns a modified openshot::Frame...
Definition: Stabilizer.cpp:63
EffectCamTrajectory
Definition: Stabilizer.h:40
EffectCamTrajectory::x
double x
Definition: Stabilizer.h:49
Json.h
Header file for JSON class.
EffectTransformParam::dy
double dy
Definition: Stabilizer.h:35
EffectCamTrajectory::y
double y
Definition: Stabilizer.h:50