写一个车队根据车间距和速度运动的动画

写一个车队根据车间距和速度运动的动画

position = np.zeros(25)
def animate(i):
dis_i = dis_new[i]
v_i = v_data[i]
if i == 0:
print(dis_i)
#for d in dis_i:
position_current = 550 * 2
position_current -= dis_i
img = cv2.rectangle(img0.copy(), (int(position_current - 9), 300), (int(position_current), 303), (255, 255, 255))
else:
for j, v in enumerate(v_i):
position[j] = (v_data[i]*0.1)*2 + position
if position[j] > 1200:
position[j] = position[j] - 1200
img = cv2.rectangle(img, (int(position[j]-9), 300), (int(position[j]), 303), (255, 255, 255))

为什么报错了啊,怎么解决呢?

line 24, in animate
img = cv2.rectangle(img0.copy(), (int(position_current - 9), 300), (int(position_current), 303), (255, 255, 255))
TypeError: only size-1 arrays can be converted to Python scalars

这是类型错误