Giter Club home page Giter Club logo

esearch-ocr's Issues

浏览器环境部署报错 Uncaught ReferenceError: require is not defined

感谢作者在 PaddleOCR 的 js 部署方面做的工作,我尝试使用 esearch-OCR 在浏览器环境部署,但是遇到了一些问题,不知道应该如何解决。

主要操作:

import * as ocr from "esearch-ocr";
async function start() {
  const res = await axios.get("/ocr_keys_v1.txt");
  console.log(res);
  await ocr.init({
    detPath: "ocr_det.onnx",
    recPath: "ocr_rec.onnx",
    dic: res.data,
    node: false,
  });
  let img = document.getElementById("ocr-image");
  let canvas = document.createElement("canvas");
  canvas.width = img.width;
  canvas.height = img.height;
  canvas.getContext("2d").drawImage(img, 0, 0);
  const result = await ocr.ocr(
    canvas.getContext("2d").getImageData(0, 0, img.width, img.height)
  );
  setResult(result.reduce((total, cur) => total + `${cur.text}\n`));
}

本地 pnpm dev 没有问题,一旦build之后就会报错 Uncaught ReferenceError: require is not defined

不支持在node环境使用吗

错误信息如下

/Users/mac/.nvm/versions/node/v20.10.0/bin/node /Users/mac/Desktop/ocr/index.js ReferenceError: document is not defined at I (/Users/mac/Desktop/ocr/node_modules/esearch-ocr/dist/esearch-ocr.umd.cjs:1:1441) at F (/Users/mac/Desktop/ocr/node_modules/esearch-ocr/dist/esearch-ocr.umd.cjs:1:1586) at G (/Users/mac/Desktop/ocr/node_modules/esearch-ocr/dist/esearch-ocr.umd.cjs:1:1954) at Module.X [as ocr] (/Users/mac/Desktop/ocr/node_modules/esearch-ocr/dist/esearch-ocr.umd.cjs:1:655) at init (/Users/mac/Desktop/ocr/index.js:17:9)

安装运行环境运行后报错

Symbol search path is: *** Invalid ***


  • Symbol loading may be unreliable without a symbol search path. *
  • Use .symfix to have the debugger choose a symbol path. *
  • After setting your symbol path, use .reload to refresh symbol locations. *

Executable search path is:
Windows 8 Version 9600 MP (2 procs) Free x64
Product: WinNt, suite: SingleUserTS
Built by: 6.3.9600.17031 (winblue_gdr.140221-1952)
Machine Name:
Debug session time: Mon Jul 11 10:05:04.000 2022 (UTC + 8:00)
System Uptime: not available
Process Uptime: 0 days 0:00:01.000
............................................
This dump file has an exception of interest stored in it.
The stored exception information can be accessed via .ecxr.
(1c80.1fd8): Unknown exception - code c0000142 (first/second chance not available)
*** ERROR: Symbol file could not be found. Defaulted to export symbols for ntdll.dll -
ntdll!RtlRaiseStatus+0x20:
00007ffb04c0cdd0 488b85b8000000 mov rax,qword ptr [rbp+0B8h] ss:00000001a1ccf3d8=00007ffb04c0cdd0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.