如何仅在整个对象完全在感兴趣区域内后才放置边界框?

How to put bounding box only after the entire object is completely within region of interest?

This is the image i get..

我已经将红线的左侧垂直设置为感兴趣区域。训练了一个模型来检测车牌,其中框包含 ROI 内检测到的对象坐标。边界框甚至在整个对象进入感兴趣区域内之前就出现了。我希望边界框仅在整个对象位于 ROI 内后出现。这是我的边界框代码。

            x, y, w, h = boxes1[i]
            label = ""
            color = (0, 0, 255)
            cv2.rectangle(frame, (x, y), (x + w, y + h), color, 2)

仅当x + w位于红线左侧时才绘制矩形。

red_line_x = 200    # for example
x, y, w, h = boxes1[i]
if (x + w) < red_line_x:
    color = (0, 0, 255)
    cv2.rectangle(frame, (x, y), (x + w, y + h), color, 2)