Re: [cloud-videointel-discuss] Video Intelligence API response not in JSON (python)

313 views
Skip to first unread message

Lei Yang

unread,
Oct 15, 2019, 9:57:49 PM10/15/19
to Iman Zulhisham, cloud-videointel-discuss

Hi Iman,

That library returns plain protobuf objects, which can be serialized to JSON using:

from google.protobuf.json_format import MessageToJson

serialized = MessageToJson(original)

You also can use output_uri in AnnotateVideoRequest to get json output in the  output file pointed by output_uri:

 https://cloud.google.com/video-intelligence/docs/reference/rpc/google.cloud.videointelligence.v1?hl=ID#google.cloud.videointelligence.v1.AnnotateVideoRequest

Thanks & Regards,


On Tue, Oct 15, 2019 at 4:20 PM Iman Zulhisham <iman.zul...@gmail.com> wrote:
I have used the code for python from https://cloud.google.com/video-intelligence/docs/libraries and the documentation mentioned that my output would be in JSON format however the format I got was: "google.cloud.videointelligence_v1.types.AnnotateVideoResponse" or something similar. I have tried other codes from other documentations but still end up having the same problem. 

I have also tried to convert the "google.cloud.videointelligence_v1.types.AnnotateVideoResponse" into a string and then into a JSON but got this error instead: "TypeError: Object of type 'AnnotateVideoResponse' is not JSON serializable" 

So how do I fix this? Please help. 

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Video Intelligence API Discussion Google Group (cloud-videoi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Video Intelligence API community and the Google Cloud Video Intelligence API Team.
---
You received this message because you are subscribed to the Google Groups "cloud-videointel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-videointel-d...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/cloud-videointel-discuss/ec07333e-4c50-4e6c-9f6f-516e73cca3a0%40googlegroups.com.


--

Lei Yang (杨蕾) | Software Engineer, Play | yanga...@google.com | 650-214-4097

Iman Zulhisham

unread,
Oct 16, 2019, 8:26:18 PM10/16/19
to cloud-videointel-discuss
Hi Lei Yang,

Thank you for the respond. I have successfully turned it into a JSON output. 

Thank you for your help!


On Wednesday, October 16, 2019 at 9:57:49 AM UTC+8, Lei Yang wrote:

Hi Iman,

That library returns plain protobuf objects, which can be serialized to JSON using:

from google.protobuf.json_format import MessageToJson

serialized = MessageToJson(original)

You also can use output_uri in AnnotateVideoRequest to get json output in the  output file pointed by output_uri:

 https://cloud.google.com/video-intelligence/docs/reference/rpc/google.cloud.videointelligence.v1?hl=ID#google.cloud.videointelligence.v1.AnnotateVideoRequest

Thanks & Regards,


On Tue, Oct 15, 2019 at 4:20 PM  wrote:
I have used the code for python from https://cloud.google.com/video-intelligence/docs/libraries and the documentation mentioned that my output would be in JSON format however the format I got was: "google.cloud.videointelligence_v1.types.AnnotateVideoResponse" or something similar. I have tried other codes from other documentations but still end up having the same problem. 

I have also tried to convert the "google.cloud.videointelligence_v1.types.AnnotateVideoResponse" into a string and then into a JSON but got this error instead: "TypeError: Object of type 'AnnotateVideoResponse' is not JSON serializable" 

So how do I fix this? Please help. 

--
© 2018 Google Inc. 1600 Amphitheatre Parkway, Mountain View, CA 94043
 
Email preferences: You received this email because you signed up for the Google Cloud Video Intelligence API Discussion Google Group (cloud-videoi...@googlegroups.com) to participate in discussions with other members of the Google Cloud Video Intelligence API community and the Google Cloud Video Intelligence API Team.
---
You received this message because you are subscribed to the Google Groups "cloud-videointel-discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cloud-videointel-discuss+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages