Compare commits
4 Commits
5da1ecb2e2
...
354d5fdbd5
Author | SHA1 | Date |
---|---|---|
Vladislav Moiseev | 354d5fdbd5 | 1 year ago |
Vladislav Moiseev | d70592fc64 | 1 year ago |
Vladislav Moiseev | 52335870fd | 1 year ago |
Vladislav Moiseev | b7c7f8e066 | 1 year ago |
Binary file not shown.
After Width: | Height: | Size: 13 KiB |
@ -1,36 +0,0 @@
|
|||||||
import base64
|
|
||||||
import cv2 as cv
|
|
||||||
from flask import Flask, redirect, request
|
|
||||||
import numpy
|
|
||||||
from imageWorking import get_image_buf_as_array
|
|
||||||
from main import analyze_base
|
|
||||||
|
|
||||||
app = Flask(__name__, static_url_path = "/")
|
|
||||||
|
|
||||||
@app.route("/")
|
|
||||||
def main():
|
|
||||||
return redirect('index.html')
|
|
||||||
|
|
||||||
@app.route("/analyze", methods=["POST"])
|
|
||||||
def analyze():
|
|
||||||
if 'image' not in request.files or request.files['image'].filename == '':
|
|
||||||
return {
|
|
||||||
'success': False,
|
|
||||||
'error': 'Укажите изображение',
|
|
||||||
}
|
|
||||||
if 'ontology' in request.files and request.files['ontology'].filename != '':
|
|
||||||
return {
|
|
||||||
'success': False,
|
|
||||||
'error': 'Загрузка онтологии ещё не реализована',
|
|
||||||
}
|
|
||||||
img = request.files['image'].read();
|
|
||||||
img = numpy.fromstring(img, numpy.uint8)
|
|
||||||
img = get_image_buf_as_array(img)
|
|
||||||
queries = [ 'QueryGetNotEmpty', 'QueryGetCheck', 'QueryGetEmpty' ]
|
|
||||||
results, response = analyze_base('5cc5570b-6ed9-3b33-9db4-bdb8ecb9f890', img, queries)
|
|
||||||
imencoded = cv.imencode(".jpg", results[0].plot())[1]
|
|
||||||
return {
|
|
||||||
'success': True,
|
|
||||||
'data': response,
|
|
||||||
'image': base64.b64encode(imencoded).decode("utf-8"),
|
|
||||||
}
|
|
Loading…
Reference in New Issue