本文整理汇总了C#中TesseractEngine类的典型用法代码示例。如果您正苦于以下问题:C# TesseractEngine类的具体用法?C# TesseractEngine怎么用?C# TesseractEngine使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
TesseractEngine类属于命名空间,在下文中一共展示了TesseractEngine类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Initialise_WithTessDataPrefixSet
public void Initialise_WithTessDataPrefixSet()
{
Environment.SetEnvironmentVariable("TESSDATA_PREFIX", Environment.CurrentDirectory);
using (var engine = new TesseractEngine(null, "eng", EngineMode.Default)) {
}
}
开发者ID:cuongnx1310,项目名称:tesseract,代码行数:7,代码来源:EngineTests.cs
示例2: CanGenerateHOCROutput
public void CanGenerateHOCROutput()
{
string actualResult;
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
using (var img = Pix.LoadFromFile("./phototest.tif")) {
using (var page = engine.Process(img)) {
actualResult = NormaliseNewLine(page.GetHOCRText(1));
}
}
}
const string ExpectedResultPath = "./Results/EngineTests.CanGenerateHOCROutput.txt";
if (File.Exists(ExpectedResultPath)) {
var expectedResult = NormaliseNewLine(File.ReadAllText(ExpectedResultPath));
if (expectedResult != actualResult) {
var actualResultPath = String.Format("./Results/EngineTests.CanGenerateHOCROutput_{0:yyyyMMddTHHmmss}.txt", DateTime.UtcNow);
File.WriteAllText(actualResultPath, actualResult);
Assert.Fail("Expected results to be {0} but was {1}", ExpectedResultPath, actualResultPath);
}
} else {
var actualResultPath = String.Format("./Results/EngineTests.CanGenerateHOCROutput_{0:yyyyMMddTHHmmss}.txt", DateTime.UtcNow);
File.WriteAllText(actualResultPath, actualResult);
Assert.Fail("Expected result did not exist, actual results saved to {0}", actualResultPath);
}
}
开发者ID:nonameShadow,项目名称:tesseract,代码行数:25,代码来源:EngineTests.cs
示例3: OnSubmitFileClicked
private void OnSubmitFileClicked(object sender, EventArgs args)
{
if (imageFile.PostedFile != null && imageFile.PostedFile.ContentLength > 0)
{
// for now just fail hard if there's any error however in a propper app I would expect a full demo.
using (var engine = new TesseractEngine(Server.MapPath(@"./tessdata"), "eng", EngineMode.Default))
{
// have to load Pix via a bitmap since Pix doesn't support loading a stream.
using (var image = new System.Drawing.Bitmap(imageFile.PostedFile.InputStream))
{
using (var pix = PixConverter.ToPix(image))
{
using (var page = engine.Process(pix))
{
meanConfidenceLabel.InnerText = String.Format("{0:P}", page.GetMeanConfidence());
resultText.InnerText = page.GetText();
}
}
}
}
inputPanel.Visible = false;
resultPanel.Visible = true;
}
}
开发者ID:JonathanKeav,项目名称:tesseract,代码行数:25,代码来源:Default.aspx.cs
示例4: Initialise_Rus_ShouldStartEngine
public void Initialise_Rus_ShouldStartEngine()
{
using (var engine = new TesseractEngine(@"./tessdata", "rus", EngineMode.Default)) {
}
}
开发者ID:cuongnx1310,项目名称:tesseract,代码行数:7,代码来源:EngineTests.cs
示例5: Initialise_ShouldStartEngine
public void Initialise_ShouldStartEngine(
[ValueSource("DataPaths")] string datapath)
{
using (var engine = new TesseractEngine(datapath, "eng", EngineMode.Default)) {
}
}
开发者ID:cuongnx1310,项目名称:tesseract,代码行数:8,代码来源:EngineTests.cs
示例6: Initialise_ShouldThrowErrorIfDatapathNotCorrect
public void Initialise_ShouldThrowErrorIfDatapathNotCorrect()
{
Assert.That(() => {
using (var engine = new TesseractEngine(@"./IDontExist", "eng", EngineMode.Default)) {
}
}, Throws.InstanceOf(typeof(TesseractException)));
}
开发者ID:cuongnx1310,项目名称:tesseract,代码行数:9,代码来源:EngineTests.cs
示例7: 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);
}
}
}
开发者ID:huanghws2013,项目名称:tesseract,代码行数:13,代码来源:EngineTests.cs
示例8: CanParseText
public void CanParseText()
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
using(var img = Pix.LoadFromFile("./phototest.tiff")) {
using(var page = engine.Process(img)) {
var text = page.GetText();
Assert.That(text, Is.EqualTo(""));
}
}
}
}
开发者ID:nikolay87,项目名称:tesseract,代码行数:13,代码来源:EngineTests.cs
示例9: 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);
}
}
}
开发者ID:huanghws2013,项目名称:tesseract,代码行数:14,代码来源:EngineTests.cs
示例10: CanProcessBitmap
public void CanProcessBitmap()
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
using (var img = new Bitmap("./phototest.tif")) {
using (var page = engine.Process(img)) {
var text = page.GetText();
const string expectedText =
"This is a lot 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\nlazy fox. The quick brown dog jumped\nover the lazy fox. The quick brown dog\njumped over the lazy fox. The quick\nbrown dog jumped over the lazy fox.\n\n";
Assert.That(text, Is.EqualTo(expectedText));
}
}
}
}
开发者ID:odflash,项目名称:tesseract,代码行数:15,代码来源:EngineTests.cs
示例11: CanParseText_UsingMode
public void CanParseText_UsingMode(PageSegMode mode, String expectedText)
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
var demoFilename = String.Format("./Data/Ocr/PSM_{0}.png", mode);
using (var pix = Pix.LoadFromFile(demoFilename)) {
using (var page = engine.Process(pix, mode)) {
var text = page.GetText().Trim();
Assert.That(text, Is.EqualTo(expectedText));
}
}
}
}
开发者ID:Picazsoo,项目名称:tesseract,代码行数:15,代码来源:EngineTests.cs
示例12: CanParseUznFile
public void CanParseUznFile()
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
var inputFilename = TestFilePath(@"Ocr\uzn-test.png");
using (var img = Pix.LoadFromFile(inputFilename)) {
using (var page = engine.Process(img, inputFilename, PageSegMode.SingleLine)) {
var text = page.GetText();
const string expectedText =
"This is another test\n\n";
Assert.That(text, Is.EqualTo(expectedText));
}
}
}
}
开发者ID:odflash,项目名称:tesseract,代码行数:16,代码来源:EngineTests.cs
示例13: CanParseMultipageTif
public void CanParseMultipageTif()
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
using (var pixA = PixArray.LoadMultiPageTiffFromFile("./Data/processing/multi-page.tif")) {
int i = 1;
foreach (var pix in pixA) {
using (var page = engine.Process(pix)) {
var text = page.GetText().Trim();
string expectedText = String.Format("Page {0}", i);
Assert.That(text, Is.EqualTo(expectedText));
}
i++;
}
}
}
}
开发者ID:Picazsoo,项目名称:tesseract,代码行数:17,代码来源:EngineTests.cs
示例14: CanProcessEmptyPxUsingResultIterator
public void CanProcessEmptyPxUsingResultIterator()
{
string actualResult;
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
using (var img = Pix.LoadFromFile("./data/ocr/empty.png")) {
using (var page = engine.Process(img)) {
actualResult = WriteResultsToString(page);
}
}
}
Assert.That(actualResult, Is.EqualTo(
@"</word></line>
</para>
</block>
"));
}
开发者ID:odflash,项目名称:tesseract,代码行数:17,代码来源:EngineTests.cs
示例15: 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,.");
}
}
开发者ID:SuperJMN,项目名称:Glass,代码行数:22,代码来源:TesseractOcrOcrService.cs
示例16: CanProcessDifferentRegionsInSameImage
public void CanProcessDifferentRegionsInSameImage()
{
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default)) {
using (var img = Pix.LoadFromFile("./phototest.tif")) {
using (var page = engine.Process(img, Rect.FromCoords(0, 0, img.Width, 188))) {
var region1Text = page.GetText();
const string expectedTextRegion1 =
"This is a lot of 12 point text to test the\nocr code and see if it works on all types\nof file format.\n\n";
Assert.That(region1Text, Is.EqualTo(expectedTextRegion1));
page.RegionOfInterest = Rect.FromCoords(0, 188, img.Width, img.Height);
var region2Text = page.GetText();
const string expectedTextRegion2 =
"The quick brown dog jumped over the\nlazy fox. The quick brown dog jumped\nover the lazy fox. The quick brown dog\njumped over the lazy fox. The quick\nbrown dog jumped over the lazy fox.\n\n";
Assert.That(region2Text, Is.EqualTo(expectedTextRegion2));
}
}
}
}
开发者ID:odflash,项目名称:tesseract,代码行数:23,代码来源:EngineTests.cs
示例17: Initialise_CanPassInitVariables
public void Initialise_CanPassInitVariables()
{
var initVars = new Dictionary<string, object>() {
{ "load_system_dawg", false }
};
using (var engine = new TesseractEngine(@"./tessdata", "eng", EngineMode.Default, Enumerable.Empty<string>(), initVars, false)) {
bool loadSystemDawg;
if (!engine.TryGetBoolVariable("load_system_dawg", out loadSystemDawg)) {
Assert.Fail("Failed to get 'load_system_dawg'.");
}
Assert.That(loadSystemDawg, Is.False);
}
}
开发者ID:Picazsoo,项目名称:tesseract,代码行数:13,代码来源:EngineTests.cs
示例18: TesseractOcrOcrService
public TesseractOcrOcrService()
{
engine = new TesseractEngine(@"./tessdata", "spa", EngineMode.Default);
}
开发者ID:SuperJMN,项目名称:Glass,代码行数:4,代码来源:TesseractOcrOcrService.cs
示例19: 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));
}
}
}
}
开发者ID:odflash,项目名称:tesseract,代码行数:20,代码来源:EngineTests.cs
示例20: 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));
}
}
}
}
开发者ID:odflash,项目名称:tesseract,代码行数:24,代码来源:EngineTests.cs
注:本文中的TesseractEngine类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论