如何使用 python 或 WMI 设置 RAM 磁盘驱动器?
我的问题的背景与 Tesseract 有关,这是一个免费的 OCR 引擎(1985-1995 年由 HP 开发,现在由 Google 托管)。它特别需要一个输入文件和一个输出文件;参数仅接受文件名(而不是流/二进制字符串),因此为了使用 pytesser 和/或 python-tesser.py 等包装 API,必须创建 OCR 临时文件。然而,我有很多图像需要 OCR;频繁的磁盘写入和删除是不可避免的(当然也会影响性能)。我能想到的唯一选择是更改包装类并将临时文件指向 RAM 磁盘,这会带来这个问题。
如果您有更好的解决方案,请告诉我。
多谢。
-M
The background of my question is associated with Tesseract, the free OCR engine (1985-1995 by HP, now hosting in Google). It specifically requires an input file and an output file; the argument only takes filename (not stream / binary string), so in order to use the wrapper API such as pytesser and / or python-tesser.py, the OCR temp files must be created. I, however, have a lot of images need to OCR; frequent disk write and remove is inevitable (and of course the performance hit). The only choice I could think about is changing the wrapper class and point the temp file to RAM disk, which bring this problem up.
If you have better solution, please let me know.
Thanks a lot.
-M
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你在Linux上吗?您可以尝试通过管道将文件发送到程序并引用 /dev/fd/0 ——它是当前进程的标准输入路径名。如果应用程序不通过它来eek(),它应该可以工作。
Are you on linux? You could try to send a file to the program through a pipe and refer to /dev/fd/0 -- it's the standard input's pathname for the current process. It should work if the application does not seek() through it.
通过Google搜索,我找到了一个可能的解决方案(不包括WMI,但您可以通过
子进程
使用它):下载devcon 实用程序,一种命令行设备管理器。
然后,您可以使用以下内容:
我希望这能给您一个开始。
By searching at Google, I found a possible solution (that does not include WMI, but you can use it through
subprocess
):Download the devcon utility, kind of a command-line device manager.
Then, you can use something like:
I hope this gives you a start.