Python:ValueError:具有多个元素的数组的真值不明确。使用a.any()或a.all()

2024-10-01 22:38:50 发布

您现在位置:Python中文网/ 问答频道 /正文

这是我的代码:

for ts, blob in izip(ts_list, blobs):
    ts = simplecvimg.track("camshift", i, fgmask,b.boundingBox())
    print(ts)

以下是我得到的错误:

^{pr2}$

{我不知道在这种情况下我为什么会犯错误。任何帮助都将不胜感激!在


Tags: 代码infor错误trackbloblistprint
1条回答
网友
1楼 · 发布于 2024-10-01 22:38:50

ts或{}是numpy数组。。。因此,它不知道not <numpy.array>是什么意思

你可能想要if len(ts) > 0 and len(img) > 0,或者{}或者类似的东西

>>> import numpy
>>> not numpy.array([1,2,3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ValueError: The truth value of an array with more than one element is ambiguous.
 Use a.any() or a.all()

相关问题 更多 >

    热门问题