Skip to content

Remove video face #1348

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

Merged
merged 3 commits into from
Mar 19, 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
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.