From a28c4bcc57611c5555513401cf16d2133700ddc5 Mon Sep 17 00:00:00 2001 From: gmuselli Date: Sat, 6 May 2017 11:26:40 +0200 Subject: [PATCH] handle base64 without inplace_decode --- ocr_rpc_client.go | 3 +-- tesseract_engine.go | 6 ++++++ 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/ocr_rpc_client.go b/ocr_rpc_client.go index 362fd0b..3defcae 100644 --- a/ocr_rpc_client.go +++ b/ocr_rpc_client.go @@ -6,7 +6,6 @@ import ( "time" "github.com/couchbaselabs/logg" - "github.com/nu7hatch/gouuid" "github.com/streadway/amqp" ) @@ -87,7 +86,7 @@ func (c *OcrRpcClient) DecodeImage(ocrRequest OcrRequest) (OcrResult, error) { // any preprocessors. if rabbitmq isn't in same data center // as open-ocr, it will be expensive in terms of bandwidth // to have image binary in messages - if ocrRequest.ImgBytes == nil { + if ocrRequest.ImgBytes == nil && ocrRequest.ImgBase64 == nil { // if we already have image bytes, ignore image url err = ocrRequest.downloadImgUrl() if err != nil { diff --git a/tesseract_engine.go b/tesseract_engine.go index 0211791..43d1775 100644 --- a/tesseract_engine.go +++ b/tesseract_engine.go @@ -129,6 +129,8 @@ func (t TesseractEngine) ProcessRequest(ocrRequest OcrRequest) (OcrResult, error func (t TesseractEngine) tmpFileFromImageBytes(imgBytes []byte) (string, error) { + logg.LogTo("OCR_TESSERACT", "Use tesseract with bytes image") + tmpFileName, err := createTempFileName() if err != nil { return "", err @@ -147,6 +149,8 @@ func (t TesseractEngine) tmpFileFromImageBytes(imgBytes []byte) (string, error) func (t TesseractEngine) tmpFileFromImageBase64(base64Image string) (string, error) { + logg.LogTo("OCR_TESSERACT", "Use tesseract with base 64") + tmpFileName, err := createTempFileName() if err != nil { return "", err @@ -170,6 +174,8 @@ func (t TesseractEngine) tmpFileFromImageBase64(base64Image string) (string, err func (t TesseractEngine) tmpFileFromImageUrl(imgUrl string) (string, error) { + logg.LogTo("OCR_TESSERACT", "Use tesseract with url") + tmpFileName, err := createTempFileName() if err != nil { return "", err