Skip to content
This repository was archived by the owner on Feb 28, 2026. It is now read-only.
This repository was archived by the owner on Feb 28, 2026. It is now read-only.

Object DeserializationError / unicode #107

@jtlz2

Description

@jtlz2

I have modified the example image_analysis_in_stream at https://github.com/Azure-Samples/cognitive-services-python-sdk-samples/blob/master/samples/vision/computer_vision_samples.py to rather carry out OCR, i.e.

with open(os.path.join(IMAGES_FOLDER, "image.jpg"), "rb") as image_stream:
        image_response = client.recognize_printed_text_in_stream(image_stream,language='en')

This gives the following Traceback:

  File "/anaconda2/lib/python2.7/site-packages/azure/cognitiveservices/vision/computervision/computer_vision_api.py", line 962, in recognize_printed_text_in_stream
    deserialized = self._deserialize('OcrResult', response)
  File "/anaconda2/lib/python2.7/site-packages/msrest/serialization.py", line 1179, in __call__
    return self._deserialize(target_obj, data)
  File "/anaconda2/lib/python2.7/site-packages/msrest/serialization.py", line 1245, in _deserialize
    value = self.deserialize_data(raw_value, attr_desc['type'])
  File "/anaconda2/lib/python2.7/site-packages/msrest/serialization.py", line 1433, in deserialize_data
    return self._deserialize(obj_type, data)
  File "/anaconda2/lib/python2.7/site-packages/msrest/serialization.py", line 1249, in _deserialize
    raise_with_traceback(DeserializationError, msg, err)
  File "/anaconda2/lib/python2.7/site-packages/msrest/exceptions.py", line 57, in raise_with_traceback
    raise error
msrest.exceptions.DeserializationError: Unable to deserialize to object: type, AttributeError: 'unicode' object has no attribute 'get

Line 962 requires a response code of 200, so can I assume image_stream is valid?

How do I then deserialize OcrResult to JSON?

Is this an API version mismatch..?

Thanks for any speedy help.

(This is a cross-posting of Azure/azure-sdk-for-python#2769)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions