gpt4 book ai didi

python - cv2.矩形 : TypeError: Argument given by name ('thickness' ) and position (4)

转载 作者:太空宇宙 更新时间:2023-11-03 23:07:34 24 4
gpt4 key购买 nike

我正在尝试可视化图像顶部的边界框。

我的代码:

color = (255, 255, 0)
thickness = 4
x_min, y_min, x_max, y_max = bbox
cv2.rectangle(img, (x_min, y_min), (x_max, y_max), color, thickness=thickness)

我明白了TypeError:由名称(“厚度”)和位置 (4) 给出的参数即使我按位置传递厚度,我也会得到不同的回溯:

cv2.rectangle(img, (x_min, y_min), (x_max, y_max), color, thickness)

引发 TypeError: expected a tuple.

最佳答案

您需要确保您的边界坐标是整数。

x_min, y_min, x_max, y_max = map(int, bbox)
cv2.rectangle(img, (x_min, y_min), (x_max, y_max), color, thickness)

调用 cv2.rectangle 都可以。

关于python - cv2.矩形 : TypeError: Argument given by name ('thickness' ) and position (4),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56010872/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com