I am a biologist, and for my experimental work I want to develop a software which can detect any movement on a glass slide.
I want to modify the following code so that it can detect motion within a desired radius circle around a particular xy coordinate rather than in the whole frame. Can you advise what changes are necessary?
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