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

C-API for OSResults (orientation and script results) is not a stable ABI #424

Closed
jbarlow83 opened this issue Sep 8, 2016 · 7 comments
Closed
Labels
OSD Orientation and Script Detection

Comments

@jbarlow83
Copy link

The existing C API for TessBaseAPIDetectOS requires a C caller to successfully allocate struct OSResults which is actually a C++ class. If the C++ compiler decides to append anything to the structure, this will fail. The definition of this struct also depends on kMaxNumberOfScripts so is subject to change if (when) Tesseract adds more scripts.

The struct members that a caller is most likely to want are actually in OSBestResult whose position may shift.

I suggest deprecating this API and providing one that returns the member elements of OSBestResult instead. I think it would be useful to have a C API call to obtain this information rather than parsing the executable's output in -psm 0. Here's one possible API.

BOOL TessBaseAPIDetectOS2(
 TessBaseAPI* handle, 
 int* best_script_id, 
 int* best_orientation_id, 
 float* script_confidence, 
 float* orientation_confidence);

Returning OSBestResults is also an option, but sometimes it's nice to avoid structs entirely.

I can contribute changes if there's agreement on them.

@zdenop
Copy link
Contributor

zdenop commented Sep 9, 2016

Thank you for you investigation.
Can you please post it to tesseract-dev forum for discussion, so developers of tesseract wrappers can be aware of change?

@jbarlow83
Copy link
Author

Posted

@amitdo
Copy link
Collaborator

amitdo commented Dec 5, 2016

The suggestion looks good to me.

@zdenop, I suggest to give @jbarlow83 a green light for sending a PR.

@stweil
Copy link
Member

stweil commented Dec 5, 2016

I must admit that I had to look into the code what "OS" means in the context of OCR. Maybe it is possible to find a better name with "Orientation and Script" ("OaS"?).

PS. I just noted that the title of this issue also had the information which I was looking for.

@zdenop
Copy link
Contributor

zdenop commented Dec 7, 2016

@jbarlow83 will you create PR?

@jbarlow83
Copy link
Author

Yes, working on it.

jbarlow83 pushed a commit to jbarlow83/tesseract that referenced this issue Dec 7, 2016
See issue tesseract-ocr#424.

The existing C API for TessBaseAPIDetectOS requires a C caller to successfully allocate struct OSResults which is actually a C++ class.  Generally it won't
be possible for a regular C compiler to do this properly.

It's also assumed that most API level users of Tesseract are only interested in Tesseract's best guess as to script and orientation, not the individual values for all possible scripts.

This introduces a new API with a better name that is more closely aligned with the output of 'tesseract -psm 0'.  Both tesseract -psm 0 and this API now share the same code in baseapi.cpp.
@zdenop
Copy link
Contributor

zdenop commented Dec 9, 2016

fixed with 3a47adc

@zdenop zdenop closed this as completed Dec 9, 2016
zdenop pushed a commit that referenced this issue Dec 11, 2016
See issue #424.

The existing C API for TessBaseAPIDetectOS requires a C caller to successfully allocate struct OSResults which is actually a C++ class.  Generally it won't
be possible for a regular C compiler to do this properly.

It's also assumed that most API level users of Tesseract are only interested in Tesseract's best guess as to script and orientation, not the individual values for all possible scripts.

This introduces a new API with a better name that is more closely aligned with the output of 'tesseract -psm 0'.  Both tesseract -psm 0 and this API now share the same code in baseapi.cpp.
@amitdo amitdo added the OSD Orientation and Script Detection label May 14, 2020
zvezdochiot pushed a commit to ImageProcessing-ElectronicPublications/tesseract that referenced this issue Mar 28, 2021
See issue tesseract-ocr#424.

The existing C API for TessBaseAPIDetectOS requires a C caller to successfully allocate struct OSResults which is actually a C++ class.  Generally it won't
be possible for a regular C compiler to do this properly.

It's also assumed that most API level users of Tesseract are only interested in Tesseract's best guess as to script and orientation, not the individual values for all possible scripts.

This introduces a new API with a better name that is more closely aligned with the output of 'tesseract -psm 0'.  Both tesseract -psm 0 and this API now share the same code in baseapi.cpp.
zvezdochiot pushed a commit to ImageProcessing-ElectronicPublications/tesseract that referenced this issue Mar 28, 2021
See issue tesseract-ocr#424.

The existing C API for TessBaseAPIDetectOS requires a C caller to successfully allocate struct OSResults which is actually a C++ class.  Generally it won't
be possible for a regular C compiler to do this properly.

It's also assumed that most API level users of Tesseract are only interested in Tesseract's best guess as to script and orientation, not the individual values for all possible scripts.

This introduces a new API with a better name that is more closely aligned with the output of 'tesseract -psm 0'.  Both tesseract -psm 0 and this API now share the same code in baseapi.cpp.
zvezdochiot pushed a commit to ImageProcessing-ElectronicPublications/tesseract that referenced this issue Mar 28, 2021
See issue tesseract-ocr#424.

The existing C API for TessBaseAPIDetectOS requires a C caller to successfully allocate struct OSResults which is actually a C++ class.  Generally it won't
be possible for a regular C compiler to do this properly.

It's also assumed that most API level users of Tesseract are only interested in Tesseract's best guess as to script and orientation, not the individual values for all possible scripts.

This introduces a new API with a better name that is more closely aligned with the output of 'tesseract -psm 0'.  Both tesseract -psm 0 and this API now share the same code in baseapi.cpp.
zvezdochiot pushed a commit to ImageProcessing-ElectronicPublications/tesseract that referenced this issue Mar 28, 2021
See issue tesseract-ocr#424.

The existing C API for TessBaseAPIDetectOS requires a C caller to successfully allocate struct OSResults which is actually a C++ class.  Generally it won't
be possible for a regular C compiler to do this properly.

It's also assumed that most API level users of Tesseract are only interested in Tesseract's best guess as to script and orientation, not the individual values for all possible scripts.

This introduces a new API with a better name that is more closely aligned with the output of 'tesseract -psm 0'.  Both tesseract -psm 0 and this API now share the same code in baseapi.cpp.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OSD Orientation and Script Detection
Projects
None yet
Development

No branches or pull requests

4 participants