#NEWLINE# def main( ) : #NEWLINE# #INDENT# scale_amount = ( 200 , 150 ) #NEWLINE# d = Display ( scale_amount ) #NEWLINE# cam = Camera ( 0 ) #NEWLINE# prev = cam . getImage ( ) . scale ( scale_amount [ 0 ] , scale_amount [ 1 ] ) #NEWLINE# time . sleep ( 0.5 ) #NEWLINE# t = 0.5 #NEWLINE# buffer = 20 #NEWLINE# count = 0 #NEWLINE# while d . isNotDone ( ) : #NEWLINE# #INDENT# current = cam . getImage ( ) #NEWLINE# current = current . scale ( t [ 0 ] , scale_amount [ 1 ] ) #NEWLINE# if ( count < buffer ) : #NEWLINE# #INDENT# count = ( count + 1 ) #NEWLINE# #UNINDENT# else : #NEWLINE# #INDENT# fs = current . findMotion ( prev , window = 15 , method = 'BM' ) #NEWLINE# lengthOfFs = len ( fs ) #NEWLINE# if fs : #NEWLINE# #INDENT# dx = 0 #NEWLINE# dy = 0 #NEWLINE# for f in fs : #NEWLINE# #INDENT# dx = ( dx + f . dx ) #NEWLINE# dy = ( dy + f . dy ) #NEWLINE# #UNINDENT# dx = ( dx / lengthOfFs ) #NEWLINE# dy = ( dy / lengthOfFs ) #NEWLINE# motionStr = movement_check ( dx , dy , t ) #NEWLINE# current . drawText ( motionStr , 10 , 10 ) #NEWLINE# #UNINDENT# #UNINDENT# prev = current #NEWLINE# time . sleep ( 0.01 ) #NEWLINE# current . save ( d )