@@ -29,7 +29,7 @@ function detectFaces(fileName) {
2929 // const fileName = 'Local image file, e.g. /path/to/image.png';
3030
3131 client
32- . faceDetection ( { image : { source : { filename : fileName } } } )
32+ . faceDetection ( fileName )
3333 . then ( results => {
3434 const faces = results [ 0 ] . faceAnnotations ;
3535
@@ -62,17 +62,9 @@ function detectFacesGCS(bucketName, fileName) {
6262 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
6363 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
6464
65- const request = {
66- image : {
67- source : {
68- imageUri : `gs://${ bucketName } /${ fileName } ` ,
69- } ,
70- } ,
71- } ;
72-
7365 // Performs face detection on the gcs file
7466 client
75- . faceDetection ( request )
67+ . faceDetection ( `gs:// ${ bucketName } / ${ fileName } ` )
7668 . then ( results => {
7769 const faces = results [ 0 ] . faceAnnotations ;
7870
@@ -106,7 +98,7 @@ function detectLabels(fileName) {
10698
10799 // Performs label detection on the local file
108100 client
109- . labelDetection ( { image : { source : { filename : fileName } } } )
101+ . labelDetection ( fileName )
110102 . then ( results => {
111103 const labels = results [ 0 ] . labelAnnotations ;
112104 console . log ( 'Labels:' ) ;
@@ -132,17 +124,9 @@ function detectLabelsGCS(bucketName, fileName) {
132124 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
133125 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
134126
135- const request = {
136- image : {
137- source : {
138- imageUri : `gs://${ bucketName } /${ fileName } ` ,
139- } ,
140- } ,
141- } ;
142-
143127 // Performs label detection on the gcs file
144128 client
145- . labelDetection ( request )
129+ . labelDetection ( `gs:// ${ bucketName } / ${ fileName } ` )
146130 . then ( results => {
147131 const labels = results [ 0 ] . labelAnnotations ;
148132 console . log ( 'Labels:' ) ;
@@ -168,7 +152,7 @@ function detectLandmarks(fileName) {
168152
169153 // Performs landmark detection on the local file
170154 client
171- . landmarkDetection ( { image : { source : { filename : fileName } } } )
155+ . landmarkDetection ( fileName )
172156 . then ( results => {
173157 const landmarks = results [ 0 ] . landmarkAnnotations ;
174158 console . log ( 'Landmarks:' ) ;
@@ -194,17 +178,9 @@ function detectLandmarksGCS(bucketName, fileName) {
194178 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
195179 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
196180
197- const request = {
198- image : {
199- source : {
200- imageUri : `gs://${ bucketName } /${ fileName } ` ,
201- } ,
202- } ,
203- } ;
204-
205181 // Performs landmark detection on the gcs file
206182 client
207- . landmarkDetection ( request )
183+ . landmarkDetection ( `gs:// ${ bucketName } / ${ fileName } ` )
208184 . then ( results => {
209185 const landmarks = results [ 0 ] . landmarkAnnotations ;
210186 console . log ( 'Landmarks:' ) ;
@@ -230,7 +206,7 @@ function detectText(fileName) {
230206
231207 // Performs text detection on the local file
232208 client
233- . textDetection ( { image : { source : { filename : fileName } } } )
209+ . textDetection ( fileName )
234210 . then ( results => {
235211 const detections = results [ 0 ] . textAnnotations ;
236212 console . log ( 'Text:' ) ;
@@ -256,17 +232,9 @@ function detectTextGCS(bucketName, fileName) {
256232 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
257233 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
258234
259- const request = {
260- image : {
261- source : {
262- imageUri : `gs://${ bucketName } /${ fileName } ` ,
263- } ,
264- } ,
265- } ;
266-
267235 // Performs text detection on the gcs file
268236 client
269- . textDetection ( request )
237+ . textDetection ( `gs:// ${ bucketName } / ${ fileName } ` )
270238 . then ( results => {
271239 const detections = results [ 0 ] . textAnnotations ;
272240 console . log ( 'Text:' ) ;
@@ -292,7 +260,7 @@ function detectLogos(fileName) {
292260
293261 // Performs logo detection on the local file
294262 client
295- . logoDetection ( { image : { source : { filename : fileName } } } )
263+ . logoDetection ( fileName )
296264 . then ( results => {
297265 const logos = results [ 0 ] . logoAnnotations ;
298266 console . log ( 'Logos:' ) ;
@@ -318,17 +286,9 @@ function detectLogosGCS(bucketName, fileName) {
318286 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
319287 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
320288
321- const request = {
322- image : {
323- source : {
324- imageUri : `gs://${ bucketName } /${ fileName } ` ,
325- } ,
326- } ,
327- } ;
328-
329289 // Performs logo detection on the gcs file
330290 client
331- . logoDetection ( request )
291+ . logoDetection ( `gs:// ${ bucketName } / ${ fileName } ` )
332292 . then ( results => {
333293 const logos = results [ 0 ] . logoAnnotations ;
334294 console . log ( 'Logos:' ) ;
@@ -354,7 +314,7 @@ function detectProperties(fileName) {
354314
355315 // Performs property detection on the local file
356316 client
357- . imageProperties ( { image : { source : { filename : fileName } } } )
317+ . imageProperties ( fileName )
358318 . then ( results => {
359319 const properties = results [ 0 ] . imagePropertiesAnnotation ;
360320 const colors = properties . dominantColors . colors ;
@@ -380,17 +340,9 @@ function detectPropertiesGCS(bucketName, fileName) {
380340 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
381341 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
382342
383- const request = {
384- image : {
385- source : {
386- imageUri : `gs://${ bucketName } /${ fileName } ` ,
387- } ,
388- } ,
389- } ;
390-
391343 // Performs property detection on the gcs file
392344 client
393- . imageProperties ( request )
345+ . imageProperties ( `gs:// ${ bucketName } / ${ fileName } ` )
394346 . then ( results => {
395347 const properties = results [ 0 ] . imagePropertiesAnnotation ;
396348 const colors = properties . dominantColors . colors ;
@@ -416,7 +368,7 @@ function detectSafeSearch(fileName) {
416368
417369 // Performs safe search detection on the local file
418370 client
419- . safeSearchDetection ( { image : { source : { filename : fileName } } } )
371+ . safeSearchDetection ( fileName )
420372 . then ( results => {
421373 const detections = results [ 0 ] . safeSearchAnnotation ;
422374
@@ -445,17 +397,9 @@ function detectSafeSearchGCS(bucketName, fileName) {
445397 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
446398 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
447399
448- const request = {
449- image : {
450- source : {
451- imageUri : `gs://${ bucketName } /${ fileName } ` ,
452- } ,
453- } ,
454- } ;
455-
456400 // Performs safe search property detection on the remote file
457401 client
458- . safeSearchDetection ( request )
402+ . safeSearchDetection ( `gs:// ${ bucketName } / ${ fileName } ` )
459403 . then ( results => {
460404 const detections = results [ 0 ] . safeSearchAnnotation ;
461405
@@ -486,7 +430,7 @@ function detectCropHints(fileName) {
486430
487431 // Find crop hints for the local file
488432 client
489- . cropHints ( { image : { source : { filename : fileName } } } )
433+ . cropHints ( fileName )
490434 . then ( results => {
491435 const cropHints = results [ 0 ] . cropHintsAnnotation ;
492436
@@ -518,17 +462,9 @@ function detectCropHintsGCS(bucketName, fileName) {
518462 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
519463 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
520464
521- const request = {
522- image : {
523- source : {
524- imageUri : `gs://${ bucketName } /${ fileName } ` ,
525- } ,
526- } ,
527- } ;
528-
529465 // Find crop hints for the remote file
530466 client
531- . cropHints ( request )
467+ . cropHints ( `gs:// ${ bucketName } / ${ fileName } ` )
532468 . then ( results => {
533469 const cropHints = results [ 0 ] . cropHintsAnnotation ;
534470
@@ -561,7 +497,7 @@ function detectWeb(fileName) {
561497
562498 // Detect similar images on the web to a local file
563499 client
564- . webDetection ( { image : { source : { filename : fileName } } } )
500+ . webDetection ( fileName )
565501 . then ( results => {
566502 const webDetection = results [ 0 ] . webDetection ;
567503
@@ -614,17 +550,9 @@ function detectWebGCS(bucketName, fileName) {
614550 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
615551 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
616552
617- const request = {
618- image : {
619- source : {
620- imageUri : `gs://${ bucketName } /${ fileName } ` ,
621- } ,
622- } ,
623- } ;
624-
625553 // Detect similar images on the web to a remote file
626554 client
627- . webDetection ( request )
555+ . webDetection ( `gs:// ${ bucketName } / ${ fileName } ` )
628556 . then ( results => {
629557 const webDetection = results [ 0 ] . webDetection ;
630558
@@ -678,7 +606,7 @@ function detectFulltext(fileName) {
678606
679607 // Read a local image as a text document
680608 client
681- . documentTextDetection ( { image : { source : { filename : fileName } } } )
609+ . documentTextDetection ( fileName )
682610 . then ( results => {
683611 const fullTextAnnotation = results [ 0 ] . fullTextAnnotation ;
684612 console . log ( fullTextAnnotation . text ) ;
@@ -704,17 +632,9 @@ function detectFulltextGCS(bucketName, fileName) {
704632 // const bucketName = 'Bucket where the file resides, e.g. my-bucket';
705633 // const fileName = 'Path to file within bucket, e.g. path/to/image.png';
706634
707- const request = {
708- image : {
709- source : {
710- imageUri : `gs://${ bucketName } /${ fileName } ` ,
711- } ,
712- } ,
713- } ;
714-
715635 // Read a remote image as a text document
716636 client
717- . documentTextDetection ( request )
637+ . documentTextDetection ( `gs:// ${ bucketName } / ${ fileName } ` )
718638 . then ( results => {
719639 const fullTextAnnotation = results [ 0 ] . fullTextAnnotation ;
720640 console . log ( fullTextAnnotation . text ) ;
0 commit comments