本文整理汇总了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
{
}
}
示例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();
}