Skip to content

Commit

Permalink
update samples to v1 [(#1221)](#1221)
Browse files Browse the repository at this point in the history
* update samples to v1

* replace while loop with operation.result(timeout)

* addressing review comments

* flake

* flake
  • Loading branch information
dizcology authored and danoscarmike committed Nov 16, 2020
1 parent ed08030 commit 1787928
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 17 deletions.
24 changes: 8 additions & 16 deletions videointelligence/samples/quickstart/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,28 +25,20 @@

def run_quickstart():
# [START videointelligence_quickstart]
import sys
import time
from google.cloud import videointelligence

from google.cloud import videointelligence_v1beta2
from google.cloud.videointelligence_v1beta2 import enums

video_client = videointelligence_v1beta2.VideoIntelligenceServiceClient()
features = [enums.Feature.LABEL_DETECTION]
operation = video_client.annotate_video('gs://demomaker/cat.mp4', features)
video_client = videointelligence.VideoIntelligenceServiceClient()
features = [videointelligence.enums.Feature.LABEL_DETECTION]
operation = video_client.annotate_video(
'gs://demomaker/cat.mp4', features=features)
print('\nProcessing video for label annotations:')

while not operation.done():
sys.stdout.write('.')
sys.stdout.flush()
time.sleep(15)

result = operation.result(timeout=90)
print('\nFinished processing.')

# first result is retrieved because a single video was processed
results = operation.result().annotation_results[0]

for i, segment_label in enumerate(results.segment_label_annotations):
segment_labels = result.annotation_results[0].segment_label_annotations
for i, segment_label in enumerate(segment_labels):
print('Video label description: {}'.format(
segment_label.entity.description))
for category_entity in segment_label.category_entities:
Expand Down
2 changes: 1 addition & 1 deletion videointelligence/samples/quickstart/requirements.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
google-cloud-videointelligence==0.28.0
google-cloud-videointelligence==1.0.0

0 comments on commit 1787928

Please sign in to comment.