我有以下代码给我错误。我试图更改if条件,但问题似乎出在其他地方。我将不胜感激。
if humanRegion_bbs and belongings_bbs :
x_left = max(humanRegion_bbs[0],belongings_bbs[0])
y_top = max(humanRegion_bbs[1],belongings_bbs[1])
x_right = min(humanRegion_bbs[2],belongings_bbs[2])
y_bottom = min(humanRegion_bbs[3],belongings_bbs[3])
回溯:
Traceback (most recent call last):
File "/home/prashant/anaconda3/envs/vaak_p36/lib/python3.6/multiprocessing/process.py", line 258, in _bootstrap
self.run()
File "/home/prashant/anaconda3/envs/vaak_p36/lib/python3.6/multiprocessing/process.py", line 93, in run
self._target(*self._args, **self._kwargs)
File "appMulti.py", line 677, in worker_processCamera
oneObject.setBelongings(image,humanRegion_bbs,belongings_bbs)
File "./deepPose/tracking.py", line 648, in setBelongings
x_left = max(humanRegion_bbs[0],belongings_bbs[0])
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
我希望humanRegion_bbs和所有物_bbs都是一些数字。是因为其他一些代码行吗?
答案 0 :(得分:1)
如果您希望列表中至少包含一个非零元素,则应使用any()
:
if any(humanRegion_bbs) and any(belongings_bbs):