Azure-Computer-Vision : Read API - Get JSON response using python sdk

Keerthana B.S 21 Reputation points

I have been able to extract the text data from the image of pdf file using Azure Computer Vision Read API using python SDK (azure-cognitiveservices-vision-computervision). However, the response is either the or msrest.pipeline.ClientRawResponse as response from the get_read_result() API as specified in below link. Kindly let me know how to get JSON response using get_read_result() API.

Response :
{'additional_properties': {}, 'status': <OperationStatusCodes.succeeded: 'succeeded'>, 'created_date_time': '2021-09-28T08:49:01Z', 'last_updated_date_time': '2021-09-28T08:49:05Z', 'analyze_result': < object at 0x0000023C502C32B0>}

I want the output as json response and not objects.

Azure Computer Vision
Azure Computer Vision
An Azure artificial intelligence service that analyzes content in images and video.
203 questions
{count} votes

Accepted answer
  1. romungi-MSFT 32,691 Reputation points Microsoft Employee

    @Keerthana B.S With the SDK you can print out each object in the response i.e the ReadResult object's analyze_result class and its results. You can follow this snippet from documentation and print your results.

    read_result = computervision_client.get_read_result(operation_id)  
    # Print the detected text, line by line  
    if read_result.status == OperationStatusCodes.succeeded:  
        for text_result in read_result.analyze_result.read_results:  
            for line in text_result.lines:  

    You also have the option to use REST API with python to use the JSON response directly from the get read results API.

0 additional answers

Sort by: Most helpful