如何在 Python 中按百分比放大边界框
如果我们有边界框 (xmin, xmax, ymin, ymax),我们可以使用以下算法在每侧调整边界框大小例如 15%:
resize_bbox.py
xmin -= 0.15 * (xmax - xmin)
xmax += 0.15 * (xmax - xmin)
ymin -= 0.15 * (ymax - ymin)
ymax += 0.15 * (ymax - ymin)注意这将在每侧调整边界框大小 15%(=0.15),即结果边界框的总宽度将大 15% * 2 = 30%!
为什么有效
resize_bbox_snippet.py
xmin -= 0.15 * (xmax - xmin)等同于
resize_bbox_explanation.py
xmin -= 0.15 * [width of the bounding box]Check out similar posts by category:
Python
If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow