使用大模型API检测图片中的涂题卡区域、下划线和表格空白单元格
健康检查端点
{
"status": "healthy",
"message": "API is running"
}
处理涂题卡图片,检测涂题卡区域
{
"image_url": "https://example.com/image.jpg",
"description": "可选的图片描述"
}
{
"success": true,
"message": "成功检测到 5 个涂题卡区域",
"data": [
{
"boundary": [100, 200, 300, 400],
"rows": 5,
"columns": 4,
"option_size": [20, 20]
}
]
}
处理base64编码的涂题卡图片,检测涂题卡区域
{
"image_base64": "base64编码的图像数据",
"description": "可选的图片描述"
}
{
"success": true,
"message": "成功检测到 5 个涂题卡区域",
"data": [
{
"boundary": [100, 200, 300, 400],
"rows": 5,
"columns": 4,
"option_size": [20, 20]
}
]
}
处理base64编码的图像,检测图像中的下划线
{
"image_base64": "base64编码的图像数据",
"description": "可选的图片描述"
}
{
"success": true,
"message": "成功检测到 3 条下划线",
"data": [
{
"x1": 100,
"y1": 200,
"x2": 300,
"y2": 250
},
{
"x1": 350,
"y1": 200,
"x2": 550,
"y2": 250
},
{
"x1": 600,
"y1": 200,
"x2": 800,
"y2": 250
}
]
}
处理base64编码的图像,检测图像中的表格空白单元格
{
"image_base64": "base64编码的图像数据",
"description": "可选的图片描述"
}
{
"success": true,
"message": "成功检测到 5 个表格空白单元格",
"data": [
{
"x1": 100,
"y1": 200,
"x2": 300,
"y2": 250
},
{
"x1": 350,
"y1": 200,
"x2": 550,
"y2": 250
},
{
"x1": 600,
"y1": 200,
"x2": 800,
"y2": 250
},
{
"x1": 100,
"y1": 300,
"x2": 300,
"y2": 350
},
{
"x1": 350,
"y1": 300,
"x2": 550,
"y2": 350
}
]
}
比较空白卷和答案卷,检测被选中的选项
{
"blank_sheet_path": "空白卷图片路径",
"answer_sheet_path": "答案卷图片路径",
"description": "可选的图片描述"
}
{
"success": true,
"message": "成功检测到 5 个选中的选项",
"data": [
{
"row": 2,
"column": 2
},
{
"row": 3,
"column": 4
}
]
}
比较空白卷和答案卷的黑色像素数量,检测被选中的选项
{
"blank_sheet_path": "空白卷图片路径",
"answer_sheet_path": "答案卷图片路径",
"threshold": 128,
"increase_threshold": 30.0,
"description": "可选的图片描述"
}
{
"success": true,
"message": "成功检测到 5 个选中的选项",
"data": {
"answer_sheet_regions": [
{
"boundary": [100, 200, 300, 400],
"rows": 5,
"columns": 4,
"option_size": [20, 20],
"selected_options": [
{"row": 2, "column": 2}
],
"black_pixel_counts": [
{
"row": 2,
"column": 2,
"position": [100, 200, 120, 220],
"blank_black_pixels": 10,
"answer_black_pixels": 50,
"black_pixel_increase_percent": 400.0
}
]
}
],
"total_regions": 1,
"total_selected_options": 1,
"visualization_path": "output/black_pixel_counts_comparison.png"
}
}
curl -X POST "http://localhost:8000/process_answer_sheet" -H "Content-Type: application/json" -d '{
"image_url": "https://marking-paper-1252908908.cos.ap-nanjing.myqcloud.com/task/20250620/60c8135fa4632f892ebe437b1750384470000001.jpg"
}'
curl -X POST "http://localhost:8000/process_answer_sheet_base64" -H "Content-Type: application/json" -d '{
"image_base64": "base64编码的图像数据"
}'
curl -X POST "http://localhost:8000/find_underlines" \
-H "Content-Type: application/json" \
-d '{
"image_base64": "base64编码的图像数据"
}'
curl -X POST "http://localhost:8000/find_table_cells" \
-H "Content-Type: application/json" \
-d '{
"image_base64": "base64编码的图像数据"
}'
curl -X POST "http://localhost:8000/compare_answer_sheet" -H "Content-Type: application/json" -d '{
"blank_sheet_path": "path/to/blank_sheet.jpg",
"answer_sheet_path": "path/to/answer_sheet.jpg"
}'
curl -X POST "http://localhost:8000/black_pixel_analysis" -H "Content-Type: application/json" -d '{
"blank_sheet_path": "path/to/blank_sheet.jpg",
"answer_sheet_path": "path/to/answer_sheet.jpg",
"threshold": 128,
"increase_threshold": 30.0
}'
import requests
import base64
# 方法1:使用URL
url = "http://localhost:8000/process_answer_sheet"
payload = {
"image_url": "https://example.com/image.jpg"
}
response = requests.post(url, json=payload)
result = response.json()
print(result)
import requests
import base64
# 方法2:使用base64编码
with open("image.jpg", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
url = "http://localhost:8000/process_answer_sheet_base64"
payload = {
"image_base64": encoded_string
}
response = requests.post(url, json=payload)
result = response.json()
print(result)
import requests
url = "http://localhost:8000/compare_answer_sheet"
payload = {
"blank_sheet_path": "path/to/blank_sheet.jpg",
"answer_sheet_path": "path/to/answer_sheet.jpg"
}
response = requests.post(url, json=payload)
result = response.json()
print(result)
import requests
url = "http://localhost:8000/black_pixel_analysis"
payload = {
"blank_sheet_path": "path/to/blank_sheet.jpg",
"answer_sheet_path": "path/to/answer_sheet.jpg",
"threshold": 128,
"increase_threshold": 30.0
}
response = requests.post(url, json=payload)
result = response.json()
print(result)
print(f"可视化图表路径: {result['data']['visualization_path']}")
import requests
import base64
# 读取图像文件并转换为base64
with open("image.jpg", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
url = "http://localhost:8000/find_underlines"
payload = {
"image_base64": encoded_string
}
response = requests.post(url, json=payload)
result = response.json()
print(result)
import requests
import base64
# 读取图像文件并转换为base64
with open("image.jpg", "rb") as image_file:
encoded_string = base64.b64encode(image_file.read()).decode('utf-8')
url = "http://localhost:8000/find_table_cells"
payload = {
"image_base64": encoded_string
}
response = requests.post(url, json=payload)
result = response.json()
print(result)
查看Swagger UI文档
查看ReDoc文档