mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-10-27 22:42:38 +01:00
Minor improvements to ocr via image compare
git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@518 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
parent
e90789047a
commit
1182ec752f
@ -47,11 +47,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
string parameters = "-I dummy -vvv --no-sout-video --sout #transcode{acodec=s16l}:std{mux=wav,access=file,dst=\"" + targetFile + "\"} \"" + SourceVideoFileName + "\" vlc://quit";
|
||||
|
||||
string vlcPath;
|
||||
if (Utilities.IsRunningOnLinux() || Utilities.IsRunningOnMac())
|
||||
//if (Logic.VideoPlayers.MPlayer.IsInstalled)
|
||||
//{
|
||||
// vlcPath = Logic.VideoPlayers.MPlayer.GetMPlayerFileName;
|
||||
// parameters = "-ao pcm:fast:file=\"" + targetFile + "\" -vo null -vc null \"" + SourceVideoFileName + "\"";
|
||||
//}
|
||||
//else
|
||||
if (Utilities.IsRunningOnLinux() || Utilities.IsRunningOnMac())
|
||||
{
|
||||
vlcPath = "cvlc";
|
||||
parameters = "-vvv --no-sout-video --sout '#transcode{acodec=s16l}:std{mux=wav,access=file,dst=" + targetFile +"}' \"" + SourceVideoFileName + "\" vlc://quit";
|
||||
}
|
||||
}
|
||||
else // windows
|
||||
{
|
||||
vlcPath = Nikse.SubtitleEdit.Logic.VideoPlayers.LibVlc11xDynamic.GetVlcPath("vlc.exe");
|
||||
@ -130,6 +136,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
ReadWaveFile(targetFile);
|
||||
labelProgress.Text = string.Empty;
|
||||
|
51
src/Forms/VobSubEditCharacters.Designer.cs
generated
51
src/Forms/VobSubEditCharacters.Designer.cs
generated
@ -55,18 +55,17 @@
|
||||
this.comboBoxTexts.FormattingEnabled = true;
|
||||
this.comboBoxTexts.Location = new System.Drawing.Point(12, 35);
|
||||
this.comboBoxTexts.Name = "comboBoxTexts";
|
||||
this.comboBoxTexts.Size = new System.Drawing.Size(240, 25);
|
||||
this.comboBoxTexts.TabIndex = 0;
|
||||
this.comboBoxTexts.Size = new System.Drawing.Size(240, 21);
|
||||
this.comboBoxTexts.TabIndex = 1;
|
||||
this.comboBoxTexts.SelectedIndexChanged += new System.EventHandler(this.ComboBoxTextsSelectedIndexChanged);
|
||||
//
|
||||
// listBoxFileNames
|
||||
//
|
||||
this.listBoxFileNames.FormattingEnabled = true;
|
||||
this.listBoxFileNames.ItemHeight = 17;
|
||||
this.listBoxFileNames.Location = new System.Drawing.Point(12, 83);
|
||||
this.listBoxFileNames.Name = "listBoxFileNames";
|
||||
this.listBoxFileNames.Size = new System.Drawing.Size(240, 259);
|
||||
this.listBoxFileNames.TabIndex = 1;
|
||||
this.listBoxFileNames.Size = new System.Drawing.Size(240, 251);
|
||||
this.listBoxFileNames.TabIndex = 3;
|
||||
this.listBoxFileNames.SelectedIndexChanged += new System.EventHandler(this.ListBoxFileNamesSelectedIndexChanged);
|
||||
//
|
||||
// buttonOK
|
||||
@ -76,7 +75,7 @@
|
||||
this.buttonOK.Location = new System.Drawing.Point(368, 351);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonOK.TabIndex = 12;
|
||||
this.buttonOK.TabIndex = 0;
|
||||
this.buttonOK.Text = "&OK";
|
||||
this.buttonOK.UseVisualStyleBackColor = true;
|
||||
//
|
||||
@ -86,7 +85,7 @@
|
||||
this.buttonDelete.Location = new System.Drawing.Point(120, 62);
|
||||
this.buttonDelete.Name = "buttonDelete";
|
||||
this.buttonDelete.Size = new System.Drawing.Size(88, 21);
|
||||
this.buttonDelete.TabIndex = 16;
|
||||
this.buttonDelete.TabIndex = 4;
|
||||
this.buttonDelete.Text = "Delete ";
|
||||
this.buttonDelete.UseVisualStyleBackColor = true;
|
||||
this.buttonDelete.Click += new System.EventHandler(this.ButtonDeleteClick);
|
||||
@ -96,8 +95,8 @@
|
||||
this.labelChooseCharacters.AutoSize = true;
|
||||
this.labelChooseCharacters.Location = new System.Drawing.Point(12, 18);
|
||||
this.labelChooseCharacters.Name = "labelChooseCharacters";
|
||||
this.labelChooseCharacters.Size = new System.Drawing.Size(132, 17);
|
||||
this.labelChooseCharacters.TabIndex = 18;
|
||||
this.labelChooseCharacters.Size = new System.Drawing.Size(105, 13);
|
||||
this.labelChooseCharacters.TabIndex = 0;
|
||||
this.labelChooseCharacters.Text = "Choose character(s)";
|
||||
//
|
||||
// labelImageCompareFiles
|
||||
@ -105,8 +104,8 @@
|
||||
this.labelImageCompareFiles.AutoSize = true;
|
||||
this.labelImageCompareFiles.Location = new System.Drawing.Point(12, 66);
|
||||
this.labelImageCompareFiles.Name = "labelImageCompareFiles";
|
||||
this.labelImageCompareFiles.Size = new System.Drawing.Size(129, 17);
|
||||
this.labelImageCompareFiles.TabIndex = 19;
|
||||
this.labelImageCompareFiles.Size = new System.Drawing.Size(103, 13);
|
||||
this.labelImageCompareFiles.TabIndex = 2;
|
||||
this.labelImageCompareFiles.Text = "Image compare files";
|
||||
//
|
||||
// groupBoxCurrentCompareImage
|
||||
@ -123,7 +122,7 @@
|
||||
this.groupBoxCurrentCompareImage.Location = new System.Drawing.Point(258, 77);
|
||||
this.groupBoxCurrentCompareImage.Name = "groupBoxCurrentCompareImage";
|
||||
this.groupBoxCurrentCompareImage.Size = new System.Drawing.Size(266, 268);
|
||||
this.groupBoxCurrentCompareImage.TabIndex = 22;
|
||||
this.groupBoxCurrentCompareImage.TabIndex = 6;
|
||||
this.groupBoxCurrentCompareImage.TabStop = false;
|
||||
this.groupBoxCurrentCompareImage.Text = "Current compare image";
|
||||
//
|
||||
@ -132,8 +131,8 @@
|
||||
this.checkBoxItalic.AutoSize = true;
|
||||
this.checkBoxItalic.Location = new System.Drawing.Point(15, 61);
|
||||
this.checkBoxItalic.Name = "checkBoxItalic";
|
||||
this.checkBoxItalic.Size = new System.Drawing.Size(69, 21);
|
||||
this.checkBoxItalic.TabIndex = 29;
|
||||
this.checkBoxItalic.Size = new System.Drawing.Size(58, 17);
|
||||
this.checkBoxItalic.TabIndex = 2;
|
||||
this.checkBoxItalic.Text = "Is &italic";
|
||||
this.checkBoxItalic.UseVisualStyleBackColor = true;
|
||||
//
|
||||
@ -142,8 +141,8 @@
|
||||
this.labelDoubleSize.AutoSize = true;
|
||||
this.labelDoubleSize.Location = new System.Drawing.Point(14, 172);
|
||||
this.labelDoubleSize.Name = "labelDoubleSize";
|
||||
this.labelDoubleSize.Size = new System.Drawing.Size(116, 17);
|
||||
this.labelDoubleSize.TabIndex = 28;
|
||||
this.labelDoubleSize.Size = new System.Drawing.Size(93, 13);
|
||||
this.labelDoubleSize.TabIndex = 6;
|
||||
this.labelDoubleSize.Text = "Image double size";
|
||||
//
|
||||
// pictureBox2
|
||||
@ -161,8 +160,8 @@
|
||||
this.labelTextAssociatedWithImage.AutoSize = true;
|
||||
this.labelTextAssociatedWithImage.Location = new System.Drawing.Point(14, 19);
|
||||
this.labelTextAssociatedWithImage.Name = "labelTextAssociatedWithImage";
|
||||
this.labelTextAssociatedWithImage.Size = new System.Drawing.Size(172, 17);
|
||||
this.labelTextAssociatedWithImage.TabIndex = 26;
|
||||
this.labelTextAssociatedWithImage.Size = new System.Drawing.Size(137, 13);
|
||||
this.labelTextAssociatedWithImage.TabIndex = 0;
|
||||
this.labelTextAssociatedWithImage.Text = "Text associated with image";
|
||||
//
|
||||
// buttonUpdate
|
||||
@ -171,7 +170,7 @@
|
||||
this.buttonUpdate.Location = new System.Drawing.Point(120, 35);
|
||||
this.buttonUpdate.Name = "buttonUpdate";
|
||||
this.buttonUpdate.Size = new System.Drawing.Size(88, 21);
|
||||
this.buttonUpdate.TabIndex = 25;
|
||||
this.buttonUpdate.TabIndex = 3;
|
||||
this.buttonUpdate.Text = "Update";
|
||||
this.buttonUpdate.UseVisualStyleBackColor = true;
|
||||
this.buttonUpdate.Click += new System.EventHandler(this.ButtonUpdateClick);
|
||||
@ -181,16 +180,17 @@
|
||||
this.labelImageInfo.AutoSize = true;
|
||||
this.labelImageInfo.Location = new System.Drawing.Point(12, 87);
|
||||
this.labelImageInfo.Name = "labelImageInfo";
|
||||
this.labelImageInfo.Size = new System.Drawing.Size(42, 17);
|
||||
this.labelImageInfo.TabIndex = 24;
|
||||
this.labelImageInfo.Size = new System.Drawing.Size(35, 13);
|
||||
this.labelImageInfo.TabIndex = 5;
|
||||
this.labelImageInfo.Text = "label1";
|
||||
//
|
||||
// textBoxText
|
||||
//
|
||||
this.textBoxText.Location = new System.Drawing.Point(14, 35);
|
||||
this.textBoxText.Name = "textBoxText";
|
||||
this.textBoxText.Size = new System.Drawing.Size(100, 24);
|
||||
this.textBoxText.TabIndex = 23;
|
||||
this.textBoxText.Size = new System.Drawing.Size(100, 21);
|
||||
this.textBoxText.TabIndex = 1;
|
||||
this.textBoxText.KeyDown += new System.Windows.Forms.KeyEventHandler(this.textBoxText_KeyDown);
|
||||
//
|
||||
// pictureBox1
|
||||
//
|
||||
@ -208,13 +208,13 @@
|
||||
this.buttonCancel.Location = new System.Drawing.Point(449, 351);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonCancel.TabIndex = 23;
|
||||
this.buttonCancel.TabIndex = 1;
|
||||
this.buttonCancel.Text = "C&ancel";
|
||||
this.buttonCancel.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// VobSubEditCharacters
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(8F, 17F);
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(536, 380);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
@ -231,6 +231,7 @@
|
||||
this.MinimizeBox = false;
|
||||
this.Name = "VobSubEditCharacters";
|
||||
this.Text = "Edit image compare database";
|
||||
this.Shown += new System.EventHandler(this.VobSubEditCharacters_Shown);
|
||||
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VobSubEditCharacters_KeyDown);
|
||||
this.groupBoxCurrentCompareImage.ResumeLayout(false);
|
||||
this.groupBoxCurrentCompareImage.PerformLayout();
|
||||
|
@ -13,6 +13,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
XmlDocument _compareDoc = new XmlDocument();
|
||||
string _directoryPath;
|
||||
List<bool> _italics = new List<bool>();
|
||||
bool _focusTextBox = false;
|
||||
|
||||
public XmlDocument ImageCompareDocument
|
||||
{
|
||||
@ -216,11 +217,23 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (listBoxFileNames.Items[j].ToString().StartsWith(name))
|
||||
listBoxFileNames.SelectedIndex = j;
|
||||
}
|
||||
_focusTextBox = true;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void VobSubEditCharacters_Shown(object sender, EventArgs e)
|
||||
{
|
||||
textBoxText.Focus();
|
||||
}
|
||||
|
||||
private void textBoxText_KeyDown(object sender, KeyEventArgs e)
|
||||
{
|
||||
if (e.KeyCode == Keys.Enter)
|
||||
DialogResult = DialogResult.OK;
|
||||
}
|
||||
}
|
||||
}
|
24
src/Forms/VobSubOcr.Designer.cs
generated
24
src/Forms/VobSubOcr.Designer.cs
generated
@ -574,14 +574,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
//
|
||||
// listBoxLog
|
||||
//
|
||||
this.listBoxLog.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listBoxLog.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listBoxLog.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listBoxLog.FormattingEnabled = true;
|
||||
this.listBoxLog.Location = new System.Drawing.Point(6, 3);
|
||||
this.listBoxLog.Location = new System.Drawing.Point(3, 3);
|
||||
this.listBoxLog.Name = "listBoxLog";
|
||||
this.listBoxLog.Size = new System.Drawing.Size(291, 121);
|
||||
this.listBoxLog.Size = new System.Drawing.Size(309, 156);
|
||||
this.listBoxLog.TabIndex = 39;
|
||||
this.listBoxLog.SelectedIndexChanged += new System.EventHandler(this.ListBoxLogSelectedIndexChanged);
|
||||
//
|
||||
@ -598,14 +596,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
//
|
||||
// listBoxLogSuggestions
|
||||
//
|
||||
this.listBoxLogSuggestions.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listBoxLogSuggestions.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listBoxLogSuggestions.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listBoxLogSuggestions.FormattingEnabled = true;
|
||||
this.listBoxLogSuggestions.Location = new System.Drawing.Point(5, 6);
|
||||
this.listBoxLogSuggestions.Location = new System.Drawing.Point(3, 3);
|
||||
this.listBoxLogSuggestions.Name = "listBoxLogSuggestions";
|
||||
this.listBoxLogSuggestions.Size = new System.Drawing.Size(292, 121);
|
||||
this.listBoxLogSuggestions.Size = new System.Drawing.Size(309, 156);
|
||||
this.listBoxLogSuggestions.TabIndex = 40;
|
||||
this.listBoxLogSuggestions.SelectedIndexChanged += new System.EventHandler(this.ListBoxLogSelectedIndexChanged);
|
||||
//
|
||||
@ -621,14 +617,12 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
//
|
||||
// listBoxUnknownWords
|
||||
//
|
||||
this.listBoxUnknownWords.Anchor = ((System.Windows.Forms.AnchorStyles)((((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
|
||||
| System.Windows.Forms.AnchorStyles.Left)
|
||||
| System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.listBoxUnknownWords.Dock = System.Windows.Forms.DockStyle.Fill;
|
||||
this.listBoxUnknownWords.Font = new System.Drawing.Font("Tahoma", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
|
||||
this.listBoxUnknownWords.FormattingEnabled = true;
|
||||
this.listBoxUnknownWords.Location = new System.Drawing.Point(5, 6);
|
||||
this.listBoxUnknownWords.Location = new System.Drawing.Point(0, 0);
|
||||
this.listBoxUnknownWords.Name = "listBoxUnknownWords";
|
||||
this.listBoxUnknownWords.Size = new System.Drawing.Size(292, 121);
|
||||
this.listBoxUnknownWords.Size = new System.Drawing.Size(315, 162);
|
||||
this.listBoxUnknownWords.TabIndex = 40;
|
||||
this.listBoxUnknownWords.SelectedIndexChanged += new System.EventHandler(this.ListBoxLogSelectedIndexChanged);
|
||||
//
|
||||
|
@ -830,6 +830,19 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
cutBitmap.Dispose();
|
||||
}
|
||||
|
||||
if (smallestDifference > 0 && Width > 15)
|
||||
{
|
||||
int oldDifference = smallestDifference;
|
||||
Bitmap cutBitmap = CopyBitmapSection(target, new Rectangle(1, 0, target.Width - 2, target.Height));
|
||||
int topCrop = 0;
|
||||
cutBitmap = ImageSplitter.CropTopAndBottom(cutBitmap, out topCrop);
|
||||
FindBestMatch(ref index, ref smallestDifference, ref smallestIndex, cutBitmap);
|
||||
cutBitmap.Dispose();
|
||||
//if (oldDifference != smallestDifference)
|
||||
// MessageBox.Show("Test");
|
||||
}
|
||||
|
||||
|
||||
//if (smallestDifference > 0)
|
||||
//{
|
||||
// Bitmap resizedBitmap = ResizeBitmap(target, target.Width + 2, target.Height + 2);
|
||||
@ -842,7 +855,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
double differencePercentage = smallestDifference * 100.0 / (target.Width * target.Height);
|
||||
double maxDiff= _vobSubOcrSettings.AllowDifferenceInPercent; // should be around 1.0 for vob/sub...
|
||||
if (_bluRaySubtitlesOriginal != null)
|
||||
maxDiff = 14; // let bluray sup have a 14% diff
|
||||
maxDiff = 12; // let bluray sup have a 12% diff
|
||||
if (differencePercentage < maxDiff) //_vobSubOcrSettings.AllowDifferenceInPercent) // should be around 1.0...
|
||||
{
|
||||
XmlNode node = _compareDoc.DocumentElement.SelectSingleNode("FileName[.='" + _compareBitmaps[smallestIndex].Name + "']");
|
||||
@ -1283,7 +1296,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
_ocrFixEngine.AutoGuessesUsed.Clear();
|
||||
_ocrFixEngine.UnknownWordsFound.Clear();
|
||||
line = _ocrFixEngine.FixUnknownWordsViaGuessOrPrompt(out wordsNotFound, line, index, bitmap, checkBoxAutoFixCommonErrors.Checked, checkBoxPromptForUnknownWords.Checked, true, checkBoxGuessUnknownWords.Checked);
|
||||
line = _ocrFixEngine.FixUnknownWordsViaGuessOrPrompt(out wordsNotFound, line, listViewIndex, bitmap, checkBoxAutoFixCommonErrors.Checked, checkBoxPromptForUnknownWords.Checked, true, checkBoxGuessUnknownWords.Checked);
|
||||
}
|
||||
|
||||
if (_ocrFixEngine.Abort)
|
||||
@ -1319,7 +1332,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
_tessnetOcrAutoFixes++;
|
||||
labelFixesMade.Text = string.Format(" - {0}", _tessnetOcrAutoFixes);
|
||||
LogOcrFix(index, textWithOutFixes.ToString(), line);
|
||||
LogOcrFix(listViewIndex, textWithOutFixes.ToString(), line);
|
||||
}
|
||||
|
||||
return line;
|
||||
@ -2582,5 +2595,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
(sender as Timer).Stop();
|
||||
ButtonStartOcrClick(null, null);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -35,7 +35,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
return bmp;
|
||||
}
|
||||
|
||||
private static Bitmap CropTopAndBottom(Bitmap bmp, out int topCropping)
|
||||
public static Bitmap CropTopAndBottom(Bitmap bmp, out int topCropping)
|
||||
{
|
||||
int startTop = 0;
|
||||
int maxTop = bmp.Height-2;
|
||||
|
Loading…
Reference in New Issue
Block a user