1

这是我的代码:

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

这是我得到的错误:

  if not ts and not img:
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()

虽然我从这里了解ValueError:具有多个元素的数组的真值是不明确的。使用 a.any() 或 a.all()为什么会出现此错误,我不知道在我的情况下如何处理此错误。任何帮助将不胜感激!

4

1 回答 1

0

要么 要么tsimg一个numpy数组......因此它不知道是什么not <numpy.array>意思

你可能想要if len(ts) > 0 and len(img) > 0 ,或者也许if ts is not None或者类似的东西

>>> 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()
于 2014-05-15T19:00:53.973 回答