Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
* update analyze_safe_search

* update analyze_shots

* update explicit_content_detection and test

* update fece detection

* update label detection (path)

* update label detection (file)

* flake

* safe search --> explicit content

* update faces tutorial

* update client library quickstart

* update shotchange tutorial

* update labels tutorial

* correct spelling

* correction start_time_offset

* import order

* rebased
  • Loading branch information
dizcology authored and danoscarmike committed Nov 16, 2020
1 parent 640a0c5 commit 0ab6b58
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,10 @@ def run_quickstart():
import sys
import time

from google.cloud.gapic.videointelligence.v1beta1 import enums
from google.cloud.gapic.videointelligence.v1beta1 import (
video_intelligence_service_client)
from google.cloud import videointelligence_v1beta2
from google.cloud.videointelligence_v1beta2 import enums

video_client = (video_intelligence_service_client.
VideoIntelligenceServiceClient())
video_client = videointelligence_v1beta2.VideoIntelligenceServiceClient()
features = [enums.Feature.LABEL_DETECTION]
operation = video_client.annotate_video('gs://demomaker/cat.mp4', features)
print('\nProcessing video for label annotations:')
Expand All @@ -46,19 +44,22 @@ def run_quickstart():
# first result is retrieved because a single video was processed
results = operation.result().annotation_results[0]

for label in results.label_annotations:
print('Label description: {}'.format(label.description))
print('Locations:')

for l, location in enumerate(label.locations):
positions = 'Entire video'
if (location.segment.start_time_offset != -1 or
location.segment.end_time_offset != -1):
positions = '{} to {}'.format(
location.segment.start_time_offset / 1000000.0,
location.segment.end_time_offset / 1000000.0)
print('\t{}: {}'.format(l, positions))
for i, segment_label in enumerate(results.segment_label_annotations):
print('Video label description: {}'.format(
segment_label.entity.description))
for category_entity in segment_label.category_entities:
print('\tLabel category description: {}'.format(
category_entity.description))

for i, segment in enumerate(segment_label.segments):
start_time = (segment.segment.start_time_offset.seconds +
segment.segment.start_time_offset.nanos / 1e9)
end_time = (segment.segment.end_time_offset.seconds +
segment.segment.end_time_offset.nanos / 1e9)
positions = '{}s to {}s'.format(start_time, end_time)
confidence = segment.confidence
print('\tSegment {}: {}'.format(i, positions))
print('\tConfidence: {}'.format(confidence))
print('\n')
# [END videointelligence_quickstart]

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@
def test_quickstart(capsys):
quickstart.run_quickstart()
out, _ = capsys.readouterr()
assert 'Whiskers' in out
assert 'Video label description: cat' in out

0 comments on commit 0ab6b58

Please sign in to comment.