Why would this be? -> When I reinitialize tesseract for every call in a loop it consistently runs faster by a something like .1 second per loop iteration

78 views
Skip to first unread message

fsbo.c...@gmail.com

unread,
Sep 9, 2015, 9:14:05 PM9/9/15
to tesseract-ocr
I have a loop that calls SetImage() and GetUTF8Text() once for each iteration of the loop. 

I have found that when I call tesseract::TessBaseAPI *api = new tesseract::TessBaseAPI() and api->End() at the beginning and end of the loop, I actually get about .1 second improvement in time performance than if I only init and end tesseract once. 

Why would this counterintuitive thing happen? Based on these timings I'm assuming the process of clearing the contents of the previous call must be significantly slower than reinitializing tesseract, but this would still be quite counterintuitive.

fsbo.c...@gmail.com

unread,
Sep 11, 2015, 3:13:02 AM9/11/15
to tesseract-ocr
To anyone else who may run across this, it is because of the way C++ uses scope to optimize the code when it compiles. Things that are within the scope of the for loop will run faster than things that have larger scope.

Nick White

unread,
Sep 17, 2015, 6:23:25 AM9/17/15
to tesser...@googlegroups.com
On Fri, Sep 11, 2015 at 12:13:02AM -0700, fsbo.c...@gmail.com wrote:
> To anyone else who may run across this, it is because of the way C++ uses scope
> to optimize the code when it compiles. Things that are within the scope of the
> for loop will run faster than things that have larger scope.

Thanks for the info!
Reply all
Reply to author
Forward
0 new messages