2727
2828"""
2929
30- # [START full_tutorial ]
31- # [START imports ]
30+ # [START video_label_tutorial ]
31+ # [START video_label_tutorial_imports ]
3232import argparse
3333
3434from google .cloud import videointelligence
35- # [END imports ]
35+ # [END video_label_tutorial_imports ]
3636
3737
3838def analyze_labels (path ):
3939 """ Detects labels given a GCS path. """
40- # [START construct_request ]
40+ # [START video_label_tutorial_construct_request ]
4141 video_client = videointelligence .VideoIntelligenceServiceClient ()
4242 features = [videointelligence .enums .Feature .LABEL_DETECTION ]
4343 operation = video_client .annotate_video (path , features = features )
44- # [END construct_request ]
44+ # [END video_label_tutorial_construct_request ]
4545 print ('\n Processing video for label annotations:' )
4646
47- # [START check_operation ]
47+ # [START video_label_tutorial_check_operation ]
4848 result = operation .result (timeout = 90 )
4949 print ('\n Finished processing.' )
50- # [END check_operation ]
50+ # [END video_label_tutorial_check_operation ]
5151
52- # [START parse_response ]
52+ # [START video_label_tutorial_parse_response ]
5353 segment_labels = result .annotation_results [0 ].segment_label_annotations
5454 for i , segment_label in enumerate (segment_labels ):
5555 print ('Video label description: {}' .format (
@@ -68,17 +68,17 @@ def analyze_labels(path):
6868 print ('\t Segment {}: {}' .format (i , positions ))
6969 print ('\t Confidence: {}' .format (confidence ))
7070 print ('\n ' )
71- # [END parse_response ]
71+ # [END video_label_tutorial_parse_response ]
7272
7373
7474if __name__ == '__main__' :
75- # [START running_app ]
75+ # [START video_label_tutorial_run_application ]
7676 parser = argparse .ArgumentParser (
7777 description = __doc__ ,
7878 formatter_class = argparse .RawDescriptionHelpFormatter )
7979 parser .add_argument ('path' , help = 'GCS file path for label detection.' )
8080 args = parser .parse_args ()
8181
8282 analyze_labels (args .path )
83- # [END running_app ]
84- # [END full_tutorial ]
83+ # [END video_label_tutorial_run_application ]
84+ # [END video_label_tutorial ]
0 commit comments