I am using Google Vision document_text_detection
function and I am trying to dump the AnnotateImageResponse to json
Earlier this code used to word
client = vision.ImageAnnotatorClient()
image = vision.Image(content=image)
response = client.document_text_detection(image=image)
texts = MessageToDict(response)
text_json = json.dumps(texts)
Now it throws this error AttributeError: 'DESCRIPTOR'
I tried all the responses in other answers but none of them worked. I also tried protobuf3-to-dict
but it also throws error
from protobuf_to_dict import protobuf_to_dict
text_json = protobuf_to_dict(response)
It throws:
AttributeError: 'ListFields'
I know I can iterate it the object but I need to dump it in json file to maintain cache.