gpt4 book ai didi

带有点列表的python boundingRect

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

尝试在 opencv 中使用 boundingRect() 函数时出现错误。给出的是点列表

lists = []
for match in enumerate(matches):
lists.append(kp2[match.trainIdx].pt)
x,y,w,h = cv2.boundingRect(lists)

TypeError: points is not a numpy array, neither a scalar

P/s:我想在图像中检测到的物体周围画一个矩形

感谢任何帮助

编辑

更改为 np 数组之前的列表

[(328.0, 227.0), (372.0, 241.0), (366.0, 229.0)]

及之后

[[ 328. 227.]
[372. 241.]
[ 366. 229.]]

最佳答案

我刚刚遇到了完全相同的问题。没有解决它,但这里是解决问题的代码:

points = ([1,1], [3,1], [3,3], [1,4])

xx, yy = zip(*points)
min_x = min(xx); min_y = min(yy); max_x = max(xx); max_y = max(yy)
bbox = [(min_x, min_y), (max_x, min_y), (max_x, max_y), (min_x, max_y)]

关于带有点列表的python boundingRect,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37041008/

24 4 0
文章推荐: c# - 将派生类的方法重构为公共(public)基类的方法? (C#)
文章推荐: Javascript 在 alert() 之前和之后显示
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com