@@ -28,8 +28,8 @@ async function detectFaces(fileName) {
2828 */
2929 // const fileName = 'Local image file, e.g. /path/to/image.png';
3030
31- const [ { faceAnnotations : faces } ] = await client . faceDetection ( fileName ) ;
32-
31+ const [ result ] = await client . faceDetection ( fileName ) ;
32+ const faces = result . faceAnnotations ;
3333 console . log ( 'Faces:' ) ;
3434 faces . forEach ( ( face , i ) => {
3535 console . log ( ` Face #${ i + 1 } :` ) ;
@@ -56,9 +56,8 @@ async function detectFacesGCS(bucketName, fileName) {
5656 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
5757
5858 // Performs face detection on the gcs file
59- const [ { faceAnnotations : faces } ] = await client . faceDetection (
60- `gs://${ bucketName } /${ fileName } `
61- ) ;
59+ const [ result ] = await client . faceDetection ( `gs://${ bucketName } /${ fileName } ` ) ;
60+ const faces = result . faceAnnotations ;
6261 console . log ( 'Faces:' ) ;
6362 faces . forEach ( ( face , i ) => {
6463 console . log ( ` Face #${ i + 1 } :` ) ;
@@ -84,7 +83,8 @@ async function detectLabels(fileName) {
8483 // const fileName = 'Local image file, e.g. /path/to/image.png';
8584
8685 // Performs label detection on the local file
87- const [ { labelAnnotations : labels } ] = await client . labelDetection ( fileName ) ;
86+ const [ result ] = await client . labelDetection ( fileName ) ;
87+ const labels = result . labelAnnotations ;
8888 console . log ( 'Labels:' ) ;
8989 labels . forEach ( label => console . log ( label . description ) ) ;
9090 // [END vision_label_detection]
@@ -105,9 +105,10 @@ async function detectLabelsGCS(bucketName, fileName) {
105105 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
106106
107107 // Performs label detection on the gcs file
108- const [ { labelAnnotations : labels } ] = await client . labelDetection (
108+ const [ result ] = await client . labelDetection (
109109 `gs://${ bucketName } /${ fileName } `
110110 ) ;
111+ const labels = result . labelAnnotations ;
111112 console . log ( 'Labels:' ) ;
112113 labels . forEach ( label => console . log ( label . description ) ) ;
113114 // [END vision_label_detection_gcs]
@@ -126,9 +127,8 @@ async function detectLandmarks(fileName) {
126127 // const fileName = 'Local image file, e.g. /path/to/image.png';
127128
128129 // Performs landmark detection on the local file
129- const [ { landmarkAnnotations : landmarks } ] = await client . landmarkDetection (
130- fileName
131- ) ;
130+ const [ result ] = await client . landmarkDetection ( fileName ) ;
131+ const landmarks = result . landmarkAnnotations ;
132132 console . log ( 'Landmarks:' ) ;
133133 landmarks . forEach ( landmark => console . log ( landmark ) ) ;
134134 // [END vision_landmark_detection]
@@ -149,9 +149,10 @@ async function detectLandmarksGCS(bucketName, fileName) {
149149 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
150150
151151 // Performs landmark detection on the gcs file
152- const [ { landmarkAnnotations : landmarks } ] = await client . landmarkDetection (
152+ const [ result ] = await client . landmarkDetection (
153153 `gs://${ bucketName } /${ fileName } `
154154 ) ;
155+ const landmarks = result . landmarkAnnotations ;
155156 console . log ( 'Landmarks:' ) ;
156157 landmarks . forEach ( landmark => console . log ( landmark ) ) ;
157158 // [END vision_landmark_detection_gcs]
@@ -170,7 +171,8 @@ async function detectText(fileName) {
170171 // const fileName = 'Local image file, e.g. /path/to/image.png';
171172
172173 // Performs text detection on the local file
173- const [ { textAnnotations : detections } ] = await client . textDetection ( fileName ) ;
174+ const [ result ] = await client . textDetection ( fileName ) ;
175+ const detections = result . textAnnotations ;
174176 console . log ( 'Text:' ) ;
175177 detections . forEach ( text => console . log ( text ) ) ;
176178 // [END vision_text_detection]
@@ -191,9 +193,8 @@ async function detectTextGCS(bucketName, fileName) {
191193 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
192194
193195 // Performs text detection on the gcs file
194- const [ { textAnnotations : detections } ] = await client . textDetection (
195- `gs://${ bucketName } /${ fileName } `
196- ) ;
196+ const [ result ] = await client . textDetection ( `gs://${ bucketName } /${ fileName } ` ) ;
197+ const detections = result . textAnnotations ;
197198 console . log ( 'Text:' ) ;
198199 detections . forEach ( text => console . log ( text ) ) ;
199200 // [END vision_text_detection_gcs]
@@ -212,7 +213,8 @@ async function detectLogos(fileName) {
212213 // const fileName = 'Local image file, e.g. /path/to/image.png';
213214
214215 // Performs logo detection on the local file
215- const [ { logoAnnotations : logos } ] = await client . logoDetection ( fileName ) ;
216+ const [ result ] = await client . logoDetection ( fileName ) ;
217+ const logos = result . logoAnnotations ;
216218 console . log ( 'Logos:' ) ;
217219 logos . forEach ( logo => console . log ( logo ) ) ;
218220 // [END vision_logo_detection]
@@ -233,9 +235,8 @@ async function detectLogosGCS(bucketName, fileName) {
233235 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
234236
235237 // Performs logo detection on the gcs file
236- const [ { logoAnnotations : logos } ] = await client . logoDetection (
237- `gs://${ bucketName } /${ fileName } `
238- ) ;
238+ const [ result ] = await client . logoDetection ( `gs://${ bucketName } /${ fileName } ` ) ;
239+ const logos = result . logoAnnotations ;
239240 console . log ( 'Logos:' ) ;
240241 logos . forEach ( logo => console . log ( logo ) ) ;
241242 // [END vision_logo_detection_gcs]
@@ -254,13 +255,8 @@ async function detectProperties(fileName) {
254255 // const fileName = 'Local image file, e.g. /path/to/image.png';
255256
256257 // Performs property detection on the local file
257- const [
258- {
259- imagePropertiesAnnotation : {
260- dominantColors : { colors} ,
261- } ,
262- } ,
263- ] = await client . imageProperties ( fileName ) ;
258+ const [ result ] = await client . imageProperties ( fileName ) ;
259+ const colors = result . imagePropertiesAnnotation . dominantColors . colors ;
264260 colors . forEach ( color => console . log ( color ) ) ;
265261 // [END vision_image_property_detection]
266262}
@@ -280,18 +276,10 @@ async function detectPropertiesGCS(bucketName, fileName) {
280276 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
281277
282278 // Performs property detection on the gcs file
283- const [
284- {
285- imagePropertiesAnnotation : {
286- dominantColors : { colors} ,
287- } ,
288- } ,
289- ] = await client . imageProperties ( `gs://${ bucketName } /${ fileName } ` ) ;
290-
291- // const [
292- // {imagePropertiesAnnotation: properties},
293- // ] = await client.imageProperties(fileName);
294- // const colors = properties.dominantColors.colors;
279+ const [ result ] = await client . imageProperties (
280+ `gs://${ bucketName } /${ fileName } `
281+ ) ;
282+ const colors = result . imagePropertiesAnnotation . dominantColors ;
295283 colors . forEach ( color => console . log ( color ) ) ;
296284 // [END vision_image_property_detection_gcs]
297285}
@@ -309,9 +297,8 @@ async function detectSafeSearch(fileName) {
309297 // const fileName = 'Local image file, e.g. /path/to/image.png';
310298
311299 // Performs safe search detection on the local file
312- const [ { safeSearchAnnotation : detections } ] = await client . safeSearchDetection (
313- fileName
314- ) ;
300+ const [ result ] = await client . safeSearchDetection ( fileName ) ;
301+ const detections = result . safeSearchAnnotation ;
315302 console . log ( 'Safe search:' ) ;
316303 console . log ( `Adult: ${ detections . adult } ` ) ;
317304 console . log ( `Medical: ${ detections . medical } ` ) ;
@@ -336,9 +323,10 @@ async function detectSafeSearchGCS(bucketName, fileName) {
336323 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
337324
338325 // Performs safe search property detection on the remote file
339- const [ { safeSearchAnnotation : detections } ] = await client . safeSearchDetection (
326+ const [ result ] = await client . safeSearchDetection (
340327 `gs://${ bucketName } /${ fileName } `
341328 ) ;
329+ const detections = result . safeSearchAnnotation ;
342330 console . log ( `Adult: ${ detections . adult } ` ) ;
343331 console . log ( `Spoof: ${ detections . spoof } ` ) ;
344332 console . log ( `Medical: ${ detections . medical } ` ) ;
@@ -361,7 +349,8 @@ async function detectCropHints(fileName) {
361349 // const fileName = 'Local image file, e.g. /path/to/image.png';
362350
363351 // Find crop hints for the local file
364- const [ { cropHintsAnnotation : cropHints } ] = await client . cropHints ( fileName ) ;
352+ const [ result ] = await client . cropHints ( fileName ) ;
353+ const cropHints = result . cropHintsAnnotation ;
365354 cropHints . cropHints . forEach ( ( hintBounds , hintIdx ) => {
366355 console . log ( `Crop Hint ${ hintIdx } :` ) ;
367356 hintBounds . boundingPoly . vertices . forEach ( ( bound , boundIdx ) => {
@@ -387,9 +376,8 @@ async function detectCropHintsGCS(bucketName, fileName) {
387376 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
388377
389378 // Find crop hints for the remote file
390- const [ { cropHintsAnnotation : cropHints } ] = await client . cropHints (
391- `gs://${ bucketName } /${ fileName } `
392- ) ;
379+ const [ result ] = await client . cropHints ( `gs://${ bucketName } /${ fileName } ` ) ;
380+ const cropHints = result . cropHintsAnnotation ;
393381 cropHints . cropHints . forEach ( ( hintBounds , hintIdx ) => {
394382 console . log ( `Crop Hint ${ hintIdx } :` ) ;
395383 hintBounds . boundingPoly . vertices . forEach ( ( bound , boundIdx ) => {
@@ -414,7 +402,8 @@ async function detectWeb(fileName) {
414402 // const fileName = 'Local image file, e.g. /path/to/image.png';
415403
416404 // Detect similar images on the web to a local file
417- const [ { webDetection} ] = await client . webDetection ( fileName ) ;
405+ const [ result ] = await client . webDetection ( fileName ) ;
406+ const webDetection = result . webDetection ;
418407 if ( webDetection . fullMatchingImages . length ) {
419408 console . log (
420409 `Full matches found: ${ webDetection . fullMatchingImages . length } `
@@ -470,9 +459,8 @@ async function detectWebGCS(bucketName, fileName) {
470459 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
471460
472461 // Detect similar images on the web to a remote file
473- const [ { webDetection} ] = await client . webDetection (
474- `gs://${ bucketName } /${ fileName } `
475- ) ;
462+ const [ result ] = await client . webDetection ( `gs://${ bucketName } /${ fileName } ` ) ;
463+ const webDetection = result . webDetection ;
476464 if ( webDetection . fullMatchingImages . length ) {
477465 console . log (
478466 `Full matches found: ${ webDetection . fullMatchingImages . length } `
@@ -539,7 +527,8 @@ async function detectWebGeo(fileName) {
539527 } ;
540528
541529 // Detect similar images on the web to a local file
542- const [ { webDetection} ] = await client . webDetection ( request ) ;
530+ const [ result ] = await client . webDetection ( request ) ;
531+ const webDetection = result . webDetection ;
543532 webDetection . webEntities . forEach ( entity => {
544533 console . log ( `Score: ${ entity . score } ` ) ;
545534 console . log ( `Description: ${ entity . description } ` ) ;
@@ -575,7 +564,8 @@ async function detectWebGeoGCS(bucketName, fileName) {
575564 } ;
576565
577566 // Detect similar images on the web to a remote file
578- const [ { webDetection} ] = await client . webDetection ( request ) ;
567+ const [ result ] = await client . webDetection ( request ) ;
568+ const webDetection = result . webDetection ;
579569 webDetection . webEntities . forEach ( entity => {
580570 console . log ( `Score: ${ entity . score } ` ) ;
581571 console . log ( `Description: ${ entity . description } ` ) ;
@@ -598,7 +588,8 @@ async function detectFulltext(fileName) {
598588 // const fileName = 'Local image file, e.g. /path/to/image.png';
599589
600590 // Read a local image as a text document
601- const [ { fullTextAnnotation} ] = await client . documentTextDetection ( fileName ) ;
591+ const [ result ] = await client . documentTextDetection ( fileName ) ;
592+ const fullTextAnnotation = result . fullTextAnnotation ;
602593 console . log ( `Full text: ${ fullTextAnnotation . text } ` ) ;
603594 fullTextAnnotation . pages . forEach ( page => {
604595 page . blocks . forEach ( block => {
@@ -636,9 +627,10 @@ async function detectFulltextGCS(bucketName, fileName) {
636627 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
637628
638629 // Read a remote image as a text document
639- const [ { fullTextAnnotation } ] = await client . documentTextDetection (
630+ const [ result ] = await client . documentTextDetection (
640631 `gs://${ bucketName } /${ fileName } `
641632 ) ;
633+ const fullTextAnnotation = result . fullTextAnnotation ;
642634 console . log ( fullTextAnnotation . text ) ;
643635 // [END vision_fulltext_detection_gcs]
644636}
@@ -687,10 +679,9 @@ async function detectPdfText(bucketName, fileName) {
687679 } ;
688680
689681 const [ operation ] = await client . asyncBatchAnnotateFiles ( request ) ;
690- const filesResponse = await operation . promise ( ) ;
691-
682+ const [ filesResponse ] = await operation . promise ( ) ;
692683 const destinationUri =
693- filesResponse [ 0 ] . responses [ 0 ] . outputConfig . gcsDestination . uri ;
684+ filesResponse . responses [ 0 ] . outputConfig . gcsDestination . uri ;
694685 console . log ( 'Json saved to: ' + destinationUri ) ;
695686 // [END vision_text_detection_pdf_gcs]
696687}
@@ -712,10 +703,8 @@ async function localizeObjects(fileName) {
712703 image : { content : fs . readFileSync ( fileName ) } ,
713704 } ;
714705
715- const [
716- { localizedObjectAnnotations : objects } ,
717- ] = await client . objectLocalization ( request ) ;
718-
706+ const [ result ] = await client . objectLocalization ( request ) ;
707+ const objects = result . localizedObjectAnnotations ;
719708 objects . forEach ( object => {
720709 console . log ( `Name: ${ object . name } ` ) ;
721710 console . log ( `Confidence: ${ object . score } ` ) ;
@@ -738,10 +727,8 @@ async function localizeObjectsGCS(gcsUri) {
738727 */
739728 // const gcsUri = `gs://bucket/bucketImage.png`;
740729
741- const [
742- { localizedObjectAnnotations : objects } ,
743- ] = await client . objectLocalization ( gcsUri ) ;
744-
730+ const [ result ] = await client . objectLocalization ( gcsUri ) ;
731+ const objects = result . localizedObjectAnnotations ;
745732 objects . forEach ( object => {
746733 console . log ( `Name: ${ object . name } ` ) ;
747734 console . log ( `Confidence: ${ object . score } ` ) ;
0 commit comments