#NEWLINE# def detect_shots( self ) : #NEWLINE# #INDENT# if ( self . _webcam_frame is None ) : #NEWLINE# #INDENT# self . _window . after ( self . _preferences [ configurator . DETECTION_RATE ] , self . detect_shots ) #NEWLINE# return #NEWLINE# #UNINDENT# frame_bw = cv2 . cvtColor ( self . _webcam_frame , cv2 . cv . CV_BGR2GRAY ) #NEWLINE# ( thresh , frame_thresh ) = cv2 . threshold ( frame_bw , self . _preferences [ configurator . LASER_INTENSITY ] , 255 , cv2 . THRESH_BINARY ) #NEWLINE# if ( not self . _seen_interference ) : #NEWLINE# #INDENT# self . detect_interfence ( frame_thresh ) #NEWLINE# #UNINDENT# frame_height = len ( frame_thresh ) #NEWLINE# frame_width = len ( frame_thresh [ 0 ] ) #NEWLINE# sub_height = ( frame_height / 3 ) #NEWLINE# sub_width = ( frame_width / 3 ) #NEWLINE# for sub_y in range ( 0 , frame_height , sub_height ) : #NEWLINE# #INDENT# for sub_x in range ( 0 , frame_width , sub_width ) : #NEWLINE# #INDENT# min_max = cv2 . minMaxLoc ( frame_thresh [ sub_y : ( sub_y + sub_height ) , sub_x : ( sub_x + sub_width ) ] ) #NEWLINE# if ( min_max [ 0 ] != min_max [ 1 ] ) : #NEWLINE# #INDENT# x = ( min_max [ 3 ] [ 0 ] + sub_x ) #NEWLINE# y = ( min_max [ 3 ] [ 1 ] + sub_y ) #NEWLINE# laser_color = self . detect_laser_color ( x , y ) #NEWLINE# if ( ( laser_color is not None ) and ( self . _preferences [ configurator . IGNORE_LASER_COLOR ] not in laser_color ) ) : #NEWLINE# #INDENT# self . handle_shot ( laser_color , x , y ) #NEWLINE# #UNINDENT# #UNINDENT# #UNINDENT# #UNINDENT# if ( self . _shutdown == False ) : #NEWLINE# #INDENT# self . _window . after ( self . _preferences [ configurator . DETECTION_RATE ] , self . detect_shots )