當前位置: 首頁>>代碼示例>>C#>>正文


C# NOcrDb.Save方法代碼示例

本文整理匯總了C#中Nikse.SubtitleEdit.Logic.Ocr.NOcrDb.Save方法的典型用法代碼示例。如果您正苦於以下問題:C# NOcrDb.Save方法的具體用法?C# NOcrDb.Save怎麽用?C# NOcrDb.Save使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Nikse.SubtitleEdit.Logic.Ocr.NOcrDb的用法示例。


在下文中一共展示了NOcrDb.Save方法的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: buttonTrain_Click

        private void buttonTrain_Click(object sender, EventArgs e)
        {
            if (!File.Exists(textBoxInputFile.Text))
            {
                return;
            }

            int numberOfCharactersLeaned = 0;
            int numberOfCharactersSkipped = 0;
            var nOcrD = new NOcrDb(textBoxNOcrDb.Text);
            var lines = new List<string>();
            foreach (string line in File.ReadAllLines(textBoxInputFile.Text))
                lines.Add(line);
            var format = new SubRip();
            var sub = new Subtitle();
            format.LoadSubtitle(sub, lines, textBoxInputFile.Text);

            var charactersLearned = new List<string>();
            foreach (ListViewItem item in listViewFonts.Items)
            {
                if (item.Checked)
                {
                    _subtitleFontName = item.Text;
                    _subtitleFontSize = Convert.ToInt32(comboBoxSubtitleFontSize.Items[comboBoxSubtitleFontSize.SelectedIndex].ToString());
                    charactersLearned = new List<string>();

                    foreach (Paragraph p in sub.Paragraphs)
                    {
                        foreach (char ch in p.Text)
                        {
                            if (!char.IsWhiteSpace(ch))
                            {
                                var s = ch.ToString();
                                if (!charactersLearned.Contains(s))
                                {
                                    TrainLetter(ref numberOfCharactersLeaned, ref numberOfCharactersSkipped, nOcrD, charactersLearned, s, false);
                                    if (checkBoxBold.Checked)
                                        TrainLetter(ref numberOfCharactersLeaned, ref numberOfCharactersSkipped, nOcrD, charactersLearned, s, true);
                                }
                            }
                        }
                    }
                }
            }
            nOcrD.Save();
        }
開發者ID:socialpercon,項目名稱:subtitleedit,代碼行數:46,代碼來源:VobSubNOcrTrain.cs


注:本文中的Nikse.SubtitleEdit.Logic.Ocr.NOcrDb.Save方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。