OpenShot Library | libopenshot  0.3.1
Tracker.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_TRACKER_EFFECT_H
15 #define OPENSHOT_TRACKER_EFFECT_H
16 
17 #include <string>
18 #include <memory>
19 #include <map>
20 
21 #include "EffectBase.h"
22 
23 #include "Json.h"
24 #include "KeyFrame.h"
25 
26 #include "TrackedObjectBBox.h"
27 
28 namespace openshot
29 {
30  // Forwards decls
31  class Frame;
32  class TrackedObjectBBox;
33 
41  class Tracker : public EffectBase
42  {
43  private:
45  void init_effect_details();
46 
47  Fraction BaseFPS;
48  double TimeScale;
49 
50  public:
51  std::string protobuf_data_path;
52  std::shared_ptr<TrackedObjectBBox> trackedData;
53 
55  Tracker();
56 
57  Tracker(std::string clipTrackerDataPath);
58 
64  std::shared_ptr<Frame> GetFrame(std::shared_ptr<Frame> frame, int64_t frame_number) override;
65 
66  std::shared_ptr<openshot::Frame>
67  GetFrame(int64_t frame_number) override {
68  return GetFrame(std::shared_ptr<Frame>(new Frame()), frame_number);
69  }
70 
72  std::string GetVisibleObjects(int64_t frame_number) const override;
73 
74  void DrawRectangleRGBA(cv::Mat &frame_image, cv::RotatedRect box, std::vector<int> color, float alpha, int thickness, bool is_background);
75 
76  // Get and Set JSON methods
77 
79  std::string Json() const override;
81  void SetJson(const std::string value) override;
83  Json::Value JsonValue() const override;
85  void SetJsonValue(const Json::Value root) override;
86 
91  std::string PropertiesJSON(int64_t requested_frame) const override;
92  };
93 
94 }
95 
96 #endif
void SetJsonValue(const Json::Value root) override
Load Json::Value into this object.
Definition: Tracker.cpp:286
This abstract class is the base class, used by all effects in libopenshot.
Definition: EffectBase.h:52
std::shared_ptr< TrackedObjectBBox > trackedData
Pointer to an object that holds the bounding-box data and it&#39;s Keyframes.
Definition: Tracker.h:52
Json::Value JsonValue() const override
Generate Json::Value for this object.
Definition: Tracker.cpp:242
This class represents a single frame of video (i.e. image & audio data)
Definition: Frame.h:90
This class tracks a given object through the clip, draws a box around it and allow the user to attach...
Definition: Tracker.h:41
std::string Json() const override
Generate JSON string of this object.
Definition: Tracker.cpp:235
std::string PropertiesJSON(int64_t requested_frame) const override
Definition: Tracker.cpp:339
Header file for the Keyframe class.
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: Tracker.h:67
Header file for JSON class.
void DrawRectangleRGBA(cv::Mat &frame_image, cv::RotatedRect box, std::vector< int > color, float alpha, int thickness, bool is_background)
Definition: Tracker.cpp:172
This class represents a fraction.
Definition: Fraction.h:30
std::string protobuf_data_path
Path to the protobuf file that holds the bounding-box data.
Definition: Tracker.h:51
Tracker()
Default constructor.
Definition: Tracker.cpp:52
std::string GetVisibleObjects(int64_t frame_number) const override
Get the indexes and IDs of all visible objects in the given frame.
Definition: Tracker.cpp:213
void SetJson(const std::string value) override
Load JSON string into this object.
Definition: Tracker.cpp:268
Header file for the TrackedObjectBBox class.
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
Header file for EffectBase class.
std::shared_ptr< Frame > GetFrame(std::shared_ptr< Frame > frame, int64_t frame_number) override
Apply this effect to an openshot::Frame.
Definition: Tracker.cpp:86