当前位置: 首页>>代码示例>>C#>>正文


C# NikseBitmap.ReplaceYellowWithWhite方法代码示例

本文整理汇总了C#中NikseBitmap.ReplaceYellowWithWhite方法的典型用法代码示例。如果您正苦于以下问题:C# NikseBitmap.ReplaceYellowWithWhite方法的具体用法?C# NikseBitmap.ReplaceYellowWithWhite怎么用?C# NikseBitmap.ReplaceYellowWithWhite使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在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

            string tempTiffFileName = Path.GetTempPath() + Guid.NewGuid() + ".png";
            string tempTextFileName;
            using (var b = nbmp.GetBitmap())
            {
                b.Save(tempTiffFileName, System.Drawing.Imaging.ImageFormat.Png);
                tempTextFileName = Path.GetTempPath() + Guid.NewGuid();
            }

            using (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();

                process.StartInfo.Arguments += " hocr";
                process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden;

                if (Configuration.IsRunningOnLinux() || Configuration.IsRunningOnMac())
                {
                    process.StartInfo.UseShellExecute = false;
                    process.StartInfo.RedirectStandardError = true;
                    process.StartInfo.FileName = "tesseract";
                }
                else
                {
                    process.StartInfo.WorkingDirectory = (Configuration.TesseractFolder);
                }

                try
                {
                    process.Start();
                }
                catch
                {
                    if (Configuration.IsRunningOnLinux() || Configuration.IsRunningOnMac())
                    {
                        MessageBox.Show("Unable to start 'Tesseract' - make sure tesseract-ocr 3.x is installed!");
                    }
                    else
                    {
                        MessageBox.Show("Unable to start 'Tesseract' (" + Configuration.TesseractFolder + "tesseract.exe) - make sure tesseract-ocr 3.x is installed!");
                    }
                    throw;
                }
                process.WaitForExit(5000);
            }

            string result = string.Empty;
            string outputFileName = tempTextFileName + ".html";
            if (!File.Exists(outputFileName))
                outputFileName = tempTextFileName + ".hocr";
            try
            {
                if (File.Exists(outputFileName))
                {
                    result = File.ReadAllText(outputFileName);
                    result = ParseHocr(result);
                    File.Delete(outputFileName);
                }
                File.Delete(tempTiffFileName);
            }
            catch
            {
            }
            return result;
        }
开发者ID:mgziminsky,项目名称:subtitleedit,代码行数:78,代码来源:VobSubOcr.cs


注:本文中的NikseBitmap.ReplaceYellowWithWhite方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。