OCR 识别

官方文档

OCR 识别官方文档OCR 识别 - 图1

源码

TNWX 中 OCR 识别相关接口源码OCR 识别 - 图2

示例

  1. app.get('/ocr', async (req: any, res: any) => {
  2. let type: string = req.query.type;
  3. console.log('to ocr...' + type);
  4. switch (parseInt(type)) {
  5. case 1:
  6. OCRApi.ocrByUrl(OCRType.IDCARD,'https://up.enterdesk.com/edpic_360_360/28/bc/80/28bc80d62c84ea7797197a6d7cb03394.jpg')
  7. .then((data) => {
  8. res.send(data);
  9. })
  10. .catch((error) => console.log(error))
  11. break;
  12. case 2:
  13. OCRApi.ocrByUrl(OCRType.PRINTEDTEXT,'https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1724603202,554806693&fm=26&gp=0.jpg')
  14. .then((data) => {
  15. res.send(data);
  16. })
  17. .catch((error) => console.log(error))
  18. break;
  19. case 3:
  20. OCRApi.ocrByFile(OCRType.PRINTEDTEXT,'/Users/Javen/Downloads/miniprogram_qrcode2.png')
  21. .then((data) => {
  22. res.send(data);
  23. })
  24. .catch((error) => console.log(error))
  25. break;
  26. default:
  27. break
  28. }
  29. });