Exemplo n.º 1
0
def myMain():
    pics = '/Users/seandoyle/git/AndromedaVision/WPIPics'
    myTarget = createSampleTarget() 

    for filename in os.listdir(pics):
        fullFileName = os.path.join(pics, filename)
        image = cv2.imread(fullFileName)
        
        boundingBoxesOfTargetCandidates = []
        normalImageDebugger = ImageDebugger(image, boundingBoxesOfTargetCandidates, "Normal Image")
        normalImageDebugger.displayImage()
        
        colorFilter = Color(myTarget.hSV, image)
        hSVFilteredImage = colorFilter.run()
        hSVFilteredImageDebugger = ImageDebugger(hSVFilteredImage, boundingBoxesOfTargetCandidates, "HSV")
        hSVFilteredImageDebugger.displayImage()

        contourFilter = Contours(myTarget.numberOfContours, hSVFilteredImage)
        boundingBoxesOfTargetCandidates = contourFilter.run()
        contourFilterDebugger = ImageDebugger(image, boundingBoxesOfTargetCandidates, "Contour")
        contourFilterDebugger.displayImageWithBoundingBoxes()

        sizeFilter = Size(myTarget.size, boundingBoxesOfTargetCandidates)
        boundingBoxesOfTargetCandidates = sizeFilter.run()
        sizeFilterDebugger = ImageDebugger(image, boundingBoxesOfTargetCandidates, "Size")
        sizeFilterDebugger.displayImageWithBoundingBoxes()

        lengthToWidthRatioFilter = LengthToWidthRatio(myTarget.lengthToWidthRatio, boundingBoxesOfTargetCandidates)
        boundingBoxesOfTargetCandidates = lengthToWidthRatioFilter.run()
        lengthToWidthRatioDebugger = ImageDebugger(image, boundingBoxesOfTargetCandidates, "LengthToWidth")
        lengthToWidthRatioDebugger.displayImageWithBoundingBoxes()

        percentWhitePixelsFilter = PercentWhitePixels(myTarget.percentWhitePixels, boundingBoxesOfTargetCandidates, hSVFilteredImage)
        boundingBoxesOfTargetCandidates = percentWhitePixelsFilter.run()
        percentWhitePixelsDebugger = ImageDebugger(hSVFilteredImage, boundingBoxesOfTargetCandidates, "percentWhitePixels")
        percentWhitePixelsDebugger.displayImageWithBoundingBoxes()