矫正扭曲和图片方向分类接口化

This commit is contained in:
2024-09-24 08:36:34 +08:00
parent 9c21152823
commit 90a6d5ec75
6 changed files with 105 additions and 22 deletions

View File

@@ -1,24 +1,23 @@
import os.path
import cv2
from flask import Flask, request, Blueprint
from flask import Flask, request
from paddle_detection import detector
from util import image_util
from util.common_util import process_request
app = Flask(__name__)
det_bp = Blueprint('det_bp', __name__)
@det_bp.route('/books', methods=['POST'])
@app.route('/det/books', methods=['POST'])
@process_request
def books():
img_path = request.form['img_path']
img_path = request.form.get('img_path')
image = cv2.imread(img_path)
result = detector.get_book_areas(image)
dirname = os.path.dirname(img_path)
img_name, ext = os.path.basename(img_path).rsplit('.', 1)
dirname, img_name, ext = image_util.parse_path(img_path)
books_path = []
for i in range(len(result)):
save_path = os.path.join(dirname, img_name + '_book_' + str(i) + '.' + ext)
@@ -27,7 +26,5 @@ def books():
return books_path
app.register_blueprint(det_bp, url_prefix='/det')
if __name__ == '__main__':
app.run('0.0.0.0', 5000)