python - 如何在 Heroku 中使用 tesseract 和 ocr?
问题描述
我按照这篇文章,在代码中添加了 tesseract_cmd,添加了 Aptfile,但部署后出现问题:
import cv2
import os
class TestingView(APIView):
def post(self, req):
print(req.FILES)
crop_img = req.FILES["ok"]
print(crop_img)
file_loc = "media/"
fs = FileSystemStorage(location=file_loc)
filename = fs.save(crop_img.name, crop_img)
crop_img = cv2.imread(file_loc+"crop_12_.png")
print(os.getcwd())
f = open("ok.txt", "w+")
f.write("shiv")
f.close()
pytesseract.pytesseract.tesseract_cmd = "/app/.apt/usr/share/tesseract-ocr/4.00/tessdata"
output = pytesseract.image_to_string(crop_img, lang='hin') #, config=)
text = "ok"
return Response({"ok": output})
# return Response({"ok": text})
PermissionError at /testing/
[Errno 13] Permission denied: '/app/.apt/usr/share/tesseract-ocr/4.00/tessdata'
build_pack 和 TESSDATA_PREFIX=/app/.apt/usr/share/tesseract-ocr/4.00/tessdata 也添加了。任何解决方案?
解决方案
推荐阅读
- security - 显示明文时检索加密值
- javascript - 有没有办法远程测试本机反应?
- shopify - 我的 Liquid 语法是错误的,还是缺少参考?
- python - 使用正则表达式搜索和删除两个标记之间的字符串
- angular - 使用 Jest 进行 ng 测试失败,并在 npm 包上显示 objValue.concat
- python - 减少组合生成脚本的执行时间
- apache-flink - 如何在 Flink keyBy 中使用 lambda 函数
- alexa - 如果在相同的意图中获得不同的插槽值,我可以做出不同的回答吗,AWS Alexa
- java - 以非编程方式将 XML 转换为 Java 类的 IDE 工具
- java - spring 请求参数是嵌套的 json 验证失败