Skip to content

3361559784/text

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OCR Course Parser (手机截图 → 结构化课表)

这是一个简单的 Node.js 服务示例,提供 /api/ocrCourse API,用于将截图提交给 OCR 解析并返回结构化的课程事件信息。

功能概览

  • 支持将整张的课程分享页截图放到可直链访问的 URL(如 GitHub raw、Cloudflare R2、图床),传入 imageUrls
  • 服务会下载图片,使用 tesseract.js 进行 OCR,并用简单的解析规则提取课程名、时间、周次和地点,返回 events/summary/needsConfirmation

快速开始

  1. 安装依赖
npm install
  1. 启动服务(默认 7071 端口,和 Azure Functions 本地端口保持一致)
npm run start
  1. 使用 curl 测试
curl -X POST http://localhost:7071/api/ocrCourse \
  -H "Content-Type: application/json" \
  -d '{
    "userId": "sensei",
    "imageUrls": ["https://your.cdn/schedule-shot.png"]
  }'

响应结构示例

{
  "userId": "sensei",
  "rawTexts": [ { "url": "https://...", "text": "..." } ],
  "events": [
    {
      "title": "操作系统",
      "day": "周一",
      "startTime": "09:00",
      "endTime": "10:30",
      "weeks": [{"startWeek":1, "endWeek":16}],
      "location": "教学楼A101"
    }
  ],
  "summary": "课程名: 操作系统 | 时间: 周一 09:00-10:30 | 周次: 1-16 | 地点: 教学楼A101",
  "needsConfirmation": false
}

小贴士

  • 使用清晰、完整的一张截图,避免拼接或遮挡。
  • 当解析结果不准时,可以再拍一张放大时间/周次区域的截图后重试。

扩展建议

  • 将 OCR 替换为云 OCR(Azure Computer Vision、Google Vision API),以提高识别率。
  • 改进解析(实体识别、正则增强),或使用 LLM 对 OCR 文本做语义解析。
  • 支持将解析结果写入 Azure Cosmos DB 或其他数据库。

脚本作者: 生成于 2025

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors