这是我的代码:
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: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()为什么会出现这个错误,但在我的情况下,我不知道如何处理这个错误。任何帮助将不胜感激!
答案 0 :(得分:0)
ts
或img
是一个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()