Skip to content

Commit

Permalink
Remove video face (#1348)
Browse files Browse the repository at this point in the history
  • Loading branch information
dizcology authored and andrewsg committed Mar 19, 2018
1 parent 07da8e3 commit 2922602
Show file tree
Hide file tree
Showing 8 changed files with 5 additions and 315 deletions.
10 changes: 4 additions & 6 deletions video/cloud-client/analyze/README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ This directory contains samples for Google Cloud Video Intelligence API. `Google



.. _Google Cloud Video Intelligence API: https://cloud.google.com/video-intelligence/docs
.. _Google Cloud Video Intelligence API: https://cloud.google.com/video-intelligence/docs

Setup
-------------------------------------------------------------------------------
Expand Down Expand Up @@ -70,22 +70,20 @@ To run this sample:
$ python analyze.py
usage: analyze.py [-h] {faces,labels,labels_file,explicit_content,shots} ...
usage: analyze.py [-h] {labels,labels_file,explicit_content,shots} ...
This application demonstrates face detection, label detection,
This application demonstrates label detection,
explicit content, and shot change detection using the Google Cloud API.
Usage Examples:
python analyze.py faces gs://demomaker/google_gmail.mp4
python analyze.py labels gs://cloud-ml-sandbox/video/chicago.mp4
python analyze.py labels_file resources/cat.mp4
python analyze.py shots gs://demomaker/gbikes_dinosaur.mp4
python analyze.py explicit_content gs://demomaker/gbikes_dinosaur.mp4
positional arguments:
{faces,labels,labels_file,explicit_content,shots}
faces Detects faces given a GCS path.
{labels,labels_file,explicit_content,shots}
labels Detects labels given a GCS path.
labels_file Detect labels given a file path.
explicit_content Detects explicit content from the GCS path to a video.
Expand Down
54 changes: 1 addition & 53 deletions video/cloud-client/analyze/analyze.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@
# See the License for the specific language governing permissions and
# limitations under the License.

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


def analyze_faces(path):
""" Detects faces given a GCS path. """
video_client = videointelligence.VideoIntelligenceServiceClient()
features = [videointelligence.enums.Feature.FACE_DETECTION]

config = videointelligence.types.FaceDetectionConfig(
include_bounding_boxes=True)
context = videointelligence.types.VideoContext(
face_detection_config=config)

operation = video_client.annotate_video(
path, features=features, video_context=context)
print('\nProcessing video for face annotations:')

result = operation.result(timeout=600)
print('\nFinished processing.')

# first result is retrieved because a single video was processed
faces = result.annotation_results[0].face_annotations
for face_id, face in enumerate(faces):
print('Face {}'.format(face_id))
print('Thumbnail size: {}'.format(len(face.thumbnail)))

for segment_id, segment in enumerate(face.segments):
start_time = (segment.segment.start_time_offset.seconds +
segment.segment.start_time_offset.nanos / 1e9)
end_time = (segment.segment.end_time_offset.seconds +
segment.segment.end_time_offset.nanos / 1e9)
positions = '{}s to {}s'.format(start_time, end_time)
print('\tSegment {}: {}'.format(segment_id, positions))

# There are typically many frames for each face,
# here we print information on only the first frame.
frame = face.frames[0]
time_offset = (frame.time_offset.seconds +
frame.time_offset.nanos / 1e9)
box = frame.normalized_bounding_boxes[0]
print('First frame time offset: {}s'.format(time_offset))
print('First frame normalized bounding box:')
print('\tleft: {}'.format(box.left))
print('\ttop: {}'.format(box.top))
print('\tright: {}'.format(box.right))
print('\tbottom: {}'.format(box.bottom))
print('\n')


def analyze_labels(path):
""" Detects labels given a GCS path. """
video_client = videointelligence.VideoIntelligenceServiceClient()
Expand Down Expand Up @@ -275,9 +228,6 @@ def analyze_shots(path):
description=__doc__,
formatter_class=argparse.RawDescriptionHelpFormatter)
subparsers = parser.add_subparsers(dest='command')
analyze_faces_parser = subparsers.add_parser(
'faces', help=analyze_faces.__doc__)
analyze_faces_parser.add_argument('path')
analyze_labels_parser = subparsers.add_parser(
'labels', help=analyze_labels.__doc__)
analyze_labels_parser.add_argument('path')
Expand All @@ -293,8 +243,6 @@ def analyze_shots(path):

args = parser.parse_args()

if args.command == 'faces':
analyze_faces(args.path)
if args.command == 'labels':
analyze_labels(args.path)
if args.command == 'labels_file':
Expand Down
11 changes: 0 additions & 11 deletions video/cloud-client/analyze/analyze_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@

BUCKET = os.environ['CLOUD_STORAGE_BUCKET']
LABELS_FILE_PATH = '/video/cat.mp4'
FACES_FILE_PATH = '/video/googlework.mp4'
EXPLICIT_CONTENT_FILE_PATH = '/video/cat.mp4'
SHOTS_FILE_PATH = '/video/gbikes_dinosaur.mp4'

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


@pytest.mark.xfail(reason='This feature is currently \
not visible to all projects.')
@pytest.mark.slow
def test_analyze_faces(capsys):
analyze.analyze_faces(
'gs://{}{}'.format(BUCKET, FACES_FILE_PATH))
out, _ = capsys.readouterr()
assert 'Thumbnail' in out


@pytest.mark.slow
def test_analyze_labels(capsys):
analyze.analyze_labels(
Expand Down
110 changes: 0 additions & 110 deletions video/cloud-client/faces/README.rst

This file was deleted.

22 changes: 0 additions & 22 deletions video/cloud-client/faces/README.rst.in

This file was deleted.

77 changes: 0 additions & 77 deletions video/cloud-client/faces/faces.py

This file was deleted.

35 changes: 0 additions & 35 deletions video/cloud-client/faces/faces_test.py

This file was deleted.

1 change: 0 additions & 1 deletion video/cloud-client/faces/requirements.txt

This file was deleted.

0 comments on commit 2922602

Please sign in to comment.