| 247 | } |
| 248 | |
| 249 | async function detectLogosGCS(bucketName, fileName) { |
| 250 | // [START vision_logo_detection_gcs] |
| 251 | const vision = require('@google-cloud/vision'); |
| 252 | |
| 253 | // Creates a client |
| 254 | const client = new vision.ImageAnnotatorClient(); |
| 255 | |
| 256 | /** |
| 257 | * TODO(developer): Uncomment the following lines before running the sample. |
| 258 | */ |
| 259 | // const bucketName = 'Bucket where the file resides, e.g. my-bucket'; |
| 260 | // const fileName = 'Path to file within bucket, e.g. path/to/image.png'; |
| 261 | |
| 262 | const request = { |
| 263 | requests: [ |
| 264 | { |
| 265 | image: { |
| 266 | source: { |
| 267 | imageUri: `gs://${bucketName}/${fileName}`, |
| 268 | }, |
| 269 | }, |
| 270 | features: [ |
| 271 | { |
| 272 | type: 'LOGO_DETECTION', |
| 273 | }, |
| 274 | ], |
| 275 | }, |
| 276 | ], |
| 277 | }; |
| 278 | |
| 279 | // Performs logo detection on the gcs file |
| 280 | const [response] = await client.batchAnnotateImages(request); |
| 281 | |
| 282 | response.responses.forEach(res => { |
| 283 | if (res.logoAnnotations) { |
| 284 | console.log('Logos:'); |
| 285 | res.logoAnnotations.forEach(logo => console.log(logo)); |
| 286 | } |
| 287 | |
| 288 | if (res.error) { |
| 289 | console.error(` - Error: ${res.error.message}`); |
| 290 | } |
| 291 | }); |
| 292 | // [END vision_logo_detection_gcs] |
| 293 | } |
| 294 | |
| 295 | async function detectProperties(fileName) { |
| 296 | // [START vision_image_property_detection] |