从图像中读取数据

时间:2018-02-08 06:22:12

标签: node.js ocr

我需要上传图片并以文本格式提取该图片中的文字。该图片将是我将从移动应用程序获得的名片。 我用节点js做到了。我尝试使用ocr npm但我在安装ocr作为依赖时遇到错误,即

$ npm install ocr
> ref@1.3.5 install E:\node_modules\ref
> node-gyp rebuild


E:\node_modules\ref>if not defined npm_config_node_gyp (node 
"C:\Users\Hello\AppData\Roaming\npm\node_modules\npm\node_modules\npm-
lifecycle\node-gyp-bin\\..\..\node_modules\node-gyp\bin\node-gyp.js" rebuild 
)  else (node 
"C:\Users\Hello\AppData\Roaming\npm\node_modules\npm\node_modules\node-
gyp\bin\node-gyp.js" rebuild )
Building the projects in this solution one at a time. To enable parallel 
build, please add the "/m" switch.
E:\node_modules\ref\build\binding.vcxproj(20,3): error MSB4019: The imported 
project "E:\Microsoft.Cpp.Default.props" was not found. Confirm that the 
path in the <Import> declaration is correct, and that the file exists on 
disk.
gyp ERR! build error
gyp ERR! stack Error: 
`C:\Windows\Microsoft.NET\Framework\v4.0.30319\msbuild.exe` failed with exit 
code: 1
gyp ERR! stack     at ChildProcess.onExit 
(C:\Users\Hello\AppData\Roaming\npm\node_modules\npm\node_modules\node-
gyp\lib\build.js:258:23)
gyp ERR! stack     at emitTwo (events.js:126:13)
gyp ERR! stack     at ChildProcess.emit (events.js:214:7)
gyp ERR! stack     at Process.ChildProcess._handle.onexit 
(internal/child_process.js:198:12)
gyp ERR! System Windows_NT 6.2.9200
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" 
"C:\\Users\\Hello\\AppData\\Roaming\\npm\\node_modules
\\npm\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild"
gyp ERR! cwd E:\node_modules\ref
gyp ERR! node -v v8.9.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm WARN my_actionhero_project@0.1.0 No repository field.
npm WARN my_actionhero_project@0.1.0 No license field.

npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! ref@1.3.5 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ref@1.3.5 install script.
npm ERR! This is probably not a problem with npm. There is likely additional 
logging output above.

有没有办法解决这个问题或我可以用来从图像中读取文本的任何其他节点模块?

1 个答案:

答案 0 :(得分:1)

在Ubuntu中安装ocr时遇到相同的错误。据我说,这是操作系统特定的错误。当我尝试使用“ npm i ocr”在MAC OS中安装ocr时,它已成功安装。所以您可以尝试一下。