K41F4r
K41F4r

Reputation: 1551

Google Cloud Vision API - DOCUMENT_TEXT_DETECTION: no "property" field in "pages"

I'm trying to extract the language from the detection response:

response.full_text_annotation.pages[0].property.detected_languages[0].language_code

but it seems that sometimes the detections are missing the TextProperty (property) field - as specified here: Page

Is it not always guaranteed to be in the detection?

Also, is there a way to receive only the fullTextAnnotation without the singular textAnnotations fields?

Upvotes: 0

Views: 898

Answers (1)

IDMT
IDMT

Reputation: 176

I think is not possible to receive only the fullTextAnnotation without the singular textAnnotations, because the response structure is TextAnnotation -> Page -> Block -> Paragraph -> Word -> Symbol and if you look into the TextAnnotation response, there is no way to modify it.

Regarding the missing TextProperty (property) field, you can try to fix this by using “DOCUMENT_TEXT_DETECTION” instead of “TEXT_DETECTION” towards TYPE. According to the documentation, The TEXT_DETECTION endpoint will auto-detect only a subset of supported languages, while the DOCUMENT_TEXT_DETECTION endpoint will auto-detect the full set of supported languages.

Upvotes: 1

Related Questions