Skip to content

Trying to call textDetection() using base64 or buffer. Not working #642

@cbdeveloper

Description

@cbdeveloper

I'm having trouble with an issue similar to issue googleapis/nodejs-vision#9

I have a base64 image string that I need to pass to vision.textDetection(), and nothing seems to work.

The issue that I've mentioned suggests the following:


image


Don't know if this should still be working for the most recent version, because this is what I'm doing:

const [textDetections] = await vision.textDetection(
     { image: {
         source: {
           content: imgBase64
      }
    }});

And this is what I'm getting:

{ Error: 3 INVALID_ARGUMENT: Request must specify image and features.

This is my base64 string (it seems fine):

image

Also tried the following:

const buffer = new Buffer(imgBase64, 'base64');
const arraybuffer  = Uint8Array.from(buffer).buffer;

const [textDetections] = await vision.textDetection({image: {
  // content: buffer           // <--- TRIED BOTH WITH BUFFER AND ARRAY BUFFER
  content: arraybuffer
}});

Nothing seems to work.

Also, the docs don't mention anything about it accepting a base64 string.

https://googleapis.dev/nodejs/vision/latest/v1.ImageAnnotatorClient.html#textDetection


image


Environment details

  • OS: Firebase Cloud Function Node v10
  • Node.js version: 10
  • npm version: NA
  • @google-cloud/vision version: "@google-cloud/vision": "^2.1.1",

Metadata

Metadata

Assignees

Labels

type: docsImprovement to the documentation for an API.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions