tesseract-ocr works on EC2, not lambda

user1144380

My goal is to run tesseract-ocr in AWS Lambda.

I've built an EC2 instance that attempts to mirror the Lambda environment. Executing tesseract without parameters succeeds in both environments. However, any attempt at substantive image processing, e.g. this code:

tess = child_process.exec('tesseract input.tif output -l eng -psm 1 hocr', function(error, stdout, stderr) {
...

runs successfully on my EC2 box, but fails in Lambda with this error:

Error: Command failed: Tesseract Open Source OCR Engine v3.04.00 with Leptonica
Error during processing.

 at ChildProcess.exithandler (child_process.js:648:15)
 at ChildProcess.emit (events.js:98:17)
 at maybeClose (child_process.js:756:16)
 at Process.ChildProcess._handle.onexit (child_process.js:823:5)
Error code: 1
Signal received: null

Lambda is assuming an IAM role with administrative privileges ({ "Effect": "Allow", "Action": "", "Resource": "" })

The "Error during processing" error is emitted by tesseract as a top level catch-all. I'm going to instrument tesseract and try to narrow the problem further.

How I got here:

  • My EC2 machine is a t2.micro running Amazon Linux in us-east-1 (amzn-ami-hvm-2014.09.2.x86_64-ebs (ami-146e2a7c)).
  • I installed node 0.10.33 and [email protected], which match the Lambda versions.
  • I compiled tesseract and leptonica from source. Added an rpath and have run ldd to confirm that all dependencies are found
  • tesseract binaries and liblept.so are all in my root directory (/var/task)

I'd like to know what's going wrong - or how to diagnose it.

Thank you, Dave

user1144380

Short answer: output must go in the /tmp dir, e.g.

tesseract input.tif /tmp/output -l eng -psm 1 hocr

Slightly longer answer: tesseract calls fopen wb under the hood, and apparently that is forbidden in /var/task.

I would have noticed this a few days ago, but Lambda has not been propagating my deployment packages. So, the one time I tried to put output in the /tmp dir, there was no effect - but that was b/c Lambda was executing a stale version of my function. Solution is to always delete-function before calling update-function.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

tesseract-ocrはラムダではなくEC2で動作します

分類Dev

virtualenvを介したAWS Lambda上のTesseract OCR

分類Dev

Android Tesseract OCR on Android Studio

分類Dev

Why is Tesseract OCR using Otsu binarization?

分類Dev

Tesseract OCR の Blob とは

分類Dev

Pip install tesseract-ocr : 終了ステータス 2 で失敗しました

分類Dev

Tesseract-OCR to batch files in all subfolders, Windows cmd?

分類Dev

How to define regions on an image and pass to tesseract-ocr?

分類Dev

Tesseract-OCR(3.02)の認識精度と速度

分類Dev

EC2 vs Elastic Beanstalk vs Lambda

分類Dev

Make Lambda access EC2 port through a VPC

分類Dev

13.10のGscan2PDFまたはTesseractを使用したOCRからスキャンできません

分類Dev

Tesseract OCRではどのしきい値(2値化)アルゴリズムが使用されていますか?

分類Dev

13.10のGscan2PDFまたはTesseractを使用したOCRからスキャンできません

分類Dev

Tesseractのエラー-tesseract :: TessBaseApi()に関連するOCR(予期される型指定子)

分類Dev

tesseract - ビルドとインストール (`configure`, `make`, `make install`...) tesseract バージョン 3 (tesseract-ocr-3.XX.XX)

分類Dev

Django send_mail() from EC2 via Gmail gives SMTPAuthenticationError - but works fine in localhost

分類Dev

How does the connection between CloudFront and one EC2 origin works using HTTPS?

分類Dev

How uploading to S3 through PHP script on EC2 works?

分類Dev

Tesseract(OCR)を使用した特殊文字ホワイトリスト

分類Dev

OCR-tesseract-表形式のデータで数値を抽出する

分類Dev

Tesseract OCR4.xでインデントを保持する

分類Dev

Node JSとTesseract.jsでOCRの精度を上げる方法は?

分類Dev

iPhoneisoのTesseract制限?iOS用の他のOCRエンジン

分類Dev

tesseract-ocr`。/ configure`トリガーエラー「leptonicanotfound」

分類Dev

tesseract-ocrの画像を前処理するImageMagick

分類Dev

Tesseract OCR「警告:画像にサイズがありません!」

分類Dev

Tesseract OCR:サポートされていない画像タイプ

分類Dev

OCR。tesseractを使用して走行距離計を認識する

Related 関連記事

  1. 1

    tesseract-ocrはラムダではなくEC2で動作します

  2. 2

    virtualenvを介したAWS Lambda上のTesseract OCR

  3. 3

    Android Tesseract OCR on Android Studio

  4. 4

    Why is Tesseract OCR using Otsu binarization?

  5. 5

    Tesseract OCR の Blob とは

  6. 6

    Pip install tesseract-ocr : 終了ステータス 2 で失敗しました

  7. 7

    Tesseract-OCR to batch files in all subfolders, Windows cmd?

  8. 8

    How to define regions on an image and pass to tesseract-ocr?

  9. 9

    Tesseract-OCR(3.02)の認識精度と速度

  10. 10

    EC2 vs Elastic Beanstalk vs Lambda

  11. 11

    Make Lambda access EC2 port through a VPC

  12. 12

    13.10のGscan2PDFまたはTesseractを使用したOCRからスキャンできません

  13. 13

    Tesseract OCRではどのしきい値(2値化)アルゴリズムが使用されていますか?

  14. 14

    13.10のGscan2PDFまたはTesseractを使用したOCRからスキャンできません

  15. 15

    Tesseractのエラー-tesseract :: TessBaseApi()に関連するOCR(予期される型指定子)

  16. 16

    tesseract - ビルドとインストール (`configure`, `make`, `make install`...) tesseract バージョン 3 (tesseract-ocr-3.XX.XX)

  17. 17

    Django send_mail() from EC2 via Gmail gives SMTPAuthenticationError - but works fine in localhost

  18. 18

    How does the connection between CloudFront and one EC2 origin works using HTTPS?

  19. 19

    How uploading to S3 through PHP script on EC2 works?

  20. 20

    Tesseract(OCR)を使用した特殊文字ホワイトリスト

  21. 21

    OCR-tesseract-表形式のデータで数値を抽出する

  22. 22

    Tesseract OCR4.xでインデントを保持する

  23. 23

    Node JSとTesseract.jsでOCRの精度を上げる方法は?

  24. 24

    iPhoneisoのTesseract制限?iOS用の他のOCRエンジン

  25. 25

    tesseract-ocr`。/ configure`トリガーエラー「leptonicanotfound」

  26. 26

    tesseract-ocrの画像を前処理するImageMagick

  27. 27

    Tesseract OCR「警告:画像にサイズがありません!」

  28. 28

    Tesseract OCR:サポートされていない画像タイプ

  29. 29

    OCR。tesseractを使用して走行距離計を認識する

ホットタグ

アーカイブ