Skip to content

Commit 26b6337

Browse files
dizcologyJon Wayne Parrott
authored and
Jon Wayne Parrott
committed
* 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
1 parent 96bb40f commit 26b6337

File tree

2 files changed

+12
-13
lines changed

2 files changed

+12
-13
lines changed

samples/shotchange/shotchange.py

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -32,17 +32,15 @@
3232
import sys
3333
import time
3434

35-
from google.cloud.gapic.videointelligence.v1beta1 import enums
36-
from google.cloud.gapic.videointelligence.v1beta1 import (
37-
video_intelligence_service_client)
35+
from google.cloud import videointelligence_v1beta2
36+
from google.cloud.videointelligence_v1beta2 import enums
3837
# [END imports]
3938

4039

4140
def analyze_shots(path):
4241
""" Detects camera shot changes. """
4342
# [START construct_request]
44-
video_client = (video_intelligence_service_client.
45-
VideoIntelligenceServiceClient())
43+
video_client = videointelligence_v1beta2.VideoIntelligenceServiceClient()
4644
features = [enums.Feature.SHOT_CHANGE_DETECTION]
4745
operation = video_client.annotate_video(path, features)
4846
# [END construct_request]
@@ -58,13 +56,14 @@ def analyze_shots(path):
5856
# [END check_operation]
5957

6058
# [START parse_response]
61-
shots = operation.result().annotation_results[0]
62-
63-
for note, shot in enumerate(shots.shot_annotations):
64-
print('Scene {}: {} to {}'.format(
65-
note,
66-
shot.start_time_offset,
67-
shot.end_time_offset))
59+
shots = operation.result().annotation_results[0].shot_annotations
60+
61+
for i, shot in enumerate(shots):
62+
start_time = (shot.start_time_offset.seconds +
63+
shot.start_time_offset.nanos / 1e9)
64+
end_time = (shot.end_time_offset.seconds +
65+
shot.end_time_offset.nanos / 1e9)
66+
print('\tShot {}: {} to {}'.format(i, start_time, end_time))
6867
# [END parse_response]
6968

7069

samples/shotchange/shotchange_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,4 @@ def test_shots_dino(capsys):
2929
shotchange.analyze_shots(
3030
'gs://{}{}'.format(BUCKET, SHOTS_FILE_PATH))
3131
out, _ = capsys.readouterr()
32-
assert 'Scene 1:' in out
32+
assert 'Shot 1:' in out

0 commit comments

Comments
 (0)