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

Unable to stop TessBaseAPI from completing recognition #2

Closed
0xbad1d3a5 opened this issue Dec 4, 2016 · 2 comments
Closed

Unable to stop TessBaseAPI from completing recognition #2

0xbad1d3a5 opened this issue Dec 4, 2016 · 2 comments
Assignees

Comments

@0xbad1d3a5
Copy link
Owner

0xbad1d3a5 commented Dec 4, 2016

I think I know the cause here.

/** Make a text string from the internal data structures. */
char* TessBaseAPI::GetUTF8Text() {
  if (tesseract_ == NULL ||
      (!recognition_done_ && Recognize(NULL) < 0))
    return NULL;
  STRING text("");
  ResultIterator *it = GetIterator();
  do {
    if (it->Empty(RIL_PARA)) continue;
    char *para_text = it->GetUTF8Text(RIL_PARA);
    text += para_text;
    delete []para_text;
  } while (it->Next(RIL_PARA));
  char* result = new char[text.length() + 1];
  strncpy(result, text.string(), text.length() + 1);
  delete it;
  return result;
}

The GetUTF8Text() function in tesseract does not pass a monitor to Recognize, so recognition will never be canceled and will always block.

@0xbad1d3a5
Copy link
Owner Author

Yup, that's definitely the problem. Calling TessBaseAPI.getHOCRText(0) instead allows you to stop and cancel the recognition.

@0xbad1d3a5 0xbad1d3a5 self-assigned this Dec 4, 2016
@0xbad1d3a5
Copy link
Owner Author

Fixed, as well as fixing some code upstream: rmtheis/tess-two#186

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant