diff --git a/src/TrackedObjectBBox.cpp b/src/TrackedObjectBBox.cpp index 6eb005e6..c58aaca9 100644 --- a/src/TrackedObjectBBox.cpp +++ b/src/TrackedObjectBBox.cpp @@ -326,6 +326,7 @@ Json::Value TrackedObjectBBox::JsonValue() const root["scale_y"] = scale_y.JsonValue(); root["rotation"] = rotation.JsonValue(); root["visible"] = visible.JsonValue(); + root["draw_box"] = draw_box.JsonValue(); // return JsonValue return root; @@ -394,6 +395,8 @@ void TrackedObjectBBox::SetJsonValue(const Json::Value root) rotation.SetJsonValue(root["rotation"]); if (!root["visible"].isNull()) visible.SetJsonValue(root["visible"]); + if (!root["draw_box"].isNull()) + draw_box.SetJsonValue(root["draw_box"]); return; } @@ -425,6 +428,10 @@ Json::Value TrackedObjectBBox::PropertiesJSON(int64_t requested_frame) const root["scale_y"] = add_property_json("Scale (Height)", scale_y.GetValue(requested_frame), "float", "", &scale_y, -1.0, 1.0, false, requested_frame); root["rotation"] = add_property_json("Rotation", rotation.GetValue(requested_frame), "float", "", &rotation, 0, 360, false, requested_frame); root["visible"] = add_property_json("Visible", visible.GetValue(requested_frame), "int", "", &visible, 0, 1, false, requested_frame); + + root["draw_box"] = add_property_json("Draw Box", draw_box.GetValue(requested_frame), "int", "", &draw_box, -1, 1.0, false, requested_frame); + root["draw_box"]["choices"].append(add_property_choice_json("Off", 0, draw_box.GetValue(requested_frame))); + root["draw_box"]["choices"].append(add_property_choice_json("On", 1, draw_box.GetValue(requested_frame))); // Return formatted string return root; diff --git a/src/TrackedObjectBase.cpp b/src/TrackedObjectBase.cpp index c1fde78f..780a9f53 100644 --- a/src/TrackedObjectBase.cpp +++ b/src/TrackedObjectBase.cpp @@ -37,7 +37,7 @@ namespace openshot{ // Blank constructor - TrackedObjectBase::TrackedObjectBase() : visible(1.0) + TrackedObjectBase::TrackedObjectBase() : visible(1.0), draw_box(1) { // Initializes the id as "None" id = "None"; @@ -50,4 +50,15 @@ namespace openshot{ Id(_id); childClipId = "None"; } + + Json::Value TrackedObjectBase::add_property_choice_json(std::string name, int value, int selected_value) const { + // Create choice + Json::Value new_choice = Json::Value(Json::objectValue); + new_choice["name"] = name; + new_choice["value"] = value; + new_choice["selected"] = (value == selected_value); + + // return JsonValue + return new_choice; + } } \ No newline at end of file diff --git a/src/TrackedObjectBase.h b/src/TrackedObjectBase.h index 6d1038ef..20e70fcf 100644 --- a/src/TrackedObjectBase.h +++ b/src/TrackedObjectBase.h @@ -64,6 +64,7 @@ namespace openshot { public: Keyframe visible; + Keyframe draw_box; /// Blank constructor TrackedObjectBase(); @@ -104,6 +105,9 @@ namespace openshot { /// Get all properties for a specific frame (perfect for a UI to display the current state /// of all properties at any time) virtual Json::Value PropertiesJSON(int64_t requested_frame) const = 0; + /// Generate JSON choice for a property (dropdown properties) + Json::Value add_property_choice_json(std::string name, int value, int selected_value) const; + }; } // Namespace openshot diff --git a/src/effects/Tracker.cpp b/src/effects/Tracker.cpp index ebbdef47..bc9aff54 100644 --- a/src/effects/Tracker.cpp +++ b/src/effects/Tracker.cpp @@ -105,7 +105,9 @@ std::shared_ptr Tracker::GetFrame(std::shared_ptr frame, int64_t f if(!frame_image.empty()) { // Check if track data exists for the requested frame - if (trackedData->Contains(frame_number) && trackedData->visible.GetValue(frame_number) == 1) + if (trackedData->Contains(frame_number) && + trackedData->visible.GetValue(frame_number) == 1 && + trackedData->draw_box.GetValue(frame_number) == 1) { // Get the width and height of the image float fw = frame_image.size().width;