本文整理匯總了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;
}