Skip to content
Snippets Groups Projects
Commit 27e946b0 authored by Herman Andersen Dyrkorn's avatar Herman Andersen Dyrkorn
Browse files

restructure endpoint

parent b57a5d3b
Branches
No related tags found
1 merge request!23Resolve "debug and cleanup code"
...@@ -17,18 +17,20 @@ class FindSalamanderInfo(Resource): ...@@ -17,18 +17,20 @@ class FindSalamanderInfo(Resource):
return jsonify({"message": "no file given"}) return jsonify({"message": "no file given"})
image = request.files['image'] image = request.files['image']
user_id = get_jwt_identity() user_id = get_jwt_identity()
if image.filename != '':
if image and allowed_image(image.filename):
image.filename = str(user_id) + "." + extension(image.filename) image.filename = str(user_id) + "." + extension(image.filename)
image.save("temp_images/" + image.filename) image.save("temp_images/" + image.filename)
execution_path = os.path.abspath(os.getcwd()) execution_path = os.path.abspath(os.getcwd())
img = cv2.imread(execution_path + "/temp_images/" + str(user_id) + "." + extension(image.filename), 1) img = cv2.imread(execution_path + "/temp_images/" + str(user_id) + "." + extension(image.filename), 1)
if image.filename != '':
if image and allowed_image(image.filename):
# run AI on image # run AI on image
str_image, _, _, _, _ = straighten(img) str_image, _, _, _, _ = straighten(img)
if str_image is not None: if str_image is not None:
cv2.imwrite("temp_images/" + str(user_id) + "_str.png", str_image) cv2.imwrite("temp_images/" + str(user_id) + "_str.png", str_image)
# store processed and original image
return jsonify({"sex": "AI_sex", "species": "AI_species"}) return jsonify({"sex": "AI_sex", "species": "AI_species"})
else:
return jsonify({"message": "image could not be processed"})
else: else:
return jsonify({"message": "file extension not allowed"}) return jsonify({"message": "file extension not allowed"})
else: else:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment