Last active
November 11, 2020 17:48
-
-
Save ZackAkil/c72735d2e1b6ee8712e6f4de14a99515 to your computer and use it in GitHub Desktop.
Cloud Function code for Video Intelligence API pose detection on a Storage Bucket Trigger
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from google.cloud import videointelligence_v1p3beta1 as videointelligence | |
client = videointelligence.VideoIntelligenceServiceClient() | |
OUTPUT_BUCKET = 'gs://YOUR OUTPUT BUCKET NAME/' | |
# configure person detection | |
config = videointelligence.types.PersonDetectionConfig( | |
include_bounding_boxes=True, # include bounding box round whole body | |
include_attributes=False, # include cloths info | |
include_pose_landmarks=True, # include body joints info | |
) | |
video_context = videointelligence.types.VideoContext(person_detection_config=config) | |
def hello_gcs(event, context): | |
print(event) | |
gcs_uri = 'gs://' + event['bucket'] + '/' + event['name'] | |
just_file_name = event['name'].split('.')[0] | |
operation = client.annotate_video( | |
input_uri=gcs_uri, | |
features=[videointelligence.enums.Feature.PERSON_DETECTION], | |
video_context=video_context, | |
output_uri = OUTPUT_BUCKET + just_file_name + '.json' | |
) | |
print("\nProcessing video for person detection annotations.") | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
google-cloud-videointelligence |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment