-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapp.py
68 lines (45 loc) · 1.66 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
from flask import *
import os
import pandas as pd
import json
from werkzeug.utils import secure_filename
import sys
import unpack
import card_detection
import cv2 as cv
import Card_Predictor
import gamelogic
ALLOWED_EXTENSIONS = set(['png', 'jpg', 'jpeg', 'gif'])
folderpath = 'static/images/cropped'
result = []
app = Flask(__name__)
app.config['UPLOAD_FOLDER'] = 'static/images/Original'
def allowed_file(filename):
return '.' in filename and \
filename.rsplit('.', 1)[1].lower() in ALLOWED_EXTENSIONS
@app.route('/', methods=['GET', 'POST'])
def upload_file():
if request.method == 'POST':
if request.files.get('file'):
file= request.files['file']
file.save(os.path.join(app.config['UPLOAD_FOLDER'], "original.jpg"))
numcards = 12
card_detection.Imagedetection("static/images/Original/original.jpg",numcards)
cards= Card_Predictor.prediction_tuples()
board = unpack.unpack_result(cards)
foundSet = gamelogic.findSet(board)
result.append(foundSet)
return redirect('results')
return render_template("index.html")
@app.route('/results')
def ending():
card_predictions = Card_Predictor.prediction_tuples()
folderpath = 'static/images/cropped'
images = Card_Predictor.find_cropped_images(folderpath)
dictionary = {'card_predictions':card_predictions, 'images':images}
return render_template('results.html', card_predictions = card_predictions, images= images)
@app.route("/fakedata")
def fakedata():
return jsonify(result)
if __name__ == '__main__':
app.run(debug=True)