OpenShot Library | libopenshot  0.3.1
ChromaKey.h
Go to the documentation of this file.
1 
9 // Copyright (c) 2008-2019 OpenShot Studios, LLC
10 //
11 // SPDX-License-Identifier: LGPL-3.0-or-later
12 
13 #ifndef OPENSHOT_CHROMAKEY_EFFECT_H
14 #define OPENSHOT_CHROMAKEY_EFFECT_H
15 
16 #include "../EffectBase.h"
17 
18 #include "../Color.h"
19 #include "../Frame.h"
20 #include "../Exceptions.h"
21 #include "../KeyFrame.h"
22 #include "../Enums.h"
23 
24 #include <memory>
25 #include <string>
26 
27 namespace openshot
28 {
29 
36  class ChromaKey : public EffectBase
37  {
38  private:
39  Color color;
40  Keyframe fuzz;
41  Keyframe halo;
42  ChromaKeyMethod method;
43 
45  void init_effect_details();
46 
47  public:
48 
50  ChromaKey();
51 
79  ChromaKey(Color color, Keyframe fuzz, Keyframe halo = 0.0, ChromaKeyMethod method = CHROMAKEY_BASIC);
80 
87  std::shared_ptr<openshot::Frame> GetFrame(int64_t frame_number) override { return GetFrame(std::make_shared<openshot::Frame>(), frame_number); }
88 
98  std::shared_ptr<openshot::Frame> GetFrame(std::shared_ptr<openshot::Frame> frame, int64_t frame_number) override;
99 
100  // Get and Set JSON methods
101  std::string Json() const override;
102  void SetJson(const std::string value) override;
103  Json::Value JsonValue() const override;
104  void SetJsonValue(const Json::Value root) override;
105 
106  // Get all properties for a specific frame
107  std::string PropertiesJSON(int64_t requested_frame) const override;
108  };
109 
110 }
111 
112 #endif
This class removes (i.e. keys out) a color (i.e. greenscreen)
Definition: ChromaKey.h:37
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: ChromaKey.cpp:539
ChromaKey()
Blank constructor, useful when using Json to load the effect properties.
Definition: ChromaKey.cpp:25
std::string Json() const override
Generate JSON string of this object.
Definition: ChromaKey.cpp:517
std::string PropertiesJSON(int64_t requested_frame) const override
Definition: ChromaKey.cpp:573
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: ChromaKey.h:87
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: ChromaKey.cpp:524
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: ChromaKey.cpp:556
This class represents a color (used on the timeline and clips)
Definition: Color.h:27
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:53
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:53
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:29
ChromaKeyMethod
This enumeration determines the algorithm used by the ChromaKey filter.
Definition: Enums.h:121
@ CHROMAKEY_BASIC
Length of difference between RGB vectors.
Definition: Enums.h:122