Files
fcb_photo_review/services/paddle_services/det_book.py

32 lines
778 B
Python

import logging.config
import os.path
import cv2
from flask import Flask, request
from log import LOGGING_CONFIG
from paddle_detection import detector
from utils import process_request, parse_img_path
app = Flask(__name__)
@app.route('/', methods=['POST'])
@process_request
def main():
img_path = request.form.get('img_path')
result = detector.get_book_areas(img_path)
dirname, img_name, ext = parse_img_path(img_path)
books_path = []
for i in range(len(result)):
save_path = os.path.join(dirname, img_name + '_book_' + str(i) + '.' + ext)
cv2.imwrite(save_path, result[i])
books_path.append(save_path)
return books_path
if __name__ == '__main__':
logging.config.dictConfig(LOGGING_CONFIG)
app.run('0.0.0.0', 5006)