问题描述
下面是我程序的部分代码,其中,如果red_dir和blue_dir的要求都不为空,则该程序仅应进入函数内部
from collections import deque
import numpy as np
red_direction=deque(maxlen=1)
blue_direction=deque(maxlen=1)
def is_collision(red_dir,blue_dir,pr,pb,S2,S5,SWitch_pos_2,SWitch_pos_5):
#checks if both direction are not empty
if red_dir and blue_dir:
if red_dir[0]!=blue_dir[0]and np.abs(WP_r[0][0][0]-WP_b[0][0][0])>3:
cv2.putText(img_dst,"ptential collision",(1204,417),cv2.FONT_HERShey_SIMPLEX,0.55,(0,255,255),1)
if red_dir[0]!=blue_dir[0] :
if np.abs(pr[0][0][0]-SWitch_pos_2[0][0])<0.2 and np.abs(pb[0][0][0]-SWitch_pos_5[0][0])<0.2:
if S2!=S5:
cv2.putText(img_dst,"collision",1)
cv2.waitKey(1000)
#calling the function
is_collision(red_direction,blue_direction,WP_r,WP_b,SW2,SW5,s2_p,s5_p)
在前30帧中,red_direction和blue方向为空,因此我进行了一项健全性检查,并打印了其中一个: 打印(红色方向) 双端队列([],maxlen = 1) 双端队列([],maxlen = 1) deque([''],maxlen = 1) deque([''],maxlen = 1)
问题在于,当我调用该函数时,它会立即进入if red_dir and blue_dir:
,尽管它的开头是空的!
deque([],maxlen=1)
意味着它不为空吗?
预先感谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)