我在我的uniapp代码中使用了tesseract.js这个库,然后出现了一些问题:
RangeError: WebAssembly.Memory(): could not allocate memory at pages/index/test2.vue:36
代码如下:
我在我的uniapp代码中使用了tesseract.js这个库,然后出现了一些问题:
RangeError: WebAssembly.Memory(): could not allocate memory at pages/index/test2.vue:36
代码如下:
这个问题看起来是因为WebAssembly内存过小而导致的。您可以尝试增加WebAssembly内存的大小来解决这个问题。具体来说,您可以尝试在创建WebAssembly实例时指定内存的大小,如下所示:
const wasmBytes = ...
const wasmModule = new WebAssembly.Module(wasmBytes)
const wasmMemory = new WebAssembly.Memory({ initial: 256, maximum: 4096 })
const wasmInstance = new WebAssembly.Instance(wasmModule, { env: { memory: wasmMemory } })
在这里,我们将内存大小设置为256页,并将其最大大小设置为4096页。您可以根据需要调整这些值。
另外,您还可以尝试使用其他OCR库来解决这个问题,例如Google Cloud Vision API或Microsoft Azure Computer Vision API。这些API可以在云端运行,而不需要在本地计算机上运行OCR库。