Skip to content

Commit

Permalink
Access Display Names of enum fields via enum object [(#1738)](GoogleC…
Browse files Browse the repository at this point in the history
…loudPlatform/python-docs-samples#1738)

* Get display name of enums using IntEnum

Requires updating google-cloud-language to 1.1.0

* Add note about gs://demomaker for video test files

* Get display name of enums using IntEnum

* Get display name of enums using IntEnum

* Revert "Add note about gs://demomaker for video test files"

This reverts commit 39d9bfff03201f7c6dcb38fee3856dd537ab4b62.
  • Loading branch information
beccasaurus authored and danoscarmike committed Sep 30, 2020
1 parent a23b589 commit eb6f109
Showing 1 changed file with 3 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import io

from google.cloud import videointelligence
from google.cloud.videointelligence import enums


def analyze_explicit_content(path):
Expand All @@ -44,15 +45,12 @@ def analyze_explicit_content(path):
result = operation.result(timeout=90)
print('\nFinished processing.')

likely_string = ("Unknown", "Very unlikely", "Unlikely", "Possible",
"Likely", "Very likely")

# first result is retrieved because a single video was processed
for frame in result.annotation_results[0].explicit_annotation.frames:
likelihood = enums.Likelihood(frame.pornography_likelihood)
frame_time = frame.time_offset.seconds + frame.time_offset.nanos / 1e9
print('Time: {}s'.format(frame_time))
print('\tpornography: {}'.format(
likely_string[frame.pornography_likelihood]))
print('\tpornography: {}'.format(likelihood.name))
# [END video_analyze_explicit_content]


Expand Down

0 comments on commit eb6f109

Please sign in to comment.