MCPcopy Create free account
hub / github.com/GoogleCloudPlatform/nodejs-docs-samples / detectText

Function detectText

vision/detect.js:160–178  ·  view source on GitHub ↗
(fileName)

Source from the content-addressed store, hash-verified

158}
159
160async function detectText(fileName) {
161 // [START vision_text_detection]
162 const vision = require('@google-cloud/vision');
163
164 // Creates a client
165 const client = new vision.ImageAnnotatorClient();
166
167 /**
168 * TODO(developer): Uncomment the following line before running the sample.
169 */
170 // const fileName = 'Local image file, e.g. /path/to/image.png';
171
172 // Performs text detection on the local file
173 const [result] = await client.textDetection(fileName);
174 const detections = result.textAnnotations;
175 console.log('Text:');
176 detections.forEach(text => console.log(text));
177 // [END vision_text_detection]
178}
179
180async function detectTextGCS(bucketName, fileName) {
181 // [START vision_text_detection_gcs]

Callers 1

detect.jsFile · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected