Removing "ChildClipId" property, no longer used for attaching clips to tracker or object detection effects: Use clip->Parent to attach clips to tracked objects now.

This commit is contained in:
Jonathan Thomas
2024-02-26 16:45:30 -06:00
parent f15c91db90
commit 07e4458c03
5 changed files with 1 additions and 50 deletions

View File

@@ -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();
@@ -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"]);
@@ -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);

View File

@@ -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

View File

@@ -35,8 +35,6 @@ namespace openshot {
class TrackedObjectBase {
protected:
std::string id;
std::string childClipId;
ClipBase* parentClip;
public:
@@ -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 {}; };

View File

@@ -157,22 +157,6 @@ std::shared_ptr<Frame> ObjectDetection::GetFrame(std::shared_ptr<Frame> frame, i
painter.drawText(QPointF(left, top), label);
}
}
// 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);
}
}
}
}
}
}

View File

@@ -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);
}
// 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();
}