21 lines
617 B
Python
21 lines
617 B
Python
import logging
|
|
|
|
import cv2
|
|
import requests
|
|
from tenacity import retry, stop_after_attempt, wait_random
|
|
|
|
|
|
@retry(stop=stop_after_attempt(3), wait=wait_random(1, 3), reraise=True,
|
|
after=lambda x: logging.warning('获取文档区域失败!'))
|
|
def request_book_areas(img_path):
|
|
url = 'http://det_api:5000/det/books'
|
|
response = requests.post(url, {'img_path': img_path})
|
|
if response.status_code == 200:
|
|
response_data = response.json()
|
|
books = []
|
|
for books_path in response_data:
|
|
books.append(cv2.imread(books_path))
|
|
return books
|
|
else:
|
|
return []
|