From 7e419b9d6458d3e489104049f76dd7658bfe3391 Mon Sep 17 00:00:00 2001 From: Brenno Date: Tue, 10 Aug 2021 15:03:01 -0300 Subject: [PATCH] Fixed Draw Box property in ObjectDetection Effect --- src/effects/ObjectDetection.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/effects/ObjectDetection.cpp b/src/effects/ObjectDetection.cpp index 130934757..b279a6fcb 100644 --- a/src/effects/ObjectDetection.cpp +++ b/src/effects/ObjectDetection.cpp @@ -146,13 +146,22 @@ std::shared_ptr ObjectDetection::GetFrame(std::shared_ptr frame, i // DrawRectangleRGBA(cv_image, box, bg_rgba, bg_alpha, 1, true); // DrawRectangleRGBA(cv_image, box, stroke_rgba, stroke_alpha, stroke_width, false); - + + cv::Rect2d box( (int)( (trackedBox.cx-trackedBox.width/2)*fw), (int)( (trackedBox.cy-trackedBox.height/2)*fh), (int)( trackedBox.width*fw), (int)( trackedBox.height*fh) ); + + // If the Draw Box property is off, then make the box invisible + if (trackedObject->draw_box.GetValue(frame_number) == 0) + { + bg_alpha = 1.0; + stroke_alpha = 1.0; + } + drawPred(detections.classIds.at(i), detections.confidences.at(i), box, cv_image, detections.objectIds.at(i), bg_rgba, bg_alpha, 1, true, draw_text); drawPred(detections.classIds.at(i), detections.confidences.at(i), @@ -166,6 +175,7 @@ std::shared_ptr ObjectDetection::GetFrame(std::shared_ptr frame, i if (parentTimeline){ // Get the Tracked Object's child clip Clip* childClip = parentTimeline->GetClip(trackedObject->ChildClipId()); + if (childClip){ std::shared_ptr f(new Frame(1, frame->GetWidth(), frame->GetHeight(), "#00000000")); // Get the image of the child clip for this frame