Skip to content

Commit 9ffd315

Browse files
committed
remove face from analyze.py
1 parent 53d300f commit 9ffd315

File tree

2 files changed

+1
-64
lines changed

2 files changed

+1
-64
lines changed

video/cloud-client/analyze/analyze.py

Lines changed: 1 addition & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,11 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
"""This application demonstrates face detection, label detection,
17+
"""This application demonstrates label detection,
1818
explicit content, and shot change detection using the Google Cloud API.
1919
2020
Usage Examples:
2121
22-
python analyze.py faces gs://demomaker/google_gmail.mp4
2322
python analyze.py labels gs://cloud-ml-sandbox/video/chicago.mp4
2423
python analyze.py labels_file resources/cat.mp4
2524
python analyze.py shots gs://demomaker/gbikes_dinosaur.mp4
@@ -55,52 +54,6 @@ def analyze_explicit_content(path):
5554
likely_string[frame.pornography_likelihood]))
5655

5756

58-
def analyze_faces(path):
59-
""" Detects faces given a GCS path. """
60-
video_client = videointelligence.VideoIntelligenceServiceClient()
61-
features = [videointelligence.enums.Feature.FACE_DETECTION]
62-
63-
config = videointelligence.types.FaceDetectionConfig(
64-
include_bounding_boxes=True)
65-
context = videointelligence.types.VideoContext(
66-
face_detection_config=config)
67-
68-
operation = video_client.annotate_video(
69-
path, features=features, video_context=context)
70-
print('\nProcessing video for face annotations:')
71-
72-
result = operation.result(timeout=600)
73-
print('\nFinished processing.')
74-
75-
# first result is retrieved because a single video was processed
76-
faces = result.annotation_results[0].face_annotations
77-
for face_id, face in enumerate(faces):
78-
print('Face {}'.format(face_id))
79-
print('Thumbnail size: {}'.format(len(face.thumbnail)))
80-
81-
for segment_id, segment in enumerate(face.segments):
82-
start_time = (segment.segment.start_time_offset.seconds +
83-
segment.segment.start_time_offset.nanos / 1e9)
84-
end_time = (segment.segment.end_time_offset.seconds +
85-
segment.segment.end_time_offset.nanos / 1e9)
86-
positions = '{}s to {}s'.format(start_time, end_time)
87-
print('\tSegment {}: {}'.format(segment_id, positions))
88-
89-
# There are typically many frames for each face,
90-
# here we print information on only the first frame.
91-
frame = face.frames[0]
92-
time_offset = (frame.time_offset.seconds +
93-
frame.time_offset.nanos / 1e9)
94-
box = frame.normalized_bounding_boxes[0]
95-
print('First frame time offset: {}s'.format(time_offset))
96-
print('First frame normalized bounding box:')
97-
print('\tleft: {}'.format(box.left))
98-
print('\ttop: {}'.format(box.top))
99-
print('\tright: {}'.format(box.right))
100-
print('\tbottom: {}'.format(box.bottom))
101-
print('\n')
102-
103-
10457
def analyze_labels(path):
10558
""" Detects labels given a GCS path. """
10659
video_client = videointelligence.VideoIntelligenceServiceClient()
@@ -275,9 +228,6 @@ def analyze_shots(path):
275228
description=__doc__,
276229
formatter_class=argparse.RawDescriptionHelpFormatter)
277230
subparsers = parser.add_subparsers(dest='command')
278-
analyze_faces_parser = subparsers.add_parser(
279-
'faces', help=analyze_faces.__doc__)
280-
analyze_faces_parser.add_argument('path')
281231
analyze_labels_parser = subparsers.add_parser(
282232
'labels', help=analyze_labels.__doc__)
283233
analyze_labels_parser.add_argument('path')
@@ -293,8 +243,6 @@ def analyze_shots(path):
293243

294244
args = parser.parse_args()
295245

296-
if args.command == 'faces':
297-
analyze_faces(args.path)
298246
if args.command == 'labels':
299247
analyze_labels(args.path)
300248
if args.command == 'labels_file':

video/cloud-client/analyze/analyze_test.py

Lines changed: 0 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@
2323

2424
BUCKET = os.environ['CLOUD_STORAGE_BUCKET']
2525
LABELS_FILE_PATH = '/video/cat.mp4'
26-
FACES_FILE_PATH = '/video/googlework.mp4'
2726
EXPLICIT_CONTENT_FILE_PATH = '/video/cat.mp4'
2827
SHOTS_FILE_PATH = '/video/gbikes_dinosaur.mp4'
2928

@@ -36,16 +35,6 @@ def test_analyze_shots(capsys):
3635
assert 'Shot 1:' in out
3736

3837

39-
@pytest.mark.xfail(reason='This feature is currently \
40-
not visible to all projects.')
41-
@pytest.mark.slow
42-
def test_analyze_faces(capsys):
43-
analyze.analyze_faces(
44-
'gs://{}{}'.format(BUCKET, FACES_FILE_PATH))
45-
out, _ = capsys.readouterr()
46-
assert 'Thumbnail' in out
47-
48-
4938
@pytest.mark.slow
5039
def test_analyze_labels(capsys):
5140
analyze.analyze_labels(

0 commit comments

Comments
 (0)