diff --git a/src/KeyFrameBase.h b/src/KeyFrameBase.h index 6a55ea5ef..14b94c198 100644 --- a/src/KeyFrameBase.h +++ b/src/KeyFrameBase.h @@ -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); @@ -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 - // 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: diff --git a/src/TrackedObjectBBox.cpp b/src/TrackedObjectBBox.cpp index 5ce953971..ed8e152a8 100644 --- a/src/TrackedObjectBBox.cpp +++ b/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 * * @ref License @@ -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()); @@ -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(); @@ -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 @@ -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 TrackedObjectBBox::GetBoxValues(int64_t frame_number) const { // Create the map @@ -484,7 +485,7 @@ std::map 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 TrackedObjectBBox::GetParentClipProperties(int64_t frame_number) const { // Get the parent clip of this object as a Clip pointer @@ -502,8 +503,10 @@ std::map 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 parentClipProperties; + // Set the map properties parentClipProperties["frame_number"] = parentClip_frame_number; parentClipProperties["timeline_frame_number"] = frame_number; parentClipProperties["location_x"] = parentClip_location_x; diff --git a/src/TrackedObjectBBox.h b/src/TrackedObjectBBox.h index b670b3a51..182853a46 100644 --- a/src/TrackedObjectBBox.h +++ b/src/TrackedObjectBBox.h @@ -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 @@ -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 @@ -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: @@ -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(); @@ -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(this)->GetBox(frame_number); } - BBox GetBox(int64_t frame_number); /// Load the bounding-boxes information from the protobuf file bool LoadBoxData(std::string inputFilePath); @@ -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 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 GetParentClipProperties(int64_t frame_number) const override; }; diff --git a/src/TrackedObjectBase.cpp b/src/TrackedObjectBase.cpp index 5d43d7fa5..157f55b39 100644 --- a/src/TrackedObjectBase.cpp +++ b/src/TrackedObjectBase.cpp @@ -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); } diff --git a/src/TrackedObjectBase.h b/src/TrackedObjectBase.h index 0a336cf2b..52499ed04 100644 --- a/src/TrackedObjectBase.h +++ b/src/TrackedObjectBase.h @@ -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; @@ -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 GetBoxValues(int64_t frame_number) const { std::map 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 GetParentClipProperties(int64_t frame_number) const { std::map 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; }; diff --git a/src/effects/Stabilizer.h b/src/effects/Stabilizer.h index 0d24b6c0c..4217958ec 100644 --- a/src/effects/Stabilizer.h +++ b/src/effects/Stabilizer.h @@ -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. diff --git a/src/effects/Tracker.h b/src/effects/Tracker.h index 2cb1faf5a..e5cca0477 100644 --- a/src/effects/Tracker.h +++ b/src/effects/Tracker.h @@ -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 {