Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Video Intelligence region tag update #1639

Merged
merged 5 commits into from
Aug 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions video/cloud-client/analyze/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def analyze_labels(path):


def analyze_labels_file(path):
# [START video_analyze_labels_local]
# [START video_analyze_labels]
"""Detect labels given a file path."""
video_client = videointelligence.VideoIntelligenceServiceClient()
features = [videointelligence.enums.Feature.LABEL_DETECTION]
Expand Down Expand Up @@ -207,7 +207,7 @@ def analyze_labels_file(path):
print('\tFirst frame time offset: {}s'.format(time_offset))
print('\tFirst frame confidence: {}'.format(frame.confidence))
print('\n')
# [END video_analyze_labels_local]
# [END video_analyze_labels]


def analyze_shots(path):
Expand Down
4 changes: 2 additions & 2 deletions video/cloud-client/analyze/beta_snippets.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
from google.cloud import videointelligence_v1p1beta1 as videointelligence


# [START video_speech_transcription]
# [START video_speech_transcription_gcs_beta]
def speech_transcription(input_uri):
"""Transcribe speech from a video stored on GCS."""
video_client = videointelligence.VideoIntelligenceServiceClient()
Expand Down Expand Up @@ -66,7 +66,7 @@ def speech_transcription(input_uri):
start_time.seconds + start_time.nanos * 1e-9,
end_time.seconds + end_time.nanos * 1e-9,
word))
# [END video_speech_transcription]
# [END video_speech_transcription_gcs_beta]


if __name__ == '__main__':
Expand Down
24 changes: 12 additions & 12 deletions video/cloud-client/labels/labels.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,29 +27,29 @@

"""

# [START full_tutorial]
# [START imports]
# [START video_label_tutorial]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this use plural labels to be more consistent with the directory and file name?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I can make this update if you prefer, but the other context to note is that page in the docs is called label-tutorial and the title of the tutorial is Label Detection Tutorial.
https://cloud.google.com/video-intelligence/docs/label-tutorial

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no strong preference on this. let's keep it as you have it now. thanks.

# [START video_label_tutorial_imports]
import argparse

from google.cloud import videointelligence
# [END imports]
# [END video_label_tutorial_imports]


def analyze_labels(path):
""" Detects labels given a GCS path. """
# [START construct_request]
# [START video_label_tutorial_construct_request]
video_client = videointelligence.VideoIntelligenceServiceClient()
features = [videointelligence.enums.Feature.LABEL_DETECTION]
operation = video_client.annotate_video(path, features=features)
# [END construct_request]
# [END video_label_tutorial_construct_request]
print('\nProcessing video for label annotations:')

# [START check_operation]
# [START video_label_tutorial_check_operation]
result = operation.result(timeout=90)
print('\nFinished processing.')
# [END check_operation]
# [END video_label_tutorial_check_operation]

# [START parse_response]
# [START video_label_tutorial_parse_response]
segment_labels = result.annotation_results[0].segment_label_annotations
for i, segment_label in enumerate(segment_labels):
print('Video label description: {}'.format(
Expand All @@ -68,17 +68,17 @@ def analyze_labels(path):
print('\tSegment {}: {}'.format(i, positions))
print('\tConfidence: {}'.format(confidence))
print('\n')
# [END parse_response]
# [END video_label_tutorial_parse_response]


if __name__ == '__main__':
# [START running_app]
# [START video_label_tutorial_run_application]
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('path', help='GCS file path for label detection.')
args = parser.parse_args()

analyze_labels(args.path)
# [END running_app]
# [END full_tutorial]
# [END video_label_tutorial_run_application]
# [END video_label_tutorial]
4 changes: 2 additions & 2 deletions video/cloud-client/quickstart/quickstart.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@


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

video_client = videointelligence.VideoIntelligenceServiceClient()
Expand Down Expand Up @@ -55,7 +55,7 @@ def run_quickstart():
print('\tSegment {}: {}'.format(i, positions))
print('\tConfidence: {}'.format(confidence))
print('\n')
# [END videointelligence_quickstart]
# [END video_quickstart]


if __name__ == '__main__':
Expand Down
24 changes: 12 additions & 12 deletions video/cloud-client/shotchange/shotchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,46 +26,46 @@

"""

# [START full_tutorial]
# [START imports]
# [START video_shot_tutorial]
# [START video_shot_tutorial_imports]
import argparse

from google.cloud import videointelligence
# [END imports]
# [END video_shot_tutorial_imports]


def analyze_shots(path):
""" Detects camera shot changes. """
# [START construct_request]
# [START video_shot_tutorial_construct_request]
video_client = videointelligence.VideoIntelligenceServiceClient()
features = [videointelligence.enums.Feature.SHOT_CHANGE_DETECTION]
operation = video_client.annotate_video(path, features=features)
# [END construct_request]
# [END video_shot_tutorial_construct_request]
print('\nProcessing video for shot change annotations:')

# [START check_operation]
# [START video_shot_tutorial_check_operation]
result = operation.result(timeout=90)
print('\nFinished processing.')
# [END check_operation]
# [END video_shot_tutorial_check_operation]

# [START parse_response]
# [START video_shot_tutorial_parse_response]
for i, shot in enumerate(result.annotation_results[0].shot_annotations):
start_time = (shot.start_time_offset.seconds +
shot.start_time_offset.nanos / 1e9)
end_time = (shot.end_time_offset.seconds +
shot.end_time_offset.nanos / 1e9)
print('\tShot {}: {} to {}'.format(i, start_time, end_time))
# [END parse_response]
# [END video_shot_tutorial_parse_response]


if __name__ == '__main__':
# [START running_app]
# [START video_shot_tutorial_run_application]
parser = argparse.ArgumentParser(
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
parser.add_argument('path', help='GCS path for shot change detection.')
args = parser.parse_args()

analyze_shots(args.path)
# [END running_app]
# [END full_tutorial]
# [END video_shot_tutorial_run_application]
# [END video_shot_tutorial]