WebPage / Google Vision Api

31 views
Skip to first unread message

PaoloPB

unread,
Jan 9, 2021, 12:31:17 PM1/9/21
to cloud-vision-discuss
Hi,

I am learning javascript / Node JS...

My purpose is to create a web page that can use "google vision apis".
Can anyone help me and show me how to use HTML/Javascript to get the same result as the nodejs code below?
Thank you in advance.

Paolo
-------------------------------------------------
The code is the nodejs code I found in Google API's site. It generates lables corresponding to the selected picture (by URL).

process.env.GOOGLE_APPLICATION_CREDENTIALS = 'PBProject-b4a0aa9f09cf.json';
async function quickstart() {
 const vision = require('@google-cloud/vision');
 const client = new vision.ImageAnnotatorClient();

  const labels = result.labelAnnotations;
  console.log('Labels:');
  labels.forEach(label => console.log(label.description));
}

quickstart()

Shameem (Google Cloud Platform)

unread,
Jan 12, 2021, 11:30:30 AM1/12/21
to cloud-vision-discuss
Node.js is meant to be run in back-end server, where as JavaScript runs in the browser. I am not sure but it seems you cannot use the Node.js client library for Vision API. You can use the generic JavaScript client library wrapper [1]. It's just a generic wrapper that takes in any of the Google Cloud API discovery documentation and turns it into a client library. This is not created by the Cloud Vision Engineering team, hence it is not supported by the cloud team.

I found some discussion [3]-[6] in the Stackoverflow that might be helpfult to understand how to convert Node.js to Javascrupt/HTML (if it does at all). 
Reply all
Reply to author
Forward
0 new messages