OpenShot Library | libopenshot  0.3.2
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;
39 
40  public:
41 
44 
47 
50 
52  TrackedObjectBase(std::string _id);
53 
55  virtual ~TrackedObjectBase() = default;
56 
58  std::string Id() const { return id; }
60  void Id(std::string _id) { id = _id; }
62  ClipBase* ParentClip() const { return parentClip; }
63  void ParentClip(ClipBase* clip) { parentClip = clip; }
64 
66  virtual bool ExactlyContains(int64_t frame_number) const { return {}; };
67 
69  virtual void ScalePoints(double scale) { return; };
71  virtual std::map<std::string, float> GetBoxValues(int64_t frame_number) const { std::map<std::string, float> ret; return ret; };
73  virtual void AddBox(int64_t _frame_num, float _cx, float _cy, float _width, float _height, float _angle) { return; };
74 
75 
77  virtual std::string Json() const = 0;
78  virtual Json::Value JsonValue() const = 0;
79  virtual void SetJson(const std::string value) = 0;
80  virtual void SetJsonValue(const Json::Value root) = 0;
81 
84  virtual Json::Value PropertiesJSON(int64_t requested_frame) const = 0;
86  Json::Value add_property_choice_json(std::string name, int value, int selected_value) const;
87  };
88 } // Namespace openshot
89 
90 #endif
openshot::TrackedObjectBase::ParentClip
void ParentClip(ClipBase *clip)
Definition: TrackedObjectBase.h:63
openshot
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:28
openshot::TrackedObjectBase::PropertiesJSON
virtual Json::Value PropertiesJSON(int64_t requested_frame) const =0
openshot::TrackedObjectBase
This abstract class is the base class of all Tracked Objects.
Definition: TrackedObjectBase.h:35
openshot::TrackedObjectBase::ScalePoints
virtual void ScalePoints(double scale)
Scale an object's property.
Definition: TrackedObjectBase.h:69
openshot::TrackedObjectBase::Json
virtual std::string Json() const =0
Get and Set JSON methods.
openshot::TrackedObjectBase::add_property_choice_json
Json::Value add_property_choice_json(std::string name, int value, int selected_value) const
Generate JSON choice for a property (dropdown properties)
Definition: TrackedObjectBase.cpp:28
KeyFrame.h
Header file for the Keyframe class.
openshot::TrackedObjectBase::SetJsonValue
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
openshot::TrackedObjectBase::draw_box
Keyframe draw_box
Keyframe to determine if a specific box is drawn (or hidden)
Definition: TrackedObjectBase.h:46
openshot::TrackedObjectBase::Id
std::string Id() const
Get the id of this object.
Definition: TrackedObjectBase.h:58
openshot::TrackedObjectBase::id
std::string id
Definition: TrackedObjectBase.h:37
openshot::TrackedObjectBase::GetBoxValues
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.
Definition: TrackedObjectBase.h:71
openshot::TrackedObjectBase::visible
Keyframe visible
Keyframe to track if a box is visible in the current frame (read-only)
Definition: TrackedObjectBase.h:43
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::TrackedObjectBase::SetJson
virtual void SetJson(const std::string value)=0
Load JSON string into this object.
openshot::TrackedObjectBase::ParentClip
ClipBase * ParentClip() const
Get and set the parentClip of this object.
Definition: TrackedObjectBase.h:62
openshot::TrackedObjectBase::TrackedObjectBase
TrackedObjectBase()
Default constructor.
Definition: TrackedObjectBase.cpp:22
openshot::TrackedObjectBase::ExactlyContains
virtual bool ExactlyContains(int64_t frame_number) const
Check if there is data for the exact frame number.
Definition: TrackedObjectBase.h:66
openshot::TrackedObjectBase::Id
void Id(std::string _id)
Set the id of this object.
Definition: TrackedObjectBase.h:60
openshot::TrackedObjectBase::JsonValue
virtual Json::Value JsonValue() const =0
Generate Json::Value for this object.
Json.h
Header file for JSON class.
openshot::ClipBase
This abstract class is the base class, used by all clips in libopenshot.
Definition: ClipBase.h:33
openshot::TrackedObjectBase::parentClip
ClipBase * parentClip
Definition: TrackedObjectBase.h:38
openshot::TrackedObjectBase::AddBox
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's BoxVec map.
Definition: TrackedObjectBase.h:73
openshot::TrackedObjectBase::~TrackedObjectBase
virtual ~TrackedObjectBase()=default
Destructor.