from SimpleCV import *
cam = Camera()
threshold = 5.0 # if mean exceeds this amount do something
while True:
previous = cam.getImage() #grab a frame
time.sleep(0.5) #wait for half a second
current = cam.getImage() #grab another frame
diff = current - previous
matrix = diff.getNumpy()
mean = matrix.mean()
diff.show()
if mean >= threshold:
print "Motion Detected"
我使用相机以每秒2幅图像的速度拍摄图像,持续10秒:
现在意味着每秒颜色积分密度在两帧内计算差异:(借助上面给出的代码)
平均差异出现(例如)在每秒一次后的30-40范围内:
times 0---1---2---3---4---5---6---7---8---9---10
calculated mean 38 40 39 32 40 35 39 40 38 38 37
现在我想实时绘制python中的图形来计算每60秒的位数