用树莓派写了个判断遮挡的程序,然后背景在未被遮挡时进行实时更新,
现在会出现程序在已经被判断为遮挡的情况下更新,求解是什么问题。
代码如下:
contours, hierarchy = cv2.findContours(diff.copy(), cv2.RETR_EXTERNAL, cv2.CHAIN_APPROX_SIMPLE)
for c in contours:
if cv2.contourArea(c) < 15000:
if cv2.contourArea(c) < 100:
print(time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime()) + '更新完毕')
cv2.accumulateWeighted(gray, background, 0.5)
continue
else:
print(time.strftime("%Y-%m-%d-%H:%M:%S", time.localtime()) + '被遮挡')
现在就是本来应该在contourArea 小于 100时才会更新,但是现在会出现>15000的时候进行更新