我尝试使用simpleCV,得到了一个开源代码,通过简单的修改我能够写下能够检测到闪烁的代码(在图像的特定位置出现一个小的变化并且消失了)。现在我想计算每分钟的闪烁并想要绘制实时图表。我看到一些代码和项目那些使用傅立叶变换进行这种工作,但无法在我的项目中实现,我终于落在这里请提前帮助我感谢:
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"
答案 0 :(得分:0)
您已拥有所需的一切。 由于你在一个固定的intervall上测量的睡眠(让我们称之为timeStep)。 您只需要将“闪烁”与每次循环迭代时递增的计数一起保存。两个闪烁之间的计时器是:
deltaT = abs(blink1.count - blink2.count)*timeStep
要获得每分钟闪烁,您可以简单地计算现在(当前计数)和现在 - 1分钟(每分钟计数= 60 / timeStep,如果timeStep,以秒为单位)出现的闪烁
bpm = sum(blinkcounts[now-minute:now])
请注意,本答案中的所有代码均为Pseudcode,只应显示Ideas而非完整解决方案。