本文整理汇总了C#中TesseractEngine.TryGetStringVariable方法的典型用法代码示例。如果您正苦于以下问题:C# TesseractEngine.TryGetStringVariable方法的具体用法?C# TesseractEngine.TryGetStringVariable怎么用?C# TesseractEngine.TryGetStringVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TesseractEngine
的用法示例。
在下文中一共展示了TesseractEngine.TryGetStringVariable方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanSetStringVariable
public void CanSetStringVariable(string variableName, string variableValue)
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
var variableWasSet = engine.SetVariable(variableName, variableValue);
Assert.That(variableWasSet, Is.True, "Failed to set variable '{0}'.", variableName);
string result;
if (engine.TryGetStringVariable(variableName, out result)) {
Assert.That(result, Is.EqualTo(variableValue));
} else {
Assert.Fail("Failed to retrieve value for '{0}'.", variableName);
}
}
}
示例2: Initialise_CanLoadConfigFile
public void Initialise_CanLoadConfigFile()
{
var tessDataPath = Path.Combine(Environment.CurrentDirectory, @"tessdata\");
using (var engine = new TesseractEngine(tessDataPath, "eng", EngineMode.Default, "bazzar")) {
// verify that the config file was loaded
string user_patterns_suffix;
if (engine.TryGetStringVariable("user_words_suffix", out user_patterns_suffix)) {
Assert.That(user_patterns_suffix, Is.EqualTo("user-words"));
} else {
Assert.Fail("Failed to retrieve value for 'user_words_suffix'.");
}
using (var img = Pix.LoadFromFile("./phototest.tif")) {
using (var page = engine.Process(img)) {
var text = page.GetText();
const string expectedText =
"This is a Iot of 12 point text to test the\nocr code and see if it works on all types\nof file format.\n\nThe quick brown dog jumped over the\nIazy fox. The quick brown dog jumped\nover the Iazy fox. The quick brown dog\njumped over the Iazy fox. The quick\nbrown dog jumped over the Iazy fox.\n\n";
Assert.That(text, Is.EqualTo(expectedText));
}
}
}
}
示例3: CanGetStringVariableThatDoesNotExist
public void CanGetStringVariableThatDoesNotExist()
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
String result;
Boolean success = engine.TryGetStringVariable("illegal-variable", out result);
Assert.That(success, Is.False);
Assert.That(result, Is.Null);
}
}