Suppose I've created two objects of TessBaseAPI
— xapi
and yapi
— initialized by calling the following overload of Init() function:
int Init(const char * datapath,
const char * language,
OcrEngineMode oem,
char ** configs,
int configs_size,
const GenericVector< STRING > * vars_vec,
const GenericVector< STRING > * vars_values,
bool set_only_non_debug_params
);
passing exactly identical arguments.
Since the objects are initialized with identical arguments, at this point xapi
and yapi
are assumed to be identical from behavioral1 perspective. Is my assumption correct? I hope so, as I don't find any reason for the objects to be non-identical.
Now I'm going to use xapi
to extract information from an image but before that I call SetVariable() a number of times, to set few more configurations.
bool SetVariable(const char * name, const char * value);
and then I used xapi
to extract some text from an image. Once I'm done with the extraction, I did this:
xapi.Clear(); //what exactly happens here?
After the call to Clear(), can I use xapi
and yapi
interchangeably? In other words, can I assume that xapi
and yapi
are identical at this point from behavioral1 perspective? Can I say Clear()
is actually a reset functionality?
1. By "behavioral", I meant performance in terms of accuracy, not speed/latency.
According to the void tesseract::TessBaseAPI::Clear() documentation, the call to this function will free up the image data and the recognition results. It says nothing about configuration data. Moreover, if the authors consider the configuration data as being time-consuming to load, it's going to be kept intact: without actually freeing any recognition data that would be time-consuming to reload
.
Answering your other questions:
"After the call to Clear(), can I use xapi and yapi interchangeably?" -- yes, you may, but results might differ because of different settings you have applied to xapi
via SetVariable()
, but not to yapi
.
"In other words, can I assume that xapi and yapi are identical at this point from behavioral1 perspective?" -- depending on what settings you have changed with SetVariable()
, the results may be or may be not the same.
"Can I say Clear() is actually a reset functionality?" -- only the recognition results and the image data is discarded, everything else is kept intact. Depending on your definition of reset
, you may call it a reset or not, it's a free country after all =)
You may check the difference between Clear() and the full teardown using End(). It's around line 1400 of baseapi.cpp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With