Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the api of detect_full_text() return incorrect results when the texts is chinese characters #3124

Closed
HopLiu opened this issue Mar 9, 2017 · 18 comments
Assignees
Labels
api: vision Issues related to the Cloud Vision API. priority: p2 Moderately-important priority. Fix may not be included in next release.

Comments

@HopLiu
Copy link

HopLiu commented Mar 9, 2017

now i use detect_full_text() to detect words in sdk way. there are two issues:

  1. the detect_full_text cannot return correct language code and words info when the texts in picture is chinese.
  2. meanwhile, the detect_text() can return correct info(words and bounds info).

since i need the info of each words and bounds, i have to use the first api. Any ideas or is this an exist issue of this api?

@daspecster daspecster added the api: speech Issues related to the Speech-to-Text API. label Mar 9, 2017
@lukesneeringer lukesneeringer added api: vision Issues related to the Cloud Vision API. and removed api: speech Issues related to the Speech-to-Text API. labels Mar 9, 2017
@lukesneeringer
Copy link
Contributor

Hi @HopLiu,
Thank you for reporting this issue.

I do not think the client library does anything differently with regard to character encodings between detect_text and detect_full_text, although I intend to double check.

Could you provide me with a reproduction case? (Basically, what is an image I can use to observe this behavior?) I expect it is a problem on the vision backend, but I would like to confirm that before passing the report on.

@lukesneeringer lukesneeringer added priority: p2 Moderately-important priority. Fix may not be included in next release. Status: Acknowledged labels Mar 9, 2017
@HopLiu
Copy link
Author

HopLiu commented Mar 10, 2017

use this attached jpg file(8E27CE646909307503C8C5D16.jpg) to test.

  1. "python detect_chn.py fulltext resources/8E27CE646909307503C8C5D16.jpg "
    2."python detect_chn.py text resources/8E27CE646909307503C8C5D16.jpg"
    the detect_chn.py is the same as detect.py in "python-docs-samples-master/vision/cloud-client" except i add a little encodings in order to print on the console.
    8e27ce646909307503c8c5d16

qq20170310-diff

@daspecster
Copy link
Contributor

Thanks @HopLiu! I can test this out real quick @lukesneeringer if you want.

@lukesneeringer
Copy link
Contributor

@daspecster Sure. I have faith in the reproduction case, what I really want to know is whether it is our bug or the backend API's bug.

@daspecster
Copy link
Contributor

daspecster commented Mar 10, 2017

@lukesneeringer so I'm still looking into this but for detect_full_text, under pages, I'm getting results like the following, but there are no properly encoded Chinese characters in the results AFAICT.

(Pdb) full_text.text
u'Eitute : WIHFW PGA TOUR DRAFX HESO 9: 274400\nFBIE ST9 : 0530-3560885 400-607 1001 (AFE HOiE)\n1$US49: 0530-3560898\n'
symbols {
    property {
      detected_languages {
        language_code: "cy"
      }
    }
    bounding_box {
      vertices {
        x: 141
        y: 442
      }
      vertices {
        x: 156
        y: 442
      }
      vertices {
        x: 156
        y: 462
      }
      vertices {
        x: 141
        y: 462
      }
    }
    text: "U"
}

Example

(Pdb) full_text.pages[0].blocks[0].paragraphs[0].words[0].symbols[0].text
u'E'
(Pdb) full_text.pages[0].blocks[0].paragraphs[0].words[0].symbols[1].text
u'i'
(Pdb) full_text.pages[0].blocks[0].paragraphs[0].words[0].symbols[2].text
u't'
(Pdb) full_text.pages[0].blocks[0].paragraphs[0].words[0].symbols[3].text
u'u'
(Pdb) full_text.pages[0].blocks[0].paragraphs[0].words[0].symbols[4].text
u't'

@daspecster
Copy link
Contributor

daspecster commented Mar 10, 2017

Also, I tried passing languageHints (which currently isn't supported well in the library), but I get this...

"message": "image-annotator::error(12): Image processing error!"

I don't get that error if I leave languageHints out of the request.

I think we need some backend confirmation of what exactly is supported.

@daspecster
Copy link
Contributor

@gguuss would you have any insight on this?

@lukesneeringer
Copy link
Contributor

This sounds like a backend issue to me.

@gguuss
Copy link
Contributor

gguuss commented Mar 17, 2017

The API accepts an optional parameter, the image context, which needs to specify the language. I am going to see if I can determine how to specify this in our Python Cloud client.

@daspecster
Copy link
Contributor

So this may be related to my #3132 issue then.

@gguuss do you know if all annotation API's support ImageContext right now? If I need to support ImageContext for all annotation types then I can do that, but if it's only one or two types(as it was in the past) then I tried to make adding that information to the API call more direct.

@gguuss
Copy link
Contributor

gguuss commented Mar 17, 2017

The ImageContext is not used by all features. I think the context configuration is used for crop hints, language features, and landmark / entities / labels. Do we currently have a way of setting it?

@gguuss
Copy link
Contributor

gguuss commented Mar 17, 2017

I authored a a web-based proof of concept that correctly detects Chinese text so it is definitely not a backend issue. Passing the image context does not appear to have side effects when extra parameters are passed, for example, landmark detection still works with language set to zh.

@daspecster
Copy link
Contributor

@gguuss your example uses this library?

@daspecster
Copy link
Contributor

@gguuss I think I missed adding that. I would have sworn I had that for the EntityAnnotations but it appears that I'm not passing that along.

I do use ImageContext for crop hints but I think that might be the only one.

@lukesneeringer I can get to work on this if there aren't other priorities?

@lukesneeringer
Copy link
Contributor

Go for it.

@gguuss
Copy link
Contributor

gguuss commented Mar 17, 2017

@daspecster My example is Apiary on JavaScript (insert joke about merely being a front-end developer and microservices on Python scaring / frightening me).

@daspecster
Copy link
Contributor

No jokes here! I hail from the frontend as well..but a long time ago in a galaxy far far away.

@gguuss
Copy link
Contributor

gguuss commented Mar 17, 2017

Btw, crop hints works well, maybe we can similarly accept an optional parameter on detect_text and detext_fulltext for language.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: vision Issues related to the Cloud Vision API. priority: p2 Moderately-important priority. Fix may not be included in next release.
Projects
None yet
Development

No branches or pull requests

4 participants