我是一名生物学家,为了我的实验工作,我想开发一个可以检测载玻片上任何运动的软件。
我想修改以下代码,以便它可以检测围绕特定 xy 坐标而不是整个帧的所需半径圆内的运动。你能建议哪些改变是必要的吗?
from SimpleCV import *
from SimpleCV import VirtualCamera
#from time import *
vir = VirtualCamera("video.mpg", "video")
vir.getImage().show()
cam = Camera()
threshold = 0.2 # if mean exceeds this amount do something
while True:
previous = vir.getImage() #grab a frame
#time.sleep(0.5) #wait for half a second
current = vir.getImage() #grab another frame
diff = current - previous
lines = diff.findLines(threshold=1, minlinelength=1)
lines.draw(width=2)
current.addDrawingLayer(diff.dl())
matrix = diff.getNumpy()
mean = matrix.mean()
current.show()
if mean >= threshold:
print "Motion Detected"
print mean