| 158 | } |
| 159 | |
| 160 | async 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 | |
| 180 | async function detectTextGCS(bucketName, fileName) { |
| 181 | // [START vision_text_detection_gcs] |