0
votes

I have been trying to use the google video intelligence API from https://cloud.google.com/video-intelligence/docs/libraries and I tried the exact same code. The response output was supposed to be in json format however the output was either a google.cloud.videointelligence_v1.types.AnnotateVideoResponse or something similar to that.

I have tried the code from many resources and recently from https://cloud.google.com/video-intelligence/docs/libraries but still no JSON output was given. What I got when I checked the type of output I got:

type(result)

google.cloud.videointelligence_v1.types.AnnotateVideoResponse

So, how do I get a JSON response from this?

2

2 Answers

1
votes

I have found a solution for this. What I had to do was import this

from google.protobuf.json_format import MessageToJson
import json

and run

job = client.annotate_video(
                            input_uri='gs://xxxx.mp4',
                            features=['OBJECT_TRACKING'])
result = job.result()

serialized = MessageToJson(result)

a = json.loads(serialized)
type(a)

what I was doing was turn the results into a dictionary. Or for more info, try going to this link: google forums thread

0
votes

If you specify an outputUri, the results will be stored in your GCS bucket in json format. https://cloud.google.com/video-intelligence/docs/reference/rest/v1/videos/annotate

It seems like you aren't storing the result in GCS. Instead you are getting the result via the GetOperation call, which has the result in AnnotateVideoResponse format.