Skip to content
This repository has been archived by the owner on Mar 17, 2022. It is now read-only.

Commit

Permalink
Fail if OCR happens too fast
Browse files Browse the repository at this point in the history
  • Loading branch information
Xyresic committed Dec 6, 2016
1 parent c61cb64 commit c947584
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,9 @@ public void testStop() throws InterruptedException {
final TessBaseAPI baseApi = new TessBaseAPI(new ProgressNotifier() {
@Override
public void onProgressValues(ProgressValues progressValues) {
if (progressValues.getPercent() > 50){
fail("OCR recognition was too fast, try to increase the image size and amount of text?");
}
if (progressValues.getPercent() > 1){
synchronized (progressLock){
progressLock.notify();
Expand Down Expand Up @@ -762,9 +765,8 @@ protected Void doInBackground(Void... params) {

baseApi.stop();

// Wait for getHOCRText() to complete (it will return recognition done up to that point),
// otherwise we may end() and recycle baseApi before getHOCRText() finishes returning the
// data and cause an exception
// Wait for getHOCRText() to complete, otherwise we may end() and recycle baseApi before
// getHOCRText() finishes execution on the AsyncTask thread and cause an exception
synchronized (progressLock){
progressLock.wait();
}
Expand Down

0 comments on commit c947584

Please sign in to comment.