OpenShot Library | libopenshot  0.3.0
TrackedObjectBase.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_TRACKEDOBJECTBASE_H
15 #define OPENSHOT_TRACKEDOBJECTBASE_H
16 
17 #include <vector>
18 #include <string>
19 
20 #include "KeyFrame.h"
21 #include "Json.h"
22 
23 namespace openshot {
24 
25  // Forward decls
26  class ClipBase;
27 
36  protected:
37  std::string id;
38  std::string childClipId;
39 
41 
42  public:
43 
46 
49 
51  TrackedObjectBase(std::string _id);
52 
54  virtual ~TrackedObjectBase() = default;
55 
57  std::string Id() const { return id; }
59  void Id(std::string _id) { id = _id; }
61  ClipBase* ParentClip() const { return parentClip; }
62  void ParentClip(ClipBase* clip) { parentClip = clip; }
64  std::string ChildClipId() const { return childClipId; };
65  void ChildClipId(std::string _childClipId) { childClipId = _childClipId; };
66 
68  virtual bool ExactlyContains(int64_t frame_number) const { return {}; };
69 
71  virtual void ScalePoints(double scale) { return; };
73  virtual std::map<std::string, float> GetBoxValues(int64_t frame_number) const { std::map<std::string, float> ret; return ret; };
75  virtual std::map<std::string, float> GetParentClipProperties(int64_t frame_number) const { std::map<std::string, float> ret; return ret; }
77  virtual void AddBox(int64_t _frame_num, float _cx, float _cy, float _width, float _height, float _angle) { return; };
78 
79 
81  virtual std::string Json() const = 0;
82  virtual Json::Value JsonValue() const = 0;
83  virtual void SetJson(const std::string value) = 0;
84  virtual void SetJsonValue(const Json::Value root) = 0;
85 
88  virtual Json::Value PropertiesJSON(int64_t requested_frame) const = 0;
90  Json::Value add_property_choice_json(std::string name, int value, int selected_value) const;
91  };
92 } // Namespace openshot
93 
94 #endif
virtual void AddBox(int64_t _frame_num, float _cx, float _cy, float _width, float _height, float _angle)
Add a bounding box to the tracked object&#39;s BoxVec map.
virtual void SetJson(const std::string value)=0
Load JSON string into this object.
void ChildClipId(std::string _childClipId)
virtual std::map< std::string, float > GetParentClipProperties(int64_t frame_number) const
Return the main properties of the tracked object&#39;s parent clip - such as position, size and rotation.
ClipBase * ParentClip() const
Get and set the parentClip of this object.
Json::Value add_property_choice_json(std::string name, int value, int selected_value) const
Generate JSON choice for a property (dropdown properties)
This abstract class is the base class of all Tracked Objects.
virtual Json::Value PropertiesJSON(int64_t requested_frame) const =0
Header file for the Keyframe class.
virtual Json::Value JsonValue() const =0
Generate Json::Value for this object.
virtual ~TrackedObjectBase()=default
Destructor.
void ParentClip(ClipBase *clip)
Header file for JSON class.
virtual bool ExactlyContains(int64_t frame_number) const
Check if there is data for the exact frame number.
This abstract class is the base class, used by all clips in libopenshot.
Definition: ClipBase.h:33
void Id(std::string _id)
Set the id of this object.
std::string ChildClipId() const
Get and set the Id of the childClip of this object.
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
std::string Id() const
Get the id of this object.
virtual void ScalePoints(double scale)
Scale an object&#39;s property.
virtual std::string Json() const =0
Get and Set JSON methods.
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
virtual std::map< std::string, float > GetBoxValues(int64_t frame_number) const
Return the main properties of a TrackedObjectBBox instance - such as position, size and rotation...
A Keyframe is a collection of Point instances, which is used to vary a number or property over time...
Definition: KeyFrame.h:54
TrackedObjectBase()
Default constructor.