Skip to content

Commit 3c12839

Browse files
dizcologydanoscarmike
authored andcommitted
* update samples to v1 * replace while loop with operation.result(timeout) * addressing review comments * flake * flake
1 parent be80ab6 commit 3c12839

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

packages/google-cloud-videointelligence/samples/quickstart/quickstart.py

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,28 +25,20 @@
2525

2626
def run_quickstart():
2727
# [START videointelligence_quickstart]
28-
import sys
29-
import time
28+
from google.cloud import videointelligence
3029

31-
from google.cloud import videointelligence_v1beta2
32-
from google.cloud.videointelligence_v1beta2 import enums
33-
34-
video_client = videointelligence_v1beta2.VideoIntelligenceServiceClient()
35-
features = [enums.Feature.LABEL_DETECTION]
36-
operation = video_client.annotate_video('gs://demomaker/cat.mp4', features)
30+
video_client = videointelligence.VideoIntelligenceServiceClient()
31+
features = [videointelligence.enums.Feature.LABEL_DETECTION]
32+
operation = video_client.annotate_video(
33+
'gs://demomaker/cat.mp4', features=features)
3734
print('\nProcessing video for label annotations:')
3835

39-
while not operation.done():
40-
sys.stdout.write('.')
41-
sys.stdout.flush()
42-
time.sleep(15)
43-
36+
result = operation.result(timeout=90)
4437
print('\nFinished processing.')
4538

4639
# first result is retrieved because a single video was processed
47-
results = operation.result().annotation_results[0]
48-
49-
for i, segment_label in enumerate(results.segment_label_annotations):
40+
segment_labels = result.annotation_results[0].segment_label_annotations
41+
for i, segment_label in enumerate(segment_labels):
5042
print('Video label description: {}'.format(
5143
segment_label.entity.description))
5244
for category_entity in segment_label.category_entities:
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
google-cloud-videointelligence==0.28.0
1+
google-cloud-videointelligence==1.0.0

0 commit comments

Comments
 (0)