Skip to content

Commit

Permalink
handle base64 without inplace_decode
Browse files Browse the repository at this point in the history
  • Loading branch information
gmuselli committed May 6, 2017
1 parent efefc7f commit a28c4bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 1 addition & 2 deletions ocr_rpc_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (
"time"

"github.com/couchbaselabs/logg"
"github.com/nu7hatch/gouuid"
"github.com/streadway/amqp"
)

Expand Down Expand Up @@ -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 {
Expand Down
6 changes: 6 additions & 0 deletions tesseract_engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a28c4bc

Please sign in to comment.