我有以下代码,该代码给了我错误。我尝试更改 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 都是一些数字。是因为其他几行代码吗?
最佳答案
如果您希望列表至少有一个非零元素,则应使用 any()
:
if any(humanRegion_bbs) and any(belongings_bbs):
关于python - 如何解决ValueError?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53512836/