OpenShot Library | libopenshot 0.2.7
TrackedObjectBase.h
Go to the documentation of this file.
1/**
2 * @file
3 * @brief Header file for the TrackedObjectBase class
4 * @author Jonathan Thomas <jonathan@openshot.org>
5 * @author Brenno Caldato <brenno.caldato@outlook.com>
6 *
7 * @ref License
8 */
9
10/* LICENSE
11 *
12 * Copyright (c) 2008-2019 OpenShot Studios, LLC
13 * <http://www.openshotstudios.com/>. This file is part of
14 * OpenShot Library (libopenshot), an open-source project dedicated to
15 * delivering high quality video editing and animation solutions to the
16 * world. For more information visit <http://www.openshot.org/>.
17 *
18 * OpenShot Library (libopenshot) is free software: you can redistribute it
19 * and/or modify it under the terms of the GNU Lesser General Public License
20 * as published by the Free Software Foundation, either version 3 of the
21 * License, or (at your option) any later version.
22 *
23 * OpenShot Library (libopenshot) is distributed in the hope that it will be
24 * useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
25 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
26 * GNU Lesser General Public License for more details.
27 *
28 * You should have received a copy of the GNU Lesser General Public License
29 * along with OpenShot Library. If not, see <http://www.gnu.org/licenses/>.
30 */
31
32#ifndef OPENSHOT_TRACKEDOBJECTBASE_H
33#define OPENSHOT_TRACKEDOBJECTBASE_H
34
35#include <vector>
36#include <string>
37
38#include "KeyFrame.h"
39#include "Json.h"
40
41namespace openshot {
42
43 // Forward decls
44 class ClipBase;
45
46 /**
47 * @brief This abstract class is the base class of all Tracked Objects.
48 *
49 * A Tracked Object is an object or a desired set of pixels in a digital image
50 * which properties (such as position, width and height) can be detected and
51 * predicted along the frames of a clip.
52 */
54 protected:
55 std::string id;
56 std::string childClipId;
57
59
60 public:
61
64
65 /// Default constructor
67
68 /// Constructor which takes an object ID
69 TrackedObjectBase(std::string _id);
70
71 /// Destructor
72 virtual ~TrackedObjectBase() = default;
73
74 /// Get the id of this object
75 std::string Id() const { return id; }
76 /// Set the id of this object
77 void Id(std::string _id) { id = _id; }
78 /// Get and set the parentClip of this object
79 ClipBase* ParentClip() const { return parentClip; }
80 void ParentClip(ClipBase* clip) { parentClip = clip; }
81 /// Get and set the Id of the childClip of this object
82 std::string ChildClipId() const { return childClipId; };
83 void ChildClipId(std::string _childClipId) { childClipId = _childClipId; };
84
85 /// Check if there is data for the exact frame number
86 virtual bool ExactlyContains(int64_t frame_number) const { return {}; };
87
88 /// Scale an object's property
89 virtual void ScalePoints(double scale) { return; };
90 /// Return the main properties of a TrackedObjectBBox instance - such as position, size and rotation
91 virtual std::map<std::string, float> GetBoxValues(int64_t frame_number) const { std::map<std::string, float> ret; return ret; };
92 /// Return the main properties of the tracked object's parent clip - such as position, size and rotation
93 virtual std::map<std::string, float> GetParentClipProperties(int64_t frame_number) const { std::map<std::string, float> ret; return ret; }
94 /// Add a bounding box to the tracked object's BoxVec map
95 virtual void AddBox(int64_t _frame_num, float _cx, float _cy, float _width, float _height, float _angle) { return; };
96
97
98 /// Get and Set JSON methods
99 virtual std::string Json() const = 0; ///< Generate JSON string of this object
100 virtual Json::Value JsonValue() const = 0; ///< Generate Json::Value for this object
101 virtual void SetJson(const std::string value) = 0; ///< Load JSON string into this object
102 virtual void SetJsonValue(const Json::Value root) = 0; ///< Load Json::Value into this object
103
104 /// Get all properties for a specific frame (perfect for a UI to display the current state
105 /// of all properties at any time)
106 virtual Json::Value PropertiesJSON(int64_t requested_frame) const = 0;
107 /// Generate JSON choice for a property (dropdown properties)
108 Json::Value add_property_choice_json(std::string name, int value, int selected_value) const;
109 };
110} // Namespace openshot
111
112#endif
Header file for JSON class.
Header file for the Keyframe class.
This abstract class is the base class, used by all clips in libopenshot.
Definition: ClipBase.h:51
A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
Definition: KeyFrame.h:72
This abstract class is the base class of all Tracked Objects.
std::string ChildClipId() const
Get and set the Id of the childClip of this object.
virtual void SetJsonValue(const Json::Value root)=0
Load Json::Value into this object.
virtual std::string Json() const =0
Get and Set JSON methods.
virtual Json::Value PropertiesJSON(int64_t requested_frame) const =0
Json::Value add_property_choice_json(std::string name, int value, int selected_value) const
Generate JSON choice for a property (dropdown properties)
virtual bool ExactlyContains(int64_t frame_number) const
Check if there is data for the exact frame number.
virtual void SetJson(const std::string value)=0
Load JSON string into this object.
virtual void ScalePoints(double scale)
Scale an object's property.
virtual std::map< std::string, float > GetParentClipProperties(int64_t frame_number) const
Return the main properties of the tracked object's parent clip - such as position,...
void Id(std::string _id)
Set the id of this object.
void ParentClip(ClipBase *clip)
void ChildClipId(std::string _childClipId)
TrackedObjectBase()
Default constructor.
virtual Json::Value JsonValue() const =0
Generate Json::Value for this object.
virtual ~TrackedObjectBase()=default
Destructor.
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.
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.
ClipBase * ParentClip() const
Get and set the parentClip of this object.
std::string Id() const
Get the id of this object.
This namespace is the default namespace for all code in the openshot library.
Definition: Compressor.h:47