Using Azure, is there a way I can detect text orientation?

66 Views Asked by At

I'm currently using the Auzre Vision API through Python like so:

import azure.ai.vision as vision

service_options = vision.VisionServiceOptions(
    os.environ["PAY_VISION_ENDPOINT"], os.environ["AZURE_PAY_VISION_KEY"]
)

vision_source = vision.VisionSource(filename=str(image_path))

analysis_options = vision.ImageAnalysisOptions()
analysis_options.features = vision.ImageAnalysisFeature.TEXT
analysis_options.language = "en"

image_analyzer = vision.ImageAnalyzer(
    service_options, vision_source, analysis_options
)

result = image_analyzer.analyze()

In the result set, I see a bounding box, but it always starts in the top left, so I can't use that to detect orientation. I don't see any other way to get orientation. I've seen this question, but that just points out that I should be able to see orientation, but not set it. However, when I try the sample, I don't see orientation.

The documentation from MS (here and here) indicates that I should be able to get this information via a detectOrientation property, which I've tried setting as analysis_options.detectOrientation = "true", but that doesn't change the response. I'm clearly missing something.

How can I get the orientation of the text like it seems I should be able to?

1

There are 1 best solutions below

0
Rishabh Meshram On BEST ANSWER

Based on the documentation, It looks like there might be a confusion in the usage of the Azure Vision API. The detectOrientation property is not part of the ImageAnalysisOptions in the azure.ai.vision.

You get the orientation, you can check OCR result,

https://<Endpoint_Name>.cognitiveservices.azure.com/vision/v3.1/ocr?detectOrientation=True

With above request, I able to get orientation and angle. enter image description here

You can also check document intelligence's layout model that also gives angle output.