Ejemplo n.º 1
0
def main(which, debug=True):
    with(open('settings.yml')) as f:
        settings = yaml.load(f)

    clf = pickle.load(open('classifier.pickle'))
    
    img = capture_image()
    
    prediction, binarized_img, chars = predict(clf, img=img,
         boundaries=settings['crop'][which])
     
    
    if debug:
        pp.gray()        
        pp.subplot(2,1,1)
        pp.title('Prediction: %s' % prediction, fontsize='xx-large')
        pp.imshow(binarized_img)
        for i in range(6):
            pp.subplot(2,6,7+i)
            pp.imshow(chars[i])
        pp.show()

    print prediction
Ejemplo n.º 2
0
    settings = yaml.load(f)


class ValidationError(Exception):
    pass


def validate_user(username, password):
    if settings["users"][username] != password:
        raise ValidationError()


@app.route("/<int:token_id>", methods=["POST"])
def index(token_id):
    try:
        username = request.values["username"]
        password = request.values["password"]
        validate_user(username, password)
        boundaries = settings["crop"][token_id]
    except KeyError, ValidationError:
        abort(401)

    img = capture_image()
    prediction, binarized_img, chars = predict(clf, img=img, boundaries=boundaries)

    return jsonify({"prediction": prediction})


if __name__ == "__main__":
    app.run(debug=True)
Ejemplo n.º 3
0
SIZE = WIDTH, HEIGHT = 1150, 550
#SIZE = WIDTH, HEIGHT = 1650,900
#for kyle's tv
#size = width, height = 1200,900
CONTROL_BOARD_WIDTH = int(WIDTH / 4.4)

# Initialize Gameboard
GameBoard = classes.Zones(5, WIDTH, HEIGHT, CONTROL_BOARD_WIDTH, BOARD_SIZE)
logging.info('GameBoard generated')

# Initialize PyGame
pygame.init()
screen = pygame.display.set_mode((GameBoard.width, GameBoard.height))

# shows you what the camera's view is and lets you readjust before moving on with program
cam.capture_image('whatCameraSees.jpg')
inpu = input('Are you ready to begin calibration?')
while 1:
    if inpu == 'n' or inpu == 'N':
        cam.capture_image('whatCameraSees.jpg')
        inpu = input('Howabout now...?')
    else:
        break

#-------------------------------------------------------------#
#CALIBRATE GAMEBOARD COLOUR DOT CALIBRATION LOCATIONS & COLOURS
#-------------------------------------------------------------#
if CALIBRATE_COLOUR_LOCATIONS:
    calibrate.calibrate_gameboard_dots(GameBoard,
                                       screen,
                                       pygame.display.flip,