note/数学图谱后端接口定义.md

418 lines
12 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

## 外部接口
### 1. 分割试卷API:
请求:
```bash
curl --location --request POST 'https://ekt1.suzhou.edu.cn/autocut/detect' \
--header 'Accept: */*' \
--header 'Host: ekt1.suzhou.edu.cn' \
--header 'Connection: keep-alive' \
--header 'Content-Type: multipart/form-data; boundary=--------------------------687058231513459413708701' \
--form 'image=@"/Users/robertmaxwell/code/zstp/AutoCut/pic.png"' \
--form 'enable_error_detection="false"'
```
返回:
```json
{
"data": {
"crop_results": {
"cropped_count": 14,
"cropped_images": [
{
"bbox": [
970,
69,
1909,
246
],
"filename": "question_001.jpg",
"question_id": 1,
"vertical_id": 1
},
{
"bbox": [
41,
107,
970,
253
],
"filename": "question_002.jpg",
"question_id": 2,
"vertical_id": 2
},
{
"bbox": [
970,
245,
1909,
479
],
"filename": "question_003.jpg",
"question_id": 3,
"vertical_id": 3
},
{
"bbox": [
41,
254,
970,
394
],
"filename": "question_004.jpg",
"question_id": 4,
"vertical_id": 4
},
{
"bbox": [
41,
395,
970,
506
],
"filename": "question_005.jpg",
"question_id": 5,
"vertical_id": 5
},
{
"bbox": [
970,
480,
1909,
661
],
"filename": "question_006.jpg",
"question_id": 6,
"vertical_id": 6
},
{
"bbox": [
41,
507,
970,
655
],
"filename": "question_007.jpg",
"question_id": 7,
"vertical_id": 7
},
{
"bbox": [
41,
656,
970,
820
],
"filename": "question_008.jpg",
"question_id": 8,
"vertical_id": 8
},
{
"bbox": [
970,
662,
1909,
904
],
"filename": "question_009.jpg",
"question_id": 9,
"vertical_id": 9
},
{
"bbox": [
41,
821,
970,
968
],
"filename": "question_010.jpg",
"question_id": 10,
"vertical_id": 10
},
{
"bbox": [
970,
905,
1909,
1183
],
"filename": "question_011.jpg",
"question_id": 11,
"vertical_id": 11
},
{
"bbox": [
41,
969,
970,
1111
],
"filename": "question_012.jpg",
"question_id": 12,
"vertical_id": 12
},
{
"bbox": [
41,
1112,
970,
1364
],
"filename": "question_013.jpg",
"question_id": 13,
"vertical_id": 13
},
{
"bbox": [
970,
1184,
1909,
1364
],
"filename": "question_014.jpg",
"question_id": 14,
"vertical_id": 14
}
],
"mode": "all_questions",
"zip_url": "/download/20251125_082929_f1975f5c"
},
"error_count": 8,
"error_details": [
{
"error_boxes": [
{
"bbox": [
1772,
678,
44,
44
],
"class_name": "cuo",
"confidence": 0.7618222236633301
}
],
"match_method": "中心点包含",
"question_box": {
"bbox": [
970,
662,
939,
242
]
}
},
{
"error_boxes": [
{
"bbox": [
1209,
163,
31,
32
],
"class_name": "cuo",
"confidence": 0.7555574178695679
}
],
"match_method": "中心点包含",
"question_box": {
"bbox": [
970,
69,
939,
177
]
}
},
{
"error_boxes": [
{
"bbox": [
1225,
533,
46,
44
],
"class_name": "cuo",
"confidence": 0.7304249405860901
}
],
"match_method": "中心点包含",
"question_box": {
"bbox": [
970,
480,
939,
181
]
}
},
{
"error_boxes": [
{
"bbox": [
797,
827,
40,
42
],
"class_name": "cuo",
"confidence": 0.7287607192993164
}
],
"match_method": "中心点包含",
"question_box": {
"bbox": [
41,
821,
929,
147
]
}
},
{
"error_boxes": [
{
"bbox": [
1299,
363,
33,
33
],
"class_name": "cuo",
"confidence": 0.7262661457061768
}
],
"match_method": "中心点包含",
"question_box": {
"bbox": [
970,
245,
939,
234
]
}
},
{
"error_boxes": [
{
"bbox": [
1226,
1028,
36,
36
],
"class_name": "cuo",
"confidence": 0.7171130776405334
}
],
"match_method": "中心点包含",
"question_box": {
"bbox": [
970,
905,
939,
278
]
}
},
{
"error_boxes": [
{
"bbox": [
814,
1116,
36,
37
],
"class_name": "cuo",
"confidence": 0.7121084332466125
}
],
"match_method": "中心点包含",
"question_box": {
"bbox": [
41,
1112,
929,
252
]
}
},
{
"error_boxes": [
{
"bbox": [
793,
127,
39,
30
],
"class_name": "xie",
"confidence": 0.5237091183662415
}
],
"match_method": "中心点包含",
"question_box": {
"bbox": [
41,
107,
929,
146
]
}
}
],
"error_symbol_count": 8,
"question_count": 14,
"session_id": "20251125_082929_f1975f5c",
"visualization_images": {
"error_symbols": "/visualizations/20251125_082929_f1975f5c/error_symbols.jpg",
"matched_errors": "/visualizations/20251125_082929_f1975f5c/matched_errors.jpg",
"questions": "/visualizations/20251125_082929_f1975f5c/questions.jpg"
}
},
"success": true
}
```
被切割后的图片拼接方式:
`https://ekt1.suzhou.edu.cn/autocut/files/<session_id>/<filename>`
如上图,则被切割了14个图片:
```
https://ekt1.suzhou.edu.cn/autocut/files/20251125_082929_f1975f5c/question_001.jpg
https://ekt1.suzhou.edu.cn/autocut/files/20251125_082929_f1975f5c/question_002.jpg
https://ekt1.suzhou.edu.cn/autocut/files/20251125_082929_f1975f5c/question_003.jpg
…………
…………
https://ekt1.suzhou.edu.cn/autocut/files/20251125_082929_f1975f5c/question_014.jpg
```
question_id 也需要记录。其他字段忽略.
返回错误包括:只支持图片格式:
{
"message": "不支持的文件格式",
"success": false
}
字段缺失或错误:
{
"message": "没有上传图片文件",
"success": false
}
### 2. ocr api
输入上面的切割试卷api所生成的url
输出markdown形式的带有数学公式的题目文本内容。