Image compare ocr now has 'max err%' in the UI

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@2069 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-09-09 19:37:50 +00:00
parent 28823e8318
commit 186cce7191
5 changed files with 109 additions and 44 deletions

View File

@ -58,7 +58,6 @@ namespace Nikse.SubtitleEdit.Forms
this.buttonOK = new System.Windows.Forms.Button(); this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button(); this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxOcrMethod = new System.Windows.Forms.GroupBox(); this.groupBoxOcrMethod = new System.Windows.Forms.GroupBox();
this.comboBoxOcrMethod = new System.Windows.Forms.ComboBox();
this.GroupBoxTesseractMethod = new System.Windows.Forms.GroupBox(); this.GroupBoxTesseractMethod = new System.Windows.Forms.GroupBox();
this.buttonGetTesseractDictionaries = new System.Windows.Forms.Button(); this.buttonGetTesseractDictionaries = new System.Windows.Forms.Button();
this.checkBoxTesseractMusicOn = new System.Windows.Forms.CheckBox(); this.checkBoxTesseractMusicOn = new System.Windows.Forms.CheckBox();
@ -66,6 +65,7 @@ namespace Nikse.SubtitleEdit.Forms
this.checkBoxUseModiInTesseractForUnknownWords = new System.Windows.Forms.CheckBox(); this.checkBoxUseModiInTesseractForUnknownWords = new System.Windows.Forms.CheckBox();
this.labelTesseractLanguage = new System.Windows.Forms.Label(); this.labelTesseractLanguage = new System.Windows.Forms.Label();
this.comboBoxTesseractLanguages = new System.Windows.Forms.ComboBox(); this.comboBoxTesseractLanguages = new System.Windows.Forms.ComboBox();
this.comboBoxOcrMethod = new System.Windows.Forms.ComboBox();
this.groupBoxModiMethod = new System.Windows.Forms.GroupBox(); this.groupBoxModiMethod = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label(); this.label1 = new System.Windows.Forms.Label();
this.comboBoxModiLanguage = new System.Windows.Forms.ComboBox(); this.comboBoxModiLanguage = new System.Windows.Forms.ComboBox();
@ -138,9 +138,11 @@ namespace Nikse.SubtitleEdit.Forms
this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog(); this.folderBrowserDialog1 = new System.Windows.Forms.FolderBrowserDialog();
this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog(); this.openFileDialog1 = new System.Windows.Forms.OpenFileDialog();
this.splitContainerBottom = new System.Windows.Forms.SplitContainer(); this.splitContainerBottom = new System.Windows.Forms.SplitContainer();
this.timerHideStatus = new System.Windows.Forms.Timer(this.components);
this.labelMaxErrorPercent = new System.Windows.Forms.Label();
this.numericUpDownMaxErrorPct = new System.Windows.Forms.NumericUpDown();
this.textBoxCurrentText = new Nikse.SubtitleEdit.Controls.SETextBox(); this.textBoxCurrentText = new Nikse.SubtitleEdit.Controls.SETextBox();
this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView(); this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.timerHideStatus = new System.Windows.Forms.Timer(this.components);
this.contextMenuStripListview.SuspendLayout(); this.contextMenuStripListview.SuspendLayout();
this.groupBoxOcrMethod.SuspendLayout(); this.groupBoxOcrMethod.SuspendLayout();
this.GroupBoxTesseractMethod.SuspendLayout(); this.GroupBoxTesseractMethod.SuspendLayout();
@ -169,6 +171,7 @@ namespace Nikse.SubtitleEdit.Forms
this.splitContainerBottom.Panel1.SuspendLayout(); this.splitContainerBottom.Panel1.SuspendLayout();
this.splitContainerBottom.Panel2.SuspendLayout(); this.splitContainerBottom.Panel2.SuspendLayout();
this.splitContainerBottom.SuspendLayout(); this.splitContainerBottom.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxErrorPct)).BeginInit();
this.SuspendLayout(); this.SuspendLayout();
// //
// contextMenuStripListview // contextMenuStripListview
@ -191,7 +194,7 @@ namespace Nikse.SubtitleEdit.Forms
this.toolStripSeparator3, this.toolStripSeparator3,
this.deleteToolStripMenuItem}); this.deleteToolStripMenuItem});
this.contextMenuStripListview.Name = "contextMenuStripListview"; this.contextMenuStripListview.Name = "contextMenuStripListview";
this.contextMenuStripListview.Size = new System.Drawing.Size(306, 298); this.contextMenuStripListview.Size = new System.Drawing.Size(306, 276);
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening); this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
// //
// normalToolStripMenuItem // normalToolStripMenuItem
@ -383,10 +386,10 @@ namespace Nikse.SubtitleEdit.Forms
// groupBoxOcrMethod // groupBoxOcrMethod
// //
this.groupBoxOcrMethod.Controls.Add(this.comboBoxOcrMethod); this.groupBoxOcrMethod.Controls.Add(this.comboBoxOcrMethod);
this.groupBoxOcrMethod.Controls.Add(this.groupBoxImageCompareMethod);
this.groupBoxOcrMethod.Controls.Add(this.GroupBoxTesseractMethod); this.groupBoxOcrMethod.Controls.Add(this.GroupBoxTesseractMethod);
this.groupBoxOcrMethod.Controls.Add(this.groupBoxModiMethod); this.groupBoxOcrMethod.Controls.Add(this.groupBoxModiMethod);
this.groupBoxOcrMethod.Controls.Add(this.groupBoxNOCR); this.groupBoxOcrMethod.Controls.Add(this.groupBoxNOCR);
this.groupBoxOcrMethod.Controls.Add(this.groupBoxImageCompareMethod);
this.groupBoxOcrMethod.Location = new System.Drawing.Point(13, 5); this.groupBoxOcrMethod.Location = new System.Drawing.Point(13, 5);
this.groupBoxOcrMethod.Name = "groupBoxOcrMethod"; this.groupBoxOcrMethod.Name = "groupBoxOcrMethod";
this.groupBoxOcrMethod.Size = new System.Drawing.Size(392, 192); this.groupBoxOcrMethod.Size = new System.Drawing.Size(392, 192);
@ -394,21 +397,6 @@ namespace Nikse.SubtitleEdit.Forms
this.groupBoxOcrMethod.TabStop = false; this.groupBoxOcrMethod.TabStop = false;
this.groupBoxOcrMethod.Text = "OCR method"; this.groupBoxOcrMethod.Text = "OCR method";
// //
// comboBoxOcrMethod
//
this.comboBoxOcrMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxOcrMethod.FormattingEnabled = true;
this.comboBoxOcrMethod.Items.AddRange(new object[] {
"OCR via tesseract",
"OCR via image compare",
"OCR via Microsoftr MODI",
"OCR via nOCR"});
this.comboBoxOcrMethod.Location = new System.Drawing.Point(13, 20);
this.comboBoxOcrMethod.Name = "comboBoxOcrMethod";
this.comboBoxOcrMethod.Size = new System.Drawing.Size(366, 21);
this.comboBoxOcrMethod.TabIndex = 0;
this.comboBoxOcrMethod.SelectedIndexChanged += new System.EventHandler(this.ComboBoxOcrMethodSelectedIndexChanged);
//
// GroupBoxTesseractMethod // GroupBoxTesseractMethod
// //
this.GroupBoxTesseractMethod.Controls.Add(this.buttonGetTesseractDictionaries); this.GroupBoxTesseractMethod.Controls.Add(this.buttonGetTesseractDictionaries);
@ -490,6 +478,21 @@ namespace Nikse.SubtitleEdit.Forms
this.comboBoxTesseractLanguages.TabIndex = 1; this.comboBoxTesseractLanguages.TabIndex = 1;
this.comboBoxTesseractLanguages.SelectedIndexChanged += new System.EventHandler(this.ComboBoxTesseractLanguagesSelectedIndexChanged); this.comboBoxTesseractLanguages.SelectedIndexChanged += new System.EventHandler(this.ComboBoxTesseractLanguagesSelectedIndexChanged);
// //
// comboBoxOcrMethod
//
this.comboBoxOcrMethod.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxOcrMethod.FormattingEnabled = true;
this.comboBoxOcrMethod.Items.AddRange(new object[] {
"OCR via tesseract",
"OCR via image compare",
"OCR via Microsoftr MODI",
"OCR via nOCR"});
this.comboBoxOcrMethod.Location = new System.Drawing.Point(13, 20);
this.comboBoxOcrMethod.Name = "comboBoxOcrMethod";
this.comboBoxOcrMethod.Size = new System.Drawing.Size(366, 21);
this.comboBoxOcrMethod.TabIndex = 0;
this.comboBoxOcrMethod.SelectedIndexChanged += new System.EventHandler(this.ComboBoxOcrMethodSelectedIndexChanged);
//
// groupBoxModiMethod // groupBoxModiMethod
// //
this.groupBoxModiMethod.Controls.Add(this.label1); this.groupBoxModiMethod.Controls.Add(this.label1);
@ -640,6 +643,8 @@ namespace Nikse.SubtitleEdit.Forms
// //
// groupBoxImageCompareMethod // groupBoxImageCompareMethod
// //
this.groupBoxImageCompareMethod.Controls.Add(this.labelMaxErrorPercent);
this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownMaxErrorPct);
this.groupBoxImageCompareMethod.Controls.Add(this.checkBoxRightToLeft); this.groupBoxImageCompareMethod.Controls.Add(this.checkBoxRightToLeft);
this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownPixelsIsSpace); this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownPixelsIsSpace);
this.groupBoxImageCompareMethod.Controls.Add(this.buttonEditCharacterDatabase); this.groupBoxImageCompareMethod.Controls.Add(this.buttonEditCharacterDatabase);
@ -657,7 +662,7 @@ namespace Nikse.SubtitleEdit.Forms
// checkBoxRightToLeft // checkBoxRightToLeft
// //
this.checkBoxRightToLeft.AutoSize = true; this.checkBoxRightToLeft.AutoSize = true;
this.checkBoxRightToLeft.Location = new System.Drawing.Point(173, 100); this.checkBoxRightToLeft.Location = new System.Drawing.Point(9, 107);
this.checkBoxRightToLeft.Name = "checkBoxRightToLeft"; this.checkBoxRightToLeft.Name = "checkBoxRightToLeft";
this.checkBoxRightToLeft.Size = new System.Drawing.Size(83, 17); this.checkBoxRightToLeft.Size = new System.Drawing.Size(83, 17);
this.checkBoxRightToLeft.TabIndex = 6; this.checkBoxRightToLeft.TabIndex = 6;
@ -666,7 +671,7 @@ namespace Nikse.SubtitleEdit.Forms
// //
// numericUpDownPixelsIsSpace // numericUpDownPixelsIsSpace
// //
this.numericUpDownPixelsIsSpace.Location = new System.Drawing.Point(173, 67); this.numericUpDownPixelsIsSpace.Location = new System.Drawing.Point(173, 54);
this.numericUpDownPixelsIsSpace.Maximum = new decimal(new int[] { this.numericUpDownPixelsIsSpace.Maximum = new decimal(new int[] {
50, 50,
0, 0,
@ -699,7 +704,7 @@ namespace Nikse.SubtitleEdit.Forms
// labelNoOfPixelsIsSpace // labelNoOfPixelsIsSpace
// //
this.labelNoOfPixelsIsSpace.AutoSize = true; this.labelNoOfPixelsIsSpace.AutoSize = true;
this.labelNoOfPixelsIsSpace.Location = new System.Drawing.Point(6, 69); this.labelNoOfPixelsIsSpace.Location = new System.Drawing.Point(6, 56);
this.labelNoOfPixelsIsSpace.Name = "labelNoOfPixelsIsSpace"; this.labelNoOfPixelsIsSpace.Name = "labelNoOfPixelsIsSpace";
this.labelNoOfPixelsIsSpace.Size = new System.Drawing.Size(104, 13); this.labelNoOfPixelsIsSpace.Size = new System.Drawing.Size(104, 13);
this.labelNoOfPixelsIsSpace.TabIndex = 4; this.labelNoOfPixelsIsSpace.TabIndex = 4;
@ -1304,6 +1309,48 @@ namespace Nikse.SubtitleEdit.Forms
this.splitContainerBottom.SplitterDistance = 658; this.splitContainerBottom.SplitterDistance = 658;
this.splitContainerBottom.TabIndex = 39; this.splitContainerBottom.TabIndex = 39;
// //
// timerHideStatus
//
this.timerHideStatus.Interval = 2000;
this.timerHideStatus.Tick += new System.EventHandler(this.timerHideStatus_Tick);
//
// labelMaxErrorPercent
//
this.labelMaxErrorPercent.AutoSize = true;
this.labelMaxErrorPercent.Location = new System.Drawing.Point(7, 83);
this.labelMaxErrorPercent.Name = "labelMaxErrorPercent";
this.labelMaxErrorPercent.Size = new System.Drawing.Size(55, 13);
this.labelMaxErrorPercent.TabIndex = 45;
this.labelMaxErrorPercent.Text = "Max Err%";
//
// numericUpDownMaxErrorPct
//
this.numericUpDownMaxErrorPct.DecimalPlaces = 1;
this.numericUpDownMaxErrorPct.Increment = new decimal(new int[] {
1,
0,
0,
65536});
this.numericUpDownMaxErrorPct.Location = new System.Drawing.Point(173, 81);
this.numericUpDownMaxErrorPct.Maximum = new decimal(new int[] {
20,
0,
0,
0});
this.numericUpDownMaxErrorPct.Minimum = new decimal(new int[] {
5,
0,
0,
65536});
this.numericUpDownMaxErrorPct.Name = "numericUpDownMaxErrorPct";
this.numericUpDownMaxErrorPct.Size = new System.Drawing.Size(50, 21);
this.numericUpDownMaxErrorPct.TabIndex = 44;
this.numericUpDownMaxErrorPct.Value = new decimal(new int[] {
10,
0,
0,
65536});
//
// textBoxCurrentText // textBoxCurrentText
// //
this.textBoxCurrentText.AllowDrop = true; this.textBoxCurrentText.AllowDrop = true;
@ -1341,11 +1388,6 @@ namespace Nikse.SubtitleEdit.Forms
this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged); this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged);
this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown); this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown);
// //
// timerHideStatus
//
this.timerHideStatus.Interval = 2000;
this.timerHideStatus.Tick += new System.EventHandler(this.timerHideStatus_Tick);
//
// VobSubOcr // VobSubOcr
// //
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1408,6 +1450,7 @@ namespace Nikse.SubtitleEdit.Forms
this.splitContainerBottom.Panel1.PerformLayout(); this.splitContainerBottom.Panel1.PerformLayout();
this.splitContainerBottom.Panel2.ResumeLayout(false); this.splitContainerBottom.Panel2.ResumeLayout(false);
this.splitContainerBottom.ResumeLayout(false); this.splitContainerBottom.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxErrorPct)).EndInit();
this.ResumeLayout(false); this.ResumeLayout(false);
this.PerformLayout(); this.PerformLayout();
@ -1525,5 +1568,7 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.Button buttonSpellCheckDownload; private System.Windows.Forms.Button buttonSpellCheckDownload;
private System.Windows.Forms.Timer timerHideStatus; private System.Windows.Forms.Timer timerHideStatus;
private System.Windows.Forms.ToolStripMenuItem dOSTToolStripMenuItem; private System.Windows.Forms.ToolStripMenuItem dOSTToolStripMenuItem;
private System.Windows.Forms.Label labelMaxErrorPercent;
private System.Windows.Forms.NumericUpDown numericUpDownMaxErrorPct;
} }
} }

View File

@ -235,6 +235,8 @@ namespace Nikse.SubtitleEdit.Forms
labelTesseractLanguage.Text = language.Language; labelTesseractLanguage.Text = language.Language;
labelImageDatabase.Text = language.ImageDatabase; labelImageDatabase.Text = language.ImageDatabase;
labelNoOfPixelsIsSpace.Text = language.NoOfPixelsIsSpace; labelNoOfPixelsIsSpace.Text = language.NoOfPixelsIsSpace;
if (!string.IsNullOrEmpty(language.MaxErrorPercent)) //TODO: Remove in SE 3.4
labelMaxErrorPercent.Text = language.MaxErrorPercent;
buttonNewCharacterDatabase.Text = language.New; buttonNewCharacterDatabase.Text = language.New;
buttonEditCharacterDatabase.Text = language.Edit; buttonEditCharacterDatabase.Text = language.Edit;
buttonStartOcr.Text = language.StartOcr; buttonStartOcr.Text = language.StartOcr;
@ -278,6 +280,7 @@ namespace Nikse.SubtitleEdit.Forms
buttonGoogleIt.Text = Configuration.Settings.Language.Main.VideoControls.GoogleIt; buttonGoogleIt.Text = Configuration.Settings.Language.Main.VideoControls.GoogleIt;
numericUpDownPixelsIsSpace.Left = labelNoOfPixelsIsSpace.Left + labelNoOfPixelsIsSpace.Width + 5; numericUpDownPixelsIsSpace.Left = labelNoOfPixelsIsSpace.Left + labelNoOfPixelsIsSpace.Width + 5;
numericUpDownMaxErrorPct.Left = numericUpDownPixelsIsSpace.Left;
groupBoxSubtitleImage.Text = string.Empty; groupBoxSubtitleImage.Text = string.Empty;
labelFixesMade.Text = string.Empty; labelFixesMade.Text = string.Empty;
labelFixesMade.Left = checkBoxAutoFixCommonErrors.Left + checkBoxAutoFixCommonErrors.Width; labelFixesMade.Left = checkBoxAutoFixCommonErrors.Left + checkBoxAutoFixCommonErrors.Width;
@ -373,6 +376,15 @@ namespace Nikse.SubtitleEdit.Forms
checkBoxEmphasis2Transparent.Left = pictureBoxEmphasis2.Left + pictureBoxEmphasis2.Width + 3; checkBoxEmphasis2Transparent.Left = pictureBoxEmphasis2.Left + pictureBoxEmphasis2.Width + 3;
buttonGetTesseractDictionaries.Visible = !string.IsNullOrEmpty(Configuration.Settings.Language.GetTesseractDictionaries.Title); buttonGetTesseractDictionaries.Visible = !string.IsNullOrEmpty(Configuration.Settings.Language.GetTesseractDictionaries.Title);
try
{
numericUpDownMaxErrorPct.Value = (decimal)Configuration.Settings.VobSubOcr.AllowDifferenceInPercent;
}
catch
{
numericUpDownMaxErrorPct.Value = 1.1m;
}
} }
private void FillSpellCheckDictionaries() private void FillSpellCheckDictionaries()
@ -2220,14 +2232,22 @@ namespace Nikse.SubtitleEdit.Forms
} }
} }
index++; index++;
} }
// Search images with minor location changes // Search images with minor location changes
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, target); FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, target);
if (smallestDifference * 100.0 / (target.Width * target.Height) > _vobSubOcrSettings.AllowDifferenceInPercent && target.Width < 70)
if (target.Height < 35)
{ {
if (smallestDifference > 0.9 && target.Width > 25)
{
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(4, 0, target.Width - 4, target.Height));
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap);
cutBitmap.Dispose();
double differencePercentage = smallestDifference * 100.0 / (target.Width * target.Height);
}
if (smallestDifference > 0 && target.Width > 12) if (smallestDifference > 0 && target.Width > 12)
{ {
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height)); Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height));
@ -2273,16 +2293,17 @@ namespace Nikse.SubtitleEdit.Forms
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap2); FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap2);
cutBitmap.Dispose(); cutBitmap.Dispose();
cutBitmap2.Dispose(); cutBitmap2.Dispose();
} }
} }
if (smallestIndex >= 0) if (smallestIndex >= 0)
{ {
double differencePercentage = smallestDifference * 100.0 / (target.Width * target.Height); double differencePercentage = smallestDifference * 100.0 / (target.Width * target.Height);
double maxDiff = _vobSubOcrSettings.AllowDifferenceInPercent; // should be around 1.0 for vob/sub... double maxDiff = (double)numericUpDownMaxErrorPct.Value;
if (_bluRaySubtitlesOriginal != null) //_vobSubOcrSettings.AllowDifferenceInPercent; // should be around 1.0 for vob/sub...
maxDiff = 12.9; // let bluray sup have a 12.9% diff //if (_bluRaySubtitlesOriginal != null)
if (differencePercentage < maxDiff) //_vobSubOcrSettings.AllowDifferenceInPercent) // should be around 1.0... // maxDiff = 12.9; // let bluray sup have a 12.9% diff
if (differencePercentage <= maxDiff) //_vobSubOcrSettings.AllowDifferenceInPercent) // should be around 1.0...
{ {
XmlNode node = _compareDoc.DocumentElement.SelectSingleNode("Item[.='" + _compareBitmaps[smallestIndex].Name + "']"); XmlNode node = _compareDoc.DocumentElement.SelectSingleNode("Item[.='" + _compareBitmaps[smallestIndex].Name + "']");
if (node != null && _bluRaySubtitlesOriginal != null && "ceoil".Contains(node.Attributes["Text"].InnerText) && differencePercentage > 12) if (node != null && _bluRaySubtitlesOriginal != null && "ceoil".Contains(node.Attributes["Text"].InnerText) && differencePercentage > 12)
@ -2345,7 +2366,7 @@ namespace Nikse.SubtitleEdit.Forms
{ {
NikseBitmap target = new NikseBitmap(target2); NikseBitmap target = new NikseBitmap(target2);
int numberOfForegroundColors = CalculateNumberOfForegroundColors(target); int numberOfForegroundColors = CalculateNumberOfForegroundColors(target);
int minForeColorMatch = 99; int minForeColorMatch = 90;
if (smallestDifference > 0) if (smallestDifference > 0)
{ {
@ -2354,10 +2375,10 @@ namespace Nikse.SubtitleEdit.Forms
{ {
if (compareItem.Bitmap.Width == target.Width && compareItem.Bitmap.Height == target.Height) // precise math in size if (compareItem.Bitmap.Width == target.Width && compareItem.Bitmap.Height == target.Height) // precise math in size
{ {
if (compareItem.NumberOfForegroundColors == -1) if (compareItem.NumberOfForegroundColors < 1)
compareItem.NumberOfForegroundColors = CalculateNumberOfForegroundColors(compareItem.Bitmap); compareItem.NumberOfForegroundColors = CalculateNumberOfForegroundColors(compareItem.Bitmap);
if (Math.Abs(compareItem.NumberOfForegroundColors - numberOfForegroundColors) < 50) if (Math.Abs(compareItem.NumberOfForegroundColors - numberOfForegroundColors) < 40)
{ {
int dif = ImageSplitter.IsBitmapsAlike(compareItem.Bitmap, target); int dif = ImageSplitter.IsBitmapsAlike(compareItem.Bitmap, target);
if (dif < smallestDifference) if (dif < smallestDifference)
@ -2369,11 +2390,7 @@ namespace Nikse.SubtitleEdit.Forms
break; // foreach ending break; // foreach ending
} }
} }
} }
else
{
smallestDifference = (int)(smallestDifference - 0.00000001);
}
} }
index++; index++;
} }
@ -3630,6 +3647,7 @@ namespace Nikse.SubtitleEdit.Forms
} }
else if (_bluRaySubtitlesOriginal != null) else if (_bluRaySubtitlesOriginal != null)
{ {
numericUpDownMaxErrorPct.Value = 12.9m;
LoadBluRaySup(); LoadBluRaySup();
bool hasForcedSubtitles = false; bool hasForcedSubtitles = false;
foreach (var x in _bluRaySubtitlesOriginal) foreach (var x in _bluRaySubtitlesOriginal)
@ -5988,6 +6006,7 @@ namespace Nikse.SubtitleEdit.Forms
Configuration.Settings.VobSubOcr.AutoBreakSubtitleIfMoreThanTwoLines = checkBoxAutoBreakLines.Checked; Configuration.Settings.VobSubOcr.AutoBreakSubtitleIfMoreThanTwoLines = checkBoxAutoBreakLines.Checked;
Configuration.Settings.VobSubOcr.LineOcrDraw = checkBoxNOcrCorrect.Checked; Configuration.Settings.VobSubOcr.LineOcrDraw = checkBoxNOcrCorrect.Checked;
Configuration.Settings.VobSubOcr.LineOcrAdvancedItalic = checkBoxNOcrItalic.Checked; Configuration.Settings.VobSubOcr.LineOcrAdvancedItalic = checkBoxNOcrItalic.Checked;
Configuration.Settings.VobSubOcr.AllowDifferenceInPercent = (double)numericUpDownMaxErrorPct.Value;
if (comboBoxOcrMethod.SelectedIndex == 3) // line ocr if (comboBoxOcrMethod.SelectedIndex == 3) // line ocr
{ {
Configuration.Settings.VobSubOcr.LineOcrLastSpellcheck = LanguageString; Configuration.Settings.VobSubOcr.LineOcrLastSpellcheck = LanguageString;

View File

@ -2052,6 +2052,7 @@ Keep changes?",
OcrViaImageCompare = "OCR via image compare", OcrViaImageCompare = "OCR via image compare",
ImageDatabase = "Image database", ImageDatabase = "Image database",
NoOfPixelsIsSpace = "No of pixels is space", NoOfPixelsIsSpace = "No of pixels is space",
MaxErrorPercent = "Max. error%",
New = "New", New = "New",
Edit = "Edit", Edit = "Edit",
StartOcr = "Start OCR", StartOcr = "Start OCR",

View File

@ -1950,6 +1950,7 @@
public string OcrViaImageCompare { get; set; } public string OcrViaImageCompare { get; set; }
public string ImageDatabase { get; set; } public string ImageDatabase { get; set; }
public string NoOfPixelsIsSpace { get; set; } public string NoOfPixelsIsSpace { get; set; }
public string MaxErrorPercent { get; set; }
public string New { get; set; } public string New { get; set; }
public string Edit { get; set; } public string Edit { get; set; }
public string StartOcr { get; set; } public string StartOcr { get; set; }

View File

@ -43,7 +43,6 @@ namespace Nikse.SubtitleEdit.Logic
{ {
byte[] buffer = new byte[8]; byte[] buffer = new byte[8];
stream.Read(buffer, 0, buffer.Length); stream.Read(buffer, 0, buffer.Length);
// System.Windows.Forms.MessageBox.Show(System.Text.Encoding.UTF8.GetString(buffer, 0, 4));
Width = buffer[4] << 8 | buffer[5]; Width = buffer[4] << 8 | buffer[5];
Height = buffer[6] << 8 | buffer[7]; Height = buffer[6] << 8 | buffer[7];
_colors = new Color[Width * Height]; _colors = new Color[Width * Height];