本文整理汇总了C#中TesseractEngine.SetVariable方法的典型用法代码示例。如果您正苦于以下问题:C# TesseractEngine.SetVariable方法的具体用法?C# TesseractEngine.SetVariable怎么用?C# TesseractEngine.SetVariable使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TesseractEngine
的用法示例。
在下文中一共展示了TesseractEngine.SetVariable方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CanSetDoubleVariable
public void CanSetDoubleVariable(string variableName, double 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);
double result;
if(engine.TryGetDoubleVariable(variableName, out result)) {
Assert.That(result, Is.EqualTo(variableValue));
} else {
Assert.Fail("Failed to retrieve value for '{0}'.", variableName);
}
}
}
示例2: SetVariablesAccordingToConfig
private static void SetVariablesAccordingToConfig(TesseractEngine engine, ZoneConfiguration barcodeConfig)
{
if (barcodeConfig.TextualDataFilter.FilterType == FilterType.Alpha)
{
engine.SetVariable("tessedit_char_whitelist", "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ-");
}
if (barcodeConfig.TextualDataFilter.FilterType == FilterType.AlphaOnly)
{
engine.SetVariable("tessedit_char_whitelist", "ABCDEFGHIJKLMNOPQRSTUVWXYZ-");
}
if (barcodeConfig.TextualDataFilter.FilterType == FilterType.Digits)
{
engine.SetVariable("tessedit_char_whitelist", "0123456789");
}
if (barcodeConfig.TextualDataFilter.FilterType == FilterType.Number)
{
engine.SetVariable("tessedit_char_whitelist", "0123456789,.");
}
}
示例3: CanSetBooleanVariable
public void CanSetBooleanVariable(bool variableValue)
{
const string VariableName = "classify_enable_learning";
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);
bool result;
if(engine.TryGetBoolVariable(VariableName, out result)) {
Assert.That(result, Is.EqualTo(variableValue));
} else {
Assert.Fail("Failed to retrieve value for '{0}'.", VariableName);
}
}
}
示例4: WritesOutThresholdedImageWhenOCRing
public void WritesOutThresholdedImageWhenOCRing()
{
var expectedFilePath = Path.Combine(Environment.CurrentDirectory, "tessinput.tif");
if (File.Exists(expectedFilePath)) {
File.Delete(expectedFilePath);
}
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
engine.SetVariable("tessedit_write_images", true);
using (var img = Pix.LoadFromFile("./phototest.tif")) {
using (var page = engine.Process(img)) {
var region1Text = page.GetText();
Assert.That(File.Exists(expectedFilePath));
}
}
}
}
示例5: CanSetClassifyBlnNumericModeVariable
public void CanSetClassifyBlnNumericModeVariable()
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
engine.SetVariable("classify_bln_numeric_mode", 1);
using (var img = Pix.LoadFromFile("./Data/processing/numbers.png")) {
using (var page = engine.Process(img)) {
var text = page.GetText();
const string expectedText = "1234567890\n\n";
Assert.That(text, Is.EqualTo(expectedText));
}
}
}
}