Drag & Drop your curve image here
or
Drag & Drop your curve image here
or
import requests
import base64
import cv2
import numpy as np
src_path = "./test_input.jpg"
xlsx_path = './result.xlsx'
mask_img_path = './mask.png'
verify_img_path = './verify.png'
url = "https://docmind.tech/process_chart"
filename = src_path.split("/")[-1]
fn_postfix = filename.split(".")[-1]
# Send request
with open(src_path, "rb") as f:
img_data = f.read()
files = {'image': (filename, img_data, f'image/{fn_postfix}')}
response = requests.post(url, files=files, verify=False, data={"skip_hd": "false"})
if response.status_code == 200:
data = response.json()
# Save verify image
if data['mask_img'] is not None:
img_bytes = base64.b64decode(data['mask_img'])
nparr = np.frombuffer(img_bytes, np.uint8)
mask_img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
cv2.imwrite(mask_img_path, mask_img) # 曲线mask
verify_img_bytes = base64.b64decode(data['verify_img'])
nparr = np.frombuffer(verify_img_bytes, np.uint8)
verify_img = cv2.imdecode(nparr, cv2.IMREAD_COLOR)
cv2.imwrite(verify_img_path, verify_img) # 重建后的曲线图
xlsx_base64 = data['xlsx_binary']
xlsx_binary = base64.b64decode(xlsx_base64)
with open(xlsx_path, 'wb') as f: # 曲线图数据
f.write(xlsx_binary)
print(f"Success: {response.status_code}")
else:
print(f"Error: {response.status_code}")
print(f"response: {response}")
print(response.json())