Beispiel #1
0
        ,('PH2RedBalls.jpg',((519,308,106),(1534,312,106))),('webcamVid1.jpg',((483,413,151),)))
    #correct_circles = (('PH2RedBalls.jpg',((519,308,106),(1534,312,106))),)
    #correct_circles = (('webcamVid1.jpg',((483,413,151),)),)
    circle_comparisons = []
    num_balls = 0 
    for file_name,measur_circle in correct_circles:
        #Keep track of the number of balls measured
        num_balls+= len(measur_circle)   
        
        image = InputOutput.get_image(file_name)
        InputOutput.display_image(image,"Starting Image")
 
        image_hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) # convert to HSV for thresholding
        image_hsv = cv2.blur(image_hsv, (9,9)) # blur to reduce noise
 
        thresh = ImageProcessing.thresholdRed(image_hsv)
        InputOutput.display_image(thresh,"Thresholded")
        thresh = ImageProcessing.removeNoise(thresh)
        
        calc_circles = ImageProcessing.reflectionDetection(thresh)
        
        #calc_circles = ImageProcessing.getBalls(thresh,4)
        if calc_circles == None:
            calc_circles = []
        #calc_circles = ImageProcessing.get_blob_centroid(image, thresh, 5)
         
        InputOutput.display_image_with_circles(image,"Result!",calc_circles)
        
        #evalueateSuccess by comparing the circle position with the most similar
        #red ball's measured circle.
        
Beispiel #2
0
    
    correct_circles = (('OnWater1.jpg',((520,312,100),)),('OnDeck.jpg',((731,416,106),))
        ,('TwoBalls.jpg',((519,308,106),(1534,312,106))))
    circle_comparisons = []
    num_balls = 0
    for file_name,measur_circle in correct_circles:
        #Keep track of the number of balls measured
        num_balls+= len(measur_circle)   
        
        image = InputOutput.get_image(file_name)
        InputOutput.display_image(image,"Starting Image")

        image_hsv = cv2.cvtColor(image, cv2.COLOR_BGR2HSV) # convert to HSV for thresholding
        image_hsv = cv2.blur(image_hsv, (9,9)) # blur to reduce noise
 
        thresh = ImageProcessing.thresholdRed(image_hsv)
        InputOutput.display_image(thresh,"Thresholded")
        thresh = ImageProcessing.removeNoise(thresh)    
    
        #calc_circles = ImageProcessing.houghTransform(thresh)
        calc_circles = ImageProcessing.blob_circle_detection(thresh)
        if calc_circles == None:
            calc_circles = []
        #calc_circles = ImageProcessing.get_blob_centroid(image, thresh, 5)
         
        InputOutput.display_image_with_circles(image,"Result!",calc_circles)
        
        #evalueateSuccess by comparing the circle position with the most similar
        #red ball's measured circle.
        
        #Print basic file facts