Skip to content

Commit

Permalink
Updated documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
BrennoCaldato committed Jan 22, 2021
1 parent d6e0acb commit ce2c4e0
Show file tree
Hide file tree
Showing 7 changed files with 60 additions and 57 deletions.
23 changes: 10 additions & 13 deletions src/KeyFrameBase.h
Expand Up @@ -45,16 +45,6 @@


namespace openshot {
/**
* @brief This abstract class is the base class of all Keyframes.
*
* A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
*
* Keyframes are used to animate and interpolate values of properties over time. For example, a single property
* can use a Keyframe instead of a constant value. Assume you want to slide an image (from left to right) over
* a video. You can create a Keyframe which will adjust the X value of the image over 100 frames (or however many
* frames the animation needs to last) from the value of 0 to 640.
*/

/// Check if the X coordinate of a given Point is lower than a given value
bool IsPointBeforeX(Point const & p, double const x);
Expand All @@ -68,9 +58,16 @@ namespace openshot {
/// Interpolate two points using the right Point's interpolation method
double InterpolateBetween(Point const & left, Point const & right, double target, double allowed_error);

// template<typename Check>
// int64_t SearchBetweenPoints(Point const & left, Point const & right, int64_t const current, Check check);

/**
* @brief This abstract class is the base class of all Keyframes.
*
* A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
*
* Keyframes are used to animate and interpolate values of properties over time. For example, a single property
* can use a Keyframe instead of a constant value. Assume you want to slide an image (from left to right) over
* a video. You can create a Keyframe which will adjust the X value of the image over 100 frames (or however many
* frames the animation needs to last) from the value of 0 to 640.
*/
class KeyframeBase{

public:
Expand Down
13 changes: 8 additions & 5 deletions src/TrackedObjectBBox.cpp
@@ -1,6 +1,6 @@
/**
* @file
* @brief Source file for the Keyframe class
* @brief Source file for the TrackedObjectBBox class
* @author Jonathan Thomas <jonathan@openshot.org>
*
* @ref License
Expand Down Expand Up @@ -350,7 +350,7 @@ void TrackedObjectBBox::SetJson(const std::string value)
void TrackedObjectBBox::SetJsonValue(const Json::Value root)
{

// Set the Id
// Set the Id by the given JSON object
if (!root["box_id"].isNull())
Id(root["box_id"].asString());

Expand All @@ -370,6 +370,7 @@ void TrackedObjectBBox::SetJsonValue(const Json::Value root)
this->ScalePoints(scale);
}

// Set the protobuf data path by the given JSON object
if (!root["protobuf_data_path"].isNull())
protobufDataPath = root["protobuf_data_path"].asString();

Expand All @@ -396,7 +397,7 @@ Json::Value TrackedObjectBBox::PropertiesJSON(int64_t requested_frame) const

BBox box = GetBox(requested_frame);

// Id
// Add the ID of this object to the JSON object
root["box_id"] = add_property_json("Box ID", 0.0, "string", Id(), NULL, -1, -1, true, requested_frame);

// Add a boolean property to inform if the object has data for the requested frame
Expand Down Expand Up @@ -457,7 +458,7 @@ Json::Value TrackedObjectBBox::add_property_json(std::string name, float value,
return prop;
}

// Return the bounding box properties and it's keyframes indexed by their names
// Return a map that contains the bounding box properties and it's keyframes indexed by their names
std::map<std::string, float> TrackedObjectBBox::GetBoxValues(int64_t frame_number) const {

// Create the map
Expand All @@ -484,7 +485,7 @@ std::map<std::string, float> TrackedObjectBBox::GetBoxValues(int64_t frame_numbe
return boxValues;
}

// Return properties of this object's parent clip
// Return a map that contains the properties of this object's parent clip
std::map<std::string, float> TrackedObjectBBox::GetParentClipProperties(int64_t frame_number) const {

// Get the parent clip of this object as a Clip pointer
Expand All @@ -502,8 +503,10 @@ std::map<std::string, float> TrackedObjectBBox::GetParentClipProperties(int64_t
float parentClip_scale_y = parentClip->scale_y.GetValue(parentClip_frame_number);
float parentClip_rotation = parentClip->rotation.GetValue(parentClip_frame_number);

// Initialize the parent clip properties map
std::map<std::string, float> parentClipProperties;

// Set the map properties
parentClipProperties["frame_number"] = parentClip_frame_number;
parentClipProperties["timeline_frame_number"] = frame_number;
parentClipProperties["location_x"] = parentClip_location_x;
Expand Down
49 changes: 25 additions & 24 deletions src/TrackedObjectBBox.h
Expand Up @@ -52,13 +52,15 @@ using google::protobuf::util::TimeUtil;
namespace openshot
{
/**
* @brief This struct holds the information of a bounding-box: a rectangular shape that enclosures an object or a
* desired set of pixels in a digital image.
*
* The bounding-box structure holds four floating-point properties: the x and y coordinates of the rectangle's
* top left corner (x1, y1), the rectangle's width and the rectangle's height.
*/

* @brief This struct holds the information of a bounding-box.
*
* A bounding-box is a rectangular shape that enclosures an
* object or a desired set of pixels in a digital image.
*
* The bounding-box structure holds five floating-point properties:
* the x and y coordinates of the rectangle's center point (cx, cy),
* the rectangle's width, height and rotation.
*/
struct BBox
{
float cx = -1; ///< x-coordinate of the bounding box center
Expand All @@ -68,10 +70,7 @@ namespace openshot
float angle = -1; ///< bounding box rotation angle [degrees]

/// Blank constructor
BBox()
{
return;
}
BBox() {}

/// Default constructor, which takes the bounding box top-left corner coordinates, width and height.
/// @param _cx X-coordinate of the bounding box center
Expand Down Expand Up @@ -144,16 +143,17 @@ namespace openshot
};

/**
* @brief This class holds the information of a bounding-box (mapped by time) over the frames that contain
* the object enclosured by it.
*
* The bounding-box displacement in X and Y directions and it's width and height variation over the frames
* are set as openshot::Keyframe objects
* @brief This class contains the properties of a tracked object
* and functions to manipulate it.
*
* The bounding-box information over the clip's frames are saved into a protobuf file and loaded into an
* object of this class.
*/

* The bounding-box displacement in X and Y directions, it's width,
* height and rotation variation over the frames are set as
* openshot::Keyframe objects.
*
* The bounding-box information over the clip's frames are
* saved into a protobuf file and loaded into an
* object of this class.
*/
class TrackedObjectBBox : public TrackedObjectBase
{
private:
Expand All @@ -168,7 +168,7 @@ namespace openshot
Keyframe scale_x; ///< X-direction scale Keyframe
Keyframe scale_y; ///< Y-direction scale Keyframe
Keyframe rotation; ///< Rotation Keyframe
std::string protobufDataPath; ///< Path to the protobuf file that holds the bbox points across the frames
std::string protobufDataPath; ///< Path to the protobuf file that holds the bounding box points across the frames

/// Default Constructor
TrackedObjectBBox();
Expand Down Expand Up @@ -197,11 +197,12 @@ namespace openshot
void RemoveBox(int64_t frame_number);

/// Return a bounding-box from BoxVec with it's properties adjusted by the Keyframes
BBox GetBox(int64_t frame_number);
/// Const-cast of the GetBox function, so that it can be called inside other cont function
BBox GetBox(int64_t frame_number) const
{
return const_cast<TrackedObjectBBox *>(this)->GetBox(frame_number);
}
BBox GetBox(int64_t frame_number);

/// Load the bounding-boxes information from the protobuf file
bool LoadBoxData(std::string inputFilePath);
Expand All @@ -228,9 +229,9 @@ namespace openshot
// Generate JSON for a property
Json::Value add_property_json(std::string name, float value, std::string type, std::string memo, const Keyframe* keyframe, float min_value, float max_value, bool readonly, int64_t requested_frame) const;

/// Return the bounding box properties and it's keyframes indexed by their names
/// Return a map that contains the bounding box properties and it's keyframes indexed by their names
std::map<std::string, float> GetBoxValues(int64_t frame_number) const override;
/// Return properties of this object's parent clip
/// Return a map that contains the properties of this object's parent clip
std::map<std::string, float> GetParentClipProperties(int64_t frame_number) const override;

};
Expand Down
3 changes: 3 additions & 0 deletions src/TrackedObjectBase.cpp
Expand Up @@ -36,10 +36,13 @@

namespace openshot{

// Blank constructor
TrackedObjectBase::TrackedObjectBase(){
// Initializes the id as "None"
id = "None";
}

// Default constructor
TrackedObjectBase::TrackedObjectBase(std::string _id){
Id(_id);
}
Expand Down
21 changes: 9 additions & 12 deletions src/TrackedObjectBase.h
Expand Up @@ -47,16 +47,12 @@

namespace openshot {
/**
* @brief This abstract class is the base class of all Keyframes.
* @brief This abstract class is the base class of all Tracked Objects.
*
* A Keyframe is a collection of Point instances, which is used to vary a number or property over time.
*
* Keyframes are used to animate and interpolate values of properties over time. For example, a single property
* can use a Keyframe instead of a constant value. Assume you want to slide an image (from left to right) over
* a video. You can create a Keyframe which will adjust the X value of the image over 100 frames (or however many
* frames the animation needs to last) from the value of 0 to 640.
* A Tracked Object is an object or a desired set of pixels in a digital image
* which properties (such as position, width and height) can be detected and
* predicted along the frames of a clip.
*/

class TrackedObjectBase {
private:
std::string id;
Expand All @@ -70,18 +66,19 @@ namespace openshot {
/// Default constructor
TrackedObjectBase(std::string _id);

/// Get and set the id of this object
/// Get the id of this object
std::string Id() const { return id; }
/// Set the id of this object
void Id(std::string _id) { id = _id; }
/// Get and set the parentClip of this object
ClipBase* ParentClip() const { return parentClip; }
void ParentClip(ClipBase* clip) { parentClip = clip; }

/// Scale a property
/// Scale an object's property
virtual void ScalePoints(double scale) { return; };
/// Return the main properties of a TrackedObjectBBox instance using a pointer to this base class
/// Return the main properties of a TrackedObjectBBox instance - such as position, size and rotation
virtual std::map<std::string, float> GetBoxValues(int64_t frame_number) const { std::map<std::string, float> ret; return ret; };
/// Return the main properties of the tracked object's parent clip
/// Return the main properties of the tracked object's parent clip - such as position, size and rotation
virtual std::map<std::string, float> GetParentClipProperties(int64_t frame_number) const { std::map<std::string, float> ret; return ret; }
/// Add a bounding box to the tracked object's BoxVec map
virtual void AddBox(int64_t _frame_num, float _cx, float _cy, float _width, float _height, float _angle) { return; };
Expand Down
2 changes: 1 addition & 1 deletion src/effects/Stabilizer.h
Expand Up @@ -76,7 +76,7 @@ namespace openshot
{

/**
* @brief This class stabilizes video clip to remove undesired shaking and jitter.
* @brief This class stabilizes a video clip to remove undesired shaking and jitter.
*
* Adding stabilization is useful to increase video quality overall, since it removes
* from subtle to harsh unexpected camera movements.
Expand Down
6 changes: 4 additions & 2 deletions src/effects/Tracker.h
Expand Up @@ -48,9 +48,11 @@ using namespace std;
namespace openshot
{
/**
* @brief This class track a given object through the clip and, when called, draws a box surrounding it.
* @brief This class tracks a given object through the clip, draws a box around it and allow
* the user to attach another clip (image or video) to the tracked object.
*
* Tracking is useful to better visualize and follow the movement of an object through video.
* Tracking is useful to better visualize, follow the movement of an object through video
* and attach an image or video to it.
*/
class Tracker : public EffectBase
{
Expand Down

0 comments on commit ce2c4e0

Please sign in to comment.