Skip to content
This repository has been archived by the owner on Jul 20, 2023. It is now read-only.

helpers.js?cd8a:247 Uncaught TypeError: gax.GoogleProtoFilesRoot is not a constructor #431

Closed
ChoyCheeWei opened this issue Sep 5, 2019 · 6 comments · Fixed by #441
Closed
Assignees
Labels
api: vision Issues related to the googleapis/nodejs-vision API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. web

Comments

@ChoyCheeWei
Copy link

I try to implement Google Vision Api in Vuejs but I getting this error:
helpers.js?cd8a:247 Uncaught TypeError: gax.GoogleProtoFilesRoot is not a constructor

this code is in my ocr.vue file
<script>
export default {
name: "ocr"
};
// Imports the Google Cloud client library
const vision = require("@google-cloud/vision");

// Creates a client
const client = new vision.ImageAnnotatorClient();

// Performs label detection on the image file
client
.textDetection('./resources/maybank2u.png')
.then(result => {
const labels = result[0].textAnnotations;
console.log("Text:");
labels.forEach(text => console.log(text));
})
.catch(err => {
console.error("ERROR:", err);
});
</script>

Any idea how to solve this?

@callmehiphop
Copy link
Contributor

👋 @ChoyCheeWei are you trying to use this on the front end? Currently this library doesn't support it, but I think we'll have a release out soon that will.

@callmehiphop callmehiphop added needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. labels Sep 5, 2019
@ChoyCheeWei
Copy link
Author

@callmehiphop I'm trying to get all the text from an image and store some of the text into database, but I already face some errors during my first step lol

@callmehiphop
Copy link
Contributor

@ChoyCheeWei the latest release should have browser support if you'd like to try updating the client version and testing again.

@bcoe
Copy link
Contributor

bcoe commented Sep 13, 2019

@alexander-fenster is there a canonical issue @callmehiphop, myself, and others can link folks to, related to browser support?

@alexander-fenster
Copy link
Contributor

Maybe this one: googleapis/google-cloud-node#2933

For Vision, helpers.js is a manual code that might also need to be updated to start using JSON protos (I haven't checked it yet).

@alexander-fenster
Copy link
Contributor

This piece of code needs to be changed to use JSON protos. I will work on this.

let protoFilesRoot = new gax.GoogleProtoFilesRoot();
protoFilesRoot = protobuf.loadSync(
path.join(
__dirname,
'..',
'protos',
`google/cloud/vision/${apiVersion}/image_annotator.proto`
),
protoFilesRoot
);
const features = protoFilesRoot.lookup(
`google.cloud.vision.${apiVersion}.Feature.Type`
).values;

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
api: vision Issues related to the googleapis/nodejs-vision API. needs more info This issue needs more information from the customer to proceed. type: question Request for information or clarification. Not an issue. web
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants