本文整理汇总了C#中Nikse.SubtitleEdit.Logic.NikseBitmap.ReplaceYellowWithWhite方法的典型用法代码示例。如果您正苦于以下问题:C# NikseBitmap.ReplaceYellowWithWhite方法的具体用法?C# NikseBitmap.ReplaceYellowWithWhite怎么用?C# NikseBitmap.ReplaceYellowWithWhite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Nikse.SubtitleEdit.Logic.NikseBitmap
的用法示例。
在下文中一共展示了NikseBitmap.ReplaceYellowWithWhite方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Tesseract3DoOcrViaExe
private string Tesseract3DoOcrViaExe(Bitmap bmp, string language, string psmMode)
{
// change yellow color to white - easier for Tesseract
var nbmp = new NikseBitmap(bmp);
nbmp.ReplaceYellowWithWhite(); // optimized replace
bool useHocr = true;
string tempTiffFileName = Path.GetTempPath() + Guid.NewGuid().ToString() + ".png";
var b = nbmp.GetBitmap();
b.Save(tempTiffFileName, System.Drawing.Imaging.ImageFormat.Png);
string tempTextFileName = Path.GetTempPath() + Guid.NewGuid().ToString();
b.Dispose();
var process = new Process();
process.StartInfo = new ProcessStartInfo(Configuration.TesseractFolder + "tesseract.exe");
process.StartInfo.UseShellExecute = true;
process.StartInfo.Arguments = "\"" + tempTiffFileName + "\" \"" + tempTextFileName + "\" -l " + language;
if (checkBoxTesseractMusicOn.Checked)
process.StartInfo.Arguments += "+music";
if (!string.IsNullOrEmpty(psmMode))
process.StartInfo.Arguments += " " + psmMode.Trim();
if (useHocr)
process.StartInfo.Arguments += " hocr";
process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;
if (Utilities.IsRunningOnLinux() || Utilities.IsRunningOnMac())
{
process.StartInfo.UseShellExecute = false;
process.StartInfo.RedirectStandardError = true;
process.StartInfo.FileName = "tesseract";
}
else
{
process.StartInfo.WorkingDirectory = (Configuration.TesseractFolder);
}
try
{
process.Start();
}
catch
{
MessageBox.Show("Unable to start 'tesseract' - make sure tesseract-ocr 3.x is installed!");
throw;
}
process.WaitForExit(5000);
string result = string.Empty;
if (useHocr)
{
string outputFileName = tempTextFileName + ".html";
try
{
if (File.Exists(outputFileName))
{
result = File.ReadAllText(outputFileName);
result = ParseHocr(result);
File.Delete(outputFileName);
}
File.Delete(tempTiffFileName);
}
catch
{
}
}
else
{
string outputFileName = tempTextFileName + ".txt";
try
{
if (File.Exists(outputFileName))
{
result = File.ReadAllText(outputFileName);
File.Delete(outputFileName);
}
File.Delete(tempTiffFileName);
}
catch
{
}
}
return result;
}