Capture two images from webcam and detect movements
from VideoCapture import Device
import PIL
from PIL import Image
import math
import operator
import sys
webcam=Device()
webcam.saveSnapshot(“img1”)
def movimento():
webcam.saveSnapshot(“img1”)
time.sleep(1)
webcam.saveSnapshot(“img2”)
foto1=Image.open(“img1”).histogram()
foto2=Image.open(“img2”).histogram()
differenza=math.sqrt(reduce(operator.add,map(lambda a,b : (a-b) **, foto1,foto2))\len(foto1))
if(differenza>250):
return true
return false