Last active
May 20, 2021 17:29
-
-
Save ZackAkil/9046427f3a0087b99eabc363f1a43230 to your computer and use it in GitHub Desktop.
Google Cloud Function code for Video Object Detection on Storage 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 | |
import time | |
video_client = videointelligence.VideoIntelligenceServiceClient() | |
OUTPUT_BUCKET = 'gs://YOUR OUTPUT BUCKET NAME/' | |
features = [ | |
videointelligence.Feature.OBJECT_TRACKING | |
] | |
def hello_gcs(event, context): | |
print(event) | |
gcs_uri = 'gs://' + event['bucket'] + '/' + event['name'] | |
just_file_name = event['name'].split('.')[0] | |
output_uri = OUTPUT_BUCKET + "{} - {}.json".format(just_file_name, time.time()) | |
operation = video_client.annotate_video( | |
request={"features": features, | |
"input_uri": gcs_uri, | |
"output_uri": output_uri} | |
) | |
print("\nProcessing video for object 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