Skip to content

Commit 7e419b9

Browse files
committed
Fixed Draw Box property in ObjectDetection Effect
1 parent 606dded commit 7e419b9

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

src/effects/ObjectDetection.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -146,13 +146,22 @@ std::shared_ptr<Frame> ObjectDetection::GetFrame(std::shared_ptr<Frame> frame, i
146146

147147
// DrawRectangleRGBA(cv_image, box, bg_rgba, bg_alpha, 1, true);
148148
// DrawRectangleRGBA(cv_image, box, stroke_rgba, stroke_alpha, stroke_width, false);
149-
149+
150+
150151
cv::Rect2d box(
151152
(int)( (trackedBox.cx-trackedBox.width/2)*fw),
152153
(int)( (trackedBox.cy-trackedBox.height/2)*fh),
153154
(int)( trackedBox.width*fw),
154155
(int)( trackedBox.height*fh)
155156
);
157+
158+
// If the Draw Box property is off, then make the box invisible
159+
if (trackedObject->draw_box.GetValue(frame_number) == 0)
160+
{
161+
bg_alpha = 1.0;
162+
stroke_alpha = 1.0;
163+
}
164+
156165
drawPred(detections.classIds.at(i), detections.confidences.at(i),
157166
box, cv_image, detections.objectIds.at(i), bg_rgba, bg_alpha, 1, true, draw_text);
158167
drawPred(detections.classIds.at(i), detections.confidences.at(i),
@@ -166,6 +175,7 @@ std::shared_ptr<Frame> ObjectDetection::GetFrame(std::shared_ptr<Frame> frame, i
166175
if (parentTimeline){
167176
// Get the Tracked Object's child clip
168177
Clip* childClip = parentTimeline->GetClip(trackedObject->ChildClipId());
178+
169179
if (childClip){
170180
std::shared_ptr<Frame> f(new Frame(1, frame->GetWidth(), frame->GetHeight(), "#00000000"));
171181
// Get the image of the child clip for this frame

0 commit comments

Comments
 (0)