Skip to content

Commit

Permalink
Removing "ChildClipId" property, no longer used for attaching clips t…
Browse files Browse the repository at this point in the history
…o tracker or object detection effects: Use clip->Parent to attach clips to tracked objects now.
  • Loading branch information
jonoomph committed Feb 26, 2024
1 parent f15c91d commit 07e4458
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 50 deletions.
9 changes: 0 additions & 9 deletions src/TrackedObjectBBox.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,6 @@ Json::Value TrackedObjectBBox::JsonValue() const
root["BaseFPS"]["num"] = BaseFps.num;
root["BaseFPS"]["den"] = BaseFps.den;
root["TimeScale"] = TimeScale;
root["child_clip_id"] = ChildClipId();

// Keyframe's properties
root["delta_x"] = delta_x.JsonValue();
Expand Down Expand Up @@ -379,11 +378,6 @@ void TrackedObjectBBox::SetJsonValue(const Json::Value root)
if (!root["protobuf_data_path"].isNull())
protobufDataPath = root["protobuf_data_path"].asString();

// Set the id of the child clip
if (!root["child_clip_id"].isNull() && root["child_clip_id"].asString() != Id()){
ChildClipId(root["child_clip_id"].asString());
}

// Set the Keyframes by the given JSON object
if (!root["delta_x"].isNull())
delta_x.SetJsonValue(root["delta_x"]);
Expand Down Expand Up @@ -425,9 +419,6 @@ Json::Value TrackedObjectBBox::PropertiesJSON(int64_t requested_frame) const
// 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 the ID of this object's child clip to the JSON object
root["child_clip_id"] = add_property_json("Child Clip ID", 0.0, "string", ChildClipId(), NULL, -1, -1, false, requested_frame);

// Add the data of given frame bounding-box to the JSON object
root["x1"] = add_property_json("X1", box.cx-(box.width/2), "float", "", NULL, 0.0, 1.0, true, requested_frame);
root["y1"] = add_property_json("Y1", box.cy-(box.height/2), "float", "", NULL, 0.0, 1.0, true, requested_frame);
Expand Down
2 changes: 1 addition & 1 deletion src/TrackedObjectBase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace openshot

// Constructor
TrackedObjectBase::TrackedObjectBase(std::string _id)
: visible(1.0), draw_box(1), id(_id), childClipId("") {}
: visible(1.0), draw_box(1), id(_id) {}

Json::Value TrackedObjectBase::add_property_choice_json(
std::string name, int value, int selected_value) const
Expand Down
5 changes: 0 additions & 5 deletions src/TrackedObjectBase.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,6 @@ namespace openshot {
class TrackedObjectBase {
protected:
std::string id;
std::string childClipId;

ClipBase* parentClip;

public:
Expand All @@ -60,9 +58,6 @@ namespace openshot {
/// Get and set the parentClip of this object
ClipBase* ParentClip() const { return parentClip; }
void ParentClip(ClipBase* clip) { parentClip = clip; }
/// Get and set the Id of the childClip of this object
std::string ChildClipId() const { return childClipId; };
void ChildClipId(std::string _childClipId) { childClipId = _childClipId; };

/// Check if there is data for the exact frame number
virtual bool ExactlyContains(int64_t frame_number) const { return {}; };
Expand Down
16 changes: 0 additions & 16 deletions src/effects/ObjectDetection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -157,22 +157,6 @@ std::shared_ptr<Frame> ObjectDetection::GetFrame(std::shared_ptr<Frame> frame, i
painter.drawText(QPointF(left, top), label);
}
}

Check warning on line 159 in src/effects/ObjectDetection.cpp

View check run for this annotation

Codecov / codecov/patch

src/effects/ObjectDetection.cpp#L157-L159

Added lines #L157 - L159 were not covered by tests

// Get the image of the Tracked Object' child clip
if (trackedObject->ChildClipId() != "") {
Timeline* parentTimeline = static_cast<Timeline *>(ParentTimeline());
if (parentTimeline) {
Clip* childClip = parentTimeline->GetClip(trackedObject->ChildClipId());
if (childClip) {
std::shared_ptr<Frame> childClipFrame = childClip->GetFrame(frame_number);
std::shared_ptr<QImage> childClipImage = childClipFrame->GetImage();

// Scale the original bounding box to this image
QRectF scaledRect = Tracker::scaleAndCenterRect(QRectF(childClipImage->rect()), boxRect);
painter.drawImage(scaledRect, *childClipImage);
}
}
}
}
}

Check warning on line 161 in src/effects/ObjectDetection.cpp

View check run for this annotation

Codecov / codecov/patch

src/effects/ObjectDetection.cpp#L161

Added line #L161 was not covered by tests
}
Expand Down
19 changes: 0 additions & 19 deletions src/effects/Tracker.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,25 +128,6 @@ std::shared_ptr<Frame> Tracker::GetFrame(std::shared_ptr<Frame> frame, int64_t f
painter.drawRoundedRect(boxRect, bg_corner, bg_corner);
}

Check warning on line 129 in src/effects/Tracker.cpp

View check run for this annotation

Codecov / codecov/patch

src/effects/Tracker.cpp#L128-L129

Added lines #L128 - L129 were not covered by tests

// Get the image of the Tracked Object' child clip
if (trackedData->ChildClipId() != ""){
// Cast the parent timeline of this effect
Timeline* parentTimeline = static_cast<Timeline *>(ParentTimeline());
if (parentTimeline){
// Get the Tracked Object's child clip
Clip* childClip = parentTimeline->GetClip(trackedData->ChildClipId());
if (childClip){
// Get the image of the child clip for this frame
std::shared_ptr<Frame> childClipFrame = childClip->GetFrame(frame_number);
std::shared_ptr<QImage> childClipImage = childClipFrame->GetImage();

// Scale the original bounding box to this image
QRectF scaledRect = scaleAndCenterRect(QRectF(childClipImage->rect()), boxRect);
painter.drawImage(scaledRect, *childClipImage);
}
}
}

painter.end();
}

Check warning on line 132 in src/effects/Tracker.cpp

View check run for this annotation

Codecov / codecov/patch

src/effects/Tracker.cpp#L131-L132

Added lines #L131 - L132 were not covered by tests

Expand Down

0 comments on commit 07e4458

Please sign in to comment.