如何使用C ++在tesseract中设置和获取变量 [英] How to set and get a variable in tesseract using C++
问题描述
我有一个快速的问题:如何使用C ++在tesseract中获取变量.
I have a quick question: How to I get the variable in tesseract using C++.
例如我要设置"load_system_dawg" to false
`tesseract.setVariable("load_system_dawg",?);`
是吗? = 0和1,还是"true"和"false"?
Is ? = 0 and 1, or "true" and "false"?
还有如何检查变量的设置?
And also how to check the settings of a variable?
`tesseract.getBoolVariable("load_system_dawg");`
or
`tesseract.getVariableAsString("load_system_dawg");`
在我所有的情况下,尝试代码中断.
In all my cases and attempts the code breaks.
编辑
我能够获取一个变量,但是为什么不能在设置后获取.
I am able to get a variable, but why is get after set not possible.
tess.SetVariable("load_punc_dawg", "0");
tess.SetVariable("load_punc_dawg", "false");
bool result = false;
tess.GetBoolVariable("load_punc_dawg", &result);
但是result = true.
bool thisOne = tess.GetBoolVariable("load_punc_dawg",& result);
But the result = true.
bool thisOne = tess.GetBoolVariable("load_punc_dawg", &result);
returns `"thisOne" = true`, and `"result" = true"`
要检查结果,我正在通过代码进行调试.
And To check the results I am debugging through the code.
推荐答案
好的,这似乎很有趣.在tesseract初始化时设置参数现在对我有用.
Ok, that seems to be very interesting. Set the parameter at the tesseract initialization works for me at the moment.
GenericVector<STRING> pars_vec;
pars_vec.push_back("load_punc_dawg");
GenericVector<STRING> pars_values;
pars_values.push_back("0"); //"false"
tesseract::TessBaseAPI tess;
tess.Init(NULL, "eng", tesseract::OEM_TESSERACT_ONLY, NULL, 0, &pars_vec,
&pars_values, false);
bool result = false;
bool thisOne = tess.GetBoolVariable("load_punc_dawg", &result);
returns "thisOne" = true and "result" = false
这篇关于如何使用C ++在tesseract中设置和获取变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!