def main():
    # prediction = ocr.predict();
    # ocr = LiteOCR(fn="app/model/alpha_weights.pkl")
    ocr = LiteOCR()
    pp = img_prep(fn="dataset.txt")

    # n is an array of pixel values between -2 and 2 I think
    if (len(sys.argv) < 2):
        print "Must enter an image name.. temp0.jpg is T"
        exit(1)

    image = sys.argv[1]
    n = pp.preprocess(image)
    char_prediction = ocr.predict(n)

    print char_prediction
Esempio n. 2
0
def do_ocr():
	app.logger.debug("Accessed _do_ocr page with image data")
	# flash('Just hit the _add_numbers function')
	# a = json.loads(request.args.get('a', 0, type=str))
	data = request.args.get('imgURI', 0, type=str)
	app.logger.debug("Data looks like " + data)
	index = request.args.get('index', 0, type=int)
	vocab = json.loads(request.args.get('vocab',0,type=str))

	pp = img_prep(fn="dataset.txt")
	ocr = LiteOCR(fn="app/model/alpha_weights.pkl")
	char_prediction= ocr.predict(pp.preprocess(data))

	result = "You entered a: " + char_prediction
	app.logger.debug("Recognized a character")
	return jsonify(result=result)
def do_ocr():
	"""Add two numbers server side, ridiculous but well..."""
	app.logger.debug("Accessed _do_ocr page with image data")
	# flash('Just hit the _add_numbers function')
	# a = json.loads(request.args.get('a', 0, type=str))
	data = request.args.get('imgURI', 0, type=str)
	app.logger.debug("Data looks like " + data)
	index = request.args.get('index', 0, type=int)
	vocab = json.loads(request.args.get('vocab',0,type=str))

	pp = img_prep(fn="dataset.txt")
	ocr = LiteOCR(fn="app/model/alpha_weights.pkl")
	char_prediction= ocr.predict(pp.preprocess(data))

	result = "You entered a: " + char_prediction

	app.logger.debug("Recognized a character")
	return jsonify(result=result)