-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrun.py
42 lines (30 loc) · 849 Bytes
/
run.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
#!/usr/bin/env python
from flask import Flask, jsonify, send_from_directory, request
from services.image_mask import HSV
import base64
import cv2
app = Flask(__name__)
hsv_object=None
@app.route('/')
def index():
return send_from_directory("templates", "index.html")
@app.route('/inputImage', methods=['POST'])
def inputImage():
content = dict(request.json)
print(content)
hsv_object= HSV(content['inputImage'])
global hsv_object
return "Uploaded"
@app.route('/sendHSV', methods=['POST'])
def sendHSV():
content = dict(request.json)
print(content)
global hsv_object
result=hsv_object.select_color(content)
_, buffer = cv2.imencode('.jpg', result)
jpg_as_text = base64.b64encode(buffer)
return jpg_as_text
if __name__ == '__main__':
app.debug = True
app.run()
print('Started')