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 Jon Wayne Parrott committed Sep 19, 2017
1 parent 96bb40f commit 26b6337
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
23 changes: 11 additions & 12 deletions samples/shotchange/shotchange.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,15 @@
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
# [END imports]


def analyze_shots(path):
""" Detects camera shot changes. """
# [START construct_request]
video_client = (video_intelligence_service_client.
VideoIntelligenceServiceClient())
video_client = videointelligence_v1beta2.VideoIntelligenceServiceClient()
features = [enums.Feature.SHOT_CHANGE_DETECTION]
operation = video_client.annotate_video(path, features)
# [END construct_request]
Expand All @@ -58,13 +56,14 @@ def analyze_shots(path):
# [END check_operation]

# [START parse_response]
shots = operation.result().annotation_results[0]

for note, shot in enumerate(shots.shot_annotations):
print('Scene {}: {} to {}'.format(
note,
shot.start_time_offset,
shot.end_time_offset))
shots = operation.result().annotation_results[0].shot_annotations

for i, shot in enumerate(shots):
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]


Expand Down
2 changes: 1 addition & 1 deletion samples/shotchange/shotchange_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ def test_shots_dino(capsys):
shotchange.analyze_shots(
'gs://{}{}'.format(BUCKET, SHOTS_FILE_PATH))
out, _ = capsys.readouterr()
assert 'Scene 1:' in out
assert 'Shot 1:' in out

0 comments on commit 26b6337

Please sign in to comment.