from collections import deque
import numpy as np
import argparse, imutils, cv2, pygame, time

pygame.init()

display_width = 600
display_height = 450

black = (0,0,0)
white = (255,255,255)

finished = False

objectLower = (0, 112, 208)
objectUpper = (19, 255, 255)

gameDisplay = pygame.display.set_mode((display_width, display_height))
pygame.display.set_caption('Object Tracker')
gameDisplay.fill(white)
pygame.display.update()

camera = cv2.VideoCapture(0)

while not finished:
        (grabbed, frame) = camera.read()

        frame = imutils.resize(frame, width=600)
        # blurred = cv2.GaussianBlur(frame, (11, 11), 0)
        hsv = cv2.cvtColor(frame, cv2.COLOR_BGR2HSV)

        mask = cv2.inRange(hsv, objectLower, objectUpper)
        mask = cv2.erode(mask, None, iterations=2)
        mask = cv2.dilate(mask, None, iterations=2)

        # find contours in the mask and initialize the current
        # (x, y) center of the object
        cnts = cv2.findContours(mask.copy(), cv2.RETR_EXTERNAL,
                cv2.CHAIN_APPROX_SIMPLE)[-2]
        if len(cnts) > 0:
                c = max(cnts, key=cv2.contourArea)
                ((x, y), radius) = cv2.minEnclosingCircle(c)
                if radius > 10:
                        # draw the circle and centroid on the frame,
                        cv2.circle(frame, (int(x), int(y)), int(radius),
                                (0, 255, 255), 2)
                        # print int(x), int(y)
                        # centroid:
                        # cv2.circle(frame, center, 5, (0, 0, 255), -1)

        # show the frame to our screen
        cv2.imshow("Frame", frame)
        # key = cv2.waitKey(1) & 0xFF

        for event in pygame.event.get():
            if event.type == pygame.QUIT:
                    finished = True
        gameDisplay.fill(white)
        try:
            pygame.draw.circle(gameDisplay,black,(int(x),int(y)),10)
        except:
            pass
        pygame.display.update()

camera.release()
cv2.destroyAllWindows()

@@ -23,16 +23,44 @@
 t deque%0A
+from pygame.locals import *%0A
 import n
@@ -128,16 +128,88 @@
 e.init()
+%0Apygame.mixer.init()%0A%0Asound_shot = pygame.mixer.Sound('audio%5C%5Cshot.ogg')
 %0A%0Adispla
@@ -574,20 +574,16 @@
 nished:%0A
-    
     (gra
@@ -612,20 +612,16 @@
 read()%0A%0A
-    
     fram
@@ -661,20 +661,16 @@
 00)%0A    
-  
-  
 # blurre
@@ -714,20 +714,16 @@
  0)%0A    
-   
- 
 hsv = cv
@@ -760,28 +760,24 @@
 R2HSV)%0A%0A    
-   
- 
 mask = cv2.i
@@ -814,20 +814,16 @@
 tUpper)%0A
-    
     mask
@@ -861,20 +861,16 @@
 ions=2)%0A
-    
     mask
@@ -914,20 +914,16 @@
 2)%0A%0A    
- 
-   
 # find c
@@ -969,20 +969,16 @@
 current%0A
-    
     # (x
@@ -1007,20 +1007,16 @@
 ect%0A    
-  
-  
 cnts = c
@@ -1062,32 +1062,16 @@
 XTERNAL,
-%0A               
  cv2.CHA
@@ -1096,20 +1096,16 @@
 -2%5D%0A    
- 
-   
 if len(c
@@ -1114,24 +1114,16 @@
 s) %3E 0:%0A
-        
         
@@ -1165,24 +1165,16 @@
         
-       
- 
 ((x, y),
@@ -1210,24 +1210,16 @@
 rcle(c)%0A
-        
         
@@ -1246,28 +1246,16 @@
         
-          
-  
 # draw t
@@ -1303,28 +1303,16 @@
         
-       
-     
 cv2.circ
@@ -1355,40 +1355,8 @@
 us),
-%0A                               
  (0,
@@ -1382,28 +1382,16 @@
         
-         
-   
 # print 
@@ -1405,28 +1405,16 @@
  int(y)%0A
-            
         
@@ -1441,28 +1441,16 @@
         
-    
-        
 # cv2.ci
@@ -1489,25 +1489,20 @@
 5), -1)%0A
-%0A 
     
-   
 # show t
@@ -1524,28 +1524,24 @@
  screen%0A    
-  
-  
 cv2.imshow(%22
@@ -1559,20 +1559,16 @@
 me)%0A    
-  
-  
 # key = 
@@ -1594,20 +1594,16 @@
 FF%0A%0A    
-   
- 
 for even
@@ -1627,20 +1627,16 @@
 .get():%0A
-    
         
@@ -1677,24 +1677,16 @@
         
-        
 finished
@@ -1693,24 +1693,97 @@
  = True%0A    
+    if event.type == pygame.MOUSEBUTTONUP:%0A            sound_shot.play()%0A
     gameDisp
@@ -1806,21 +1806,13 @@
     
-  
-  
 try:%0A
-    
     
@@ -1872,20 +1872,16 @@
 y)),10)%0A
-    
     exce
@@ -1896,21 +1896,13 @@
     
-  
-  
 pass%0A
-    
     

set indents to pep-8