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


C# NOcrDb.Add方法代码示例

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


在下文中一共展示了NOcrDb.Add方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestNOcrSaveLoad

        public void TestNOcrSaveLoad()
        {
            string tempFileName = Path.GetTempFileName();
            var db = new NOcrDb(tempFileName);

            var nOcrChar = new NOcrChar("t");
            nOcrChar.ExpandCount = 0;
            nOcrChar.Italic = false;
            nOcrChar.MarginTop = 2;
            nOcrChar.Width = 10;
            nOcrChar.Height = 10;
            nOcrChar.LinesForeground.Add(new NOcrPoint(new Point(1, 1), new Point(2, 2)));
            nOcrChar.LinesBackground.Add(new NOcrPoint(new Point(3, 4), new Point(5, 6)));
            db.Add(nOcrChar);

            var nOcrChar2 = new NOcrChar("u");
            nOcrChar2.ExpandCount = 0;
            nOcrChar2.Italic = false;
            nOcrChar2.MarginTop = 3;
            nOcrChar2.Width = 12;
            nOcrChar2.Height = 12;
            nOcrChar2.LinesForeground.Add(new NOcrPoint(new Point(1, 1), new Point(2, 2)));
            nOcrChar2.LinesBackground.Add(new NOcrPoint(new Point(3, 4), new Point(5, 6)));
            db.Add(nOcrChar2);
            db.Save();

            db = new NOcrDb(tempFileName);
            Assert.IsTrue(db.OcrCharacters.Count == 2);

            Assert.IsTrue(db.OcrCharacters[0].Text == nOcrChar2.Text);
            Assert.IsTrue(db.OcrCharacters[0].Italic == nOcrChar2.Italic);
            Assert.IsTrue(db.OcrCharacters[0].MarginTop == nOcrChar2.MarginTop);
            Assert.IsTrue(db.OcrCharacters[0].LinesForeground.Count == nOcrChar2.LinesForeground.Count);
            Assert.IsTrue(db.OcrCharacters[0].LinesForeground[0].Start.X == nOcrChar2.LinesForeground[0].Start.X);
            Assert.IsTrue(db.OcrCharacters[0].LinesForeground[0].Start.Y == nOcrChar2.LinesForeground[0].Start.Y);
            Assert.IsTrue(db.OcrCharacters[0].LinesBackground.Count == nOcrChar2.LinesBackground.Count);
            Assert.IsTrue(db.OcrCharacters[0].LinesBackground[0].Start.X == nOcrChar2.LinesBackground[0].Start.X);
            Assert.IsTrue(db.OcrCharacters[0].LinesBackground[0].Start.Y == nOcrChar2.LinesBackground[0].Start.Y);

            Assert.IsTrue(db.OcrCharacters[1].Text == nOcrChar.Text);

            try
            {
                File.Delete(tempFileName);
            }
            catch
            {
            }
        }
开发者ID:YangEunYong,项目名称:subtitleedit,代码行数:49,代码来源:NOcrTest.cs

示例2: TrainLetter

        private void TrainLetter(ref int numberOfCharactersLeaned, ref int numberOfCharactersSkipped, NOcrDb nOcrD, List<string> charactersLearned, string s, bool bold)
        {
            Bitmap bmp = GenerateImageFromTextWithStyle(s, bold);
            var nbmp = new NikseBitmap(bmp);
            nbmp.MakeTwoColor(280);
            var list = NikseBitmapImageSplitter.SplitBitmapToLettersNew(nbmp, 10, false, false, 25);
            if (list.Count == 1)
            {
                NOcrChar match = nOcrD.GetMatch(list[0].NikseBitmap);
                if (match == null)
                {
                    pictureBox1.Image = list[0].NikseBitmap.GetBitmap();
                    this.Refresh();
                    Application.DoEvents();
                    System.Threading.Thread.Sleep(100);

                    NOcrChar nOcrChar = new NOcrChar(s);
                    nOcrChar.Width = list[0].NikseBitmap.Width;
                    nOcrChar.Height = list[0].NikseBitmap.Height;
                    VobSubOcrNOcrCharacter.GenerateLineSegments((int)numericUpDownSegmentsPerCharacter.Value, checkBoxVeryAccurate.Checked, nOcrChar, list[0].NikseBitmap);
                    nOcrD.Add(nOcrChar);

                    charactersLearned.Add(s);
                    numberOfCharactersLeaned++;
                    labelInfo.Text = string.Format("Now training font '{1}', total characters leaned is {0}, {2} skipped", numberOfCharactersLeaned, _subtitleFontName, numberOfCharactersSkipped);
                    bmp.Dispose();
                }
                else
                {
                    numberOfCharactersSkipped++;
                }
            }
        }
开发者ID:socialpercon,项目名称:subtitleedit,代码行数:33,代码来源:VobSubNOcrTrain.cs


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