mirror of
https://github.com/SubtitleEdit/subtitleedit.git
synced 2024-11-25 04:33:04 +01:00
Some minor improvements for OCR via "Binary image compare"
This commit is contained in:
parent
93e2ad8913
commit
7d09349e0b
@ -14,6 +14,7 @@
|
||||
* Ctrl+Backspace in text box works better with html tags - thx xylographe
|
||||
* Drag'n'drop to subtitle list now supports ifo/vob/mp4/mks (with subs) - thx Budman
|
||||
* Some improvements to cmd line (mostly multiplereplace) - thx xylographe
|
||||
* Some minor improvements for OCR via "Binary image compare"
|
||||
* FIXED:
|
||||
* Fix updating of main list view after "Remove text for HI" + "Apply" - thx Henry
|
||||
* Spell check "change" / "change all" issue regarding brackets/dash - thx jc
|
||||
@ -37,6 +38,7 @@
|
||||
* Fixed bug when converting ttml to ass - thx SwK
|
||||
* Fixed broken link to German dictionary - thx be-sc
|
||||
* Fixed crash in OCR when changing "Use color" - thx kurosu
|
||||
* Fixed end-time for (some) TS files - thx kurosu
|
||||
* + Many minor fixes from ivandrofly and xylographe
|
||||
|
||||
|
||||
|
@ -188,7 +188,6 @@
|
||||
<Word from="BIind" to="Blind" />
|
||||
<Word from="BIood" to="Blood" />
|
||||
<Word from="BIue" to="Blue" />
|
||||
<Word from="blonde" to="blonde" />
|
||||
<Word from="BLOVVS" to="BLOWS" />
|
||||
<Word from="blowholel" to="blowhole!" />
|
||||
<Word from="blt" to="bit" />
|
||||
@ -1818,6 +1817,52 @@
|
||||
<Word from="lron" to="Iron" />
|
||||
<Word from="It'syour" to="It's your" />
|
||||
<Word from="lfstill" to="if still" />
|
||||
<Word to="for joining" from="forjoining"/>
|
||||
<Word to="for years" from="foryears"/>
|
||||
<Word to="If it" from="Ifit"/>
|
||||
<Word to="not jump" from="notjump"/>
|
||||
<Word to="our problem" from="ourproblem"/>
|
||||
<Word to="your profile" from="yourprofile"/>
|
||||
<Word to="if Janine" from="ifJanine"/>
|
||||
<Word to="for preventative" from="forpreventative"/>
|
||||
<Word to="a hold" from="ahold"/>
|
||||
<Word to="whether protest" from="whetherprotest"/>
|
||||
<Word to="If not" from="Ifnot"/>
|
||||
<Word to="our people" from="ourpeople"/>
|
||||
<Word to="off my" from="offmy"/>
|
||||
<Word to="for providing" from="forproviding"/>
|
||||
<Word to="had just" from="hadjust"/>
|
||||
<Word to="near you" from="nearyou"/>
|
||||
<Word to="whatever you" from="whateveryou"/>
|
||||
<Word to="hour puts" from="hourputs"/>
|
||||
<Word to="time job" from="timejob"/>
|
||||
<Word to="over your" from="overyour"/>
|
||||
<Word to="or permanent" from="orpermanent"/>
|
||||
<Word to="create jobs" from="createjobs"/>
|
||||
<Word to="I've just" from="I'vejust"/>
|
||||
<Word to="people jobs" from="peoplejobs"/>
|
||||
<Word to="dinner pail" from="dinnerpail"/>
|
||||
<Word to="has jumped" from="hasjumped"/>
|
||||
<Word to="their privacy" from="theirprivacy"/>
|
||||
<Word to="All" from="AIl"/>
|
||||
<Word to="of serious" from="ofserious"/>
|
||||
<Word to="your professional" from="yourprofessional"/>
|
||||
<Word to="political" from="poiitical"/>
|
||||
<Word to="to jump" from="tojump"/>
|
||||
<Word to="lives" from="iives"/>
|
||||
<Word to="elections" from="eiections"/>
|
||||
<Word to="military juntas" from="militaryjuntas"/>
|
||||
<Word to="no joke" from="nojoke"/>
|
||||
<Word to="your presidency" from="yourpresidency"/>
|
||||
<Word to="of military juntas" from="ofmilitaryjuntas"/>
|
||||
<Word to="Our proposal" from="Ourproposal"/>
|
||||
<Word to="LeBlanc" from="LeBIanc"/>
|
||||
<Word to="Klaus" from="KIaus"/>
|
||||
<Word to="your pussy" from="yourpussy"/>
|
||||
<Word to="INTERVIEWER" from="lNTERVIEWER"/>
|
||||
<Word to="INAUDIBLE" from="lNAUDIBLE"/>
|
||||
<Word to="Simpsons" from="SImpsons"/>
|
||||
<Word from="tojump" to="to jump" />
|
||||
</WholeWords>
|
||||
<PartialWordsAlways>
|
||||
<!-- Will be replaced always -->
|
||||
@ -1850,9 +1895,8 @@
|
||||
<WordPart from="i" to="t" />
|
||||
<WordPart from="cc" to="oo" />
|
||||
<WordPart from="ii" to="tt" />
|
||||
<WordPart from="ii" to="ll" />
|
||||
<!-- "f " will be two words -->
|
||||
<WordPart from="f" to="f " />
|
||||
<WordPart from="ii" to="ll" />
|
||||
<WordPart from="f" to="f " /> <!-- "f " will be two words -->
|
||||
<WordPart from="c" to="e" />
|
||||
<WordPart from="I" to="t" />
|
||||
<WordPart from="n" to="o" />
|
||||
@ -2096,6 +2140,7 @@
|
||||
<LinePart from=". Lt " to=". It " />
|
||||
<LinePart from="! Lt " to="! It " />
|
||||
<LinePart from="? Lt " to="? It " />
|
||||
<LinePart from="SQMEWH ERE ELSE" to="SOMEWHERE ELSE" />
|
||||
</PartialLines>
|
||||
<PartialLinesAlways>
|
||||
<LinePart from="forbest act" to="for best act" />
|
||||
@ -2202,7 +2247,6 @@
|
||||
<Line from="[M EOWS]" to="[MEOWS]" />
|
||||
<Line from="Uaughs]" to="[laughs]" />
|
||||
<Line from="[chitte rs]" to="[chitters]" />
|
||||
<Line from="SQMEWH ERE ELSE" to="SOMEWHERE ELSE" />
|
||||
<Line from="Hil‘ it!" to="Hit it!" />
|
||||
<Line from="<i>Hil‘ it!</i>" to="<i>Hit it!</i>" />
|
||||
<Line from="ISIGHS]" to="[SIGHS]" />
|
||||
|
@ -5,6 +5,7 @@
|
||||
public int X { get; set; }
|
||||
public int Y { get; set; }
|
||||
public int ParentY { get; set; }
|
||||
public int Top { get; set; }
|
||||
public NikseBitmap NikseBitmap { get; set; }
|
||||
public string SpecialCharacter { get; set; }
|
||||
|
||||
|
@ -535,7 +535,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
return 0;
|
||||
}
|
||||
|
||||
public void CropTransparentSidesAndBottom(int maximumCropping, bool bottom)
|
||||
public int CropTransparentSidesAndBottom(int maximumCropping, bool bottom)
|
||||
{
|
||||
int leftStart = 0;
|
||||
bool done = false;
|
||||
@ -551,7 +551,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
done = true;
|
||||
leftStart = x;
|
||||
leftStart -= maximumCropping;
|
||||
if (leftStart > maximumCropping)
|
||||
leftStart = leftStart - maximumCropping;
|
||||
if (leftStart < 0)
|
||||
leftStart = 0;
|
||||
}
|
||||
@ -573,7 +574,8 @@ namespace Nikse.SubtitleEdit.Core
|
||||
{
|
||||
done = true;
|
||||
rightEnd = x;
|
||||
rightEnd += maximumCropping;
|
||||
if (Width - rightEnd > maximumCropping)
|
||||
rightEnd += maximumCropping;
|
||||
if (rightEnd >= Width)
|
||||
rightEnd = Width - 1;
|
||||
}
|
||||
@ -608,11 +610,11 @@ namespace Nikse.SubtitleEdit.Core
|
||||
}
|
||||
|
||||
if (leftStart < 2 && rightEnd >= Width - 3)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
int newWidth = rightEnd - leftStart + 1;
|
||||
if (newWidth <= 0)
|
||||
return;
|
||||
return 0;
|
||||
|
||||
var newBitmapData = new byte[newWidth * newHeight * 4];
|
||||
int index = 0;
|
||||
@ -625,6 +627,7 @@ namespace Nikse.SubtitleEdit.Core
|
||||
Width = newWidth;
|
||||
Height = newHeight;
|
||||
_bitmapData = newBitmapData;
|
||||
return leftStart;
|
||||
}
|
||||
|
||||
public void CropSidesAndBottom(int maximumCropping, Color transparentColor, bool bottom)
|
||||
|
33
src/Forms/VobSubEditCharacters.Designer.cs
generated
33
src/Forms/VobSubEditCharacters.Designer.cs
generated
@ -36,6 +36,7 @@
|
||||
this.labelChooseCharacters = new System.Windows.Forms.Label();
|
||||
this.labelImageCompareFiles = new System.Windows.Forms.Label();
|
||||
this.groupBoxCurrentCompareImage = new System.Windows.Forms.GroupBox();
|
||||
this.labelExpandCount = new System.Windows.Forms.Label();
|
||||
this.checkBoxItalic = new System.Windows.Forms.CheckBox();
|
||||
this.labelDoubleSize = new System.Windows.Forms.Label();
|
||||
this.pictureBox2 = new System.Windows.Forms.PictureBox();
|
||||
@ -49,7 +50,6 @@
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.labelCount = new System.Windows.Forms.Label();
|
||||
this.saveFileDialog1 = new System.Windows.Forms.SaveFileDialog();
|
||||
this.labelExpandCount = new System.Windows.Forms.Label();
|
||||
this.groupBoxCurrentCompareImage.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
|
||||
@ -73,7 +73,7 @@
|
||||
this.listBoxFileNames.FormattingEnabled = true;
|
||||
this.listBoxFileNames.Location = new System.Drawing.Point(12, 73);
|
||||
this.listBoxFileNames.Name = "listBoxFileNames";
|
||||
this.listBoxFileNames.Size = new System.Drawing.Size(240, 277);
|
||||
this.listBoxFileNames.Size = new System.Drawing.Size(240, 316);
|
||||
this.listBoxFileNames.TabIndex = 3;
|
||||
this.listBoxFileNames.SelectedIndexChanged += new System.EventHandler(this.ListBoxFileNamesSelectedIndexChanged);
|
||||
//
|
||||
@ -82,7 +82,7 @@
|
||||
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonOK.DialogResult = System.Windows.Forms.DialogResult.OK;
|
||||
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonOK.Location = new System.Drawing.Point(368, 355);
|
||||
this.buttonOK.Location = new System.Drawing.Point(420, 397);
|
||||
this.buttonOK.Name = "buttonOK";
|
||||
this.buttonOK.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonOK.TabIndex = 0;
|
||||
@ -135,11 +135,20 @@
|
||||
this.groupBoxCurrentCompareImage.Controls.Add(this.pictureBox1);
|
||||
this.groupBoxCurrentCompareImage.Location = new System.Drawing.Point(258, 67);
|
||||
this.groupBoxCurrentCompareImage.Name = "groupBoxCurrentCompareImage";
|
||||
this.groupBoxCurrentCompareImage.Size = new System.Drawing.Size(266, 282);
|
||||
this.groupBoxCurrentCompareImage.Size = new System.Drawing.Size(318, 324);
|
||||
this.groupBoxCurrentCompareImage.TabIndex = 6;
|
||||
this.groupBoxCurrentCompareImage.TabStop = false;
|
||||
this.groupBoxCurrentCompareImage.Text = "Current compare image";
|
||||
//
|
||||
// labelExpandCount
|
||||
//
|
||||
this.labelExpandCount.AutoSize = true;
|
||||
this.labelExpandCount.Location = new System.Drawing.Point(6, 264);
|
||||
this.labelExpandCount.Name = "labelExpandCount";
|
||||
this.labelExpandCount.Size = new System.Drawing.Size(94, 13);
|
||||
this.labelExpandCount.TabIndex = 28;
|
||||
this.labelExpandCount.Text = "labelExpandCount";
|
||||
//
|
||||
// checkBoxItalic
|
||||
//
|
||||
this.checkBoxItalic.AutoSize = true;
|
||||
@ -213,6 +222,7 @@
|
||||
this.pictureBox1.Location = new System.Drawing.Point(17, 104);
|
||||
this.pictureBox1.Name = "pictureBox1";
|
||||
this.pictureBox1.Size = new System.Drawing.Size(52, 52);
|
||||
this.pictureBox1.SizeMode = System.Windows.Forms.PictureBoxSizeMode.CenterImage;
|
||||
this.pictureBox1.TabIndex = 22;
|
||||
this.pictureBox1.TabStop = false;
|
||||
//
|
||||
@ -235,7 +245,7 @@
|
||||
this.buttonCancel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
this.buttonCancel.DialogResult = System.Windows.Forms.DialogResult.Cancel;
|
||||
this.buttonCancel.ImeMode = System.Windows.Forms.ImeMode.NoControl;
|
||||
this.buttonCancel.Location = new System.Drawing.Point(449, 355);
|
||||
this.buttonCancel.Location = new System.Drawing.Point(501, 397);
|
||||
this.buttonCancel.Name = "buttonCancel";
|
||||
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
|
||||
this.buttonCancel.TabIndex = 7;
|
||||
@ -246,26 +256,17 @@
|
||||
//
|
||||
this.labelCount.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
|
||||
this.labelCount.AutoSize = true;
|
||||
this.labelCount.Location = new System.Drawing.Point(12, 359);
|
||||
this.labelCount.Location = new System.Drawing.Point(12, 401);
|
||||
this.labelCount.Name = "labelCount";
|
||||
this.labelCount.Size = new System.Drawing.Size(58, 13);
|
||||
this.labelCount.TabIndex = 8;
|
||||
this.labelCount.Text = "labelCount";
|
||||
//
|
||||
// labelExpandCount
|
||||
//
|
||||
this.labelExpandCount.AutoSize = true;
|
||||
this.labelExpandCount.Location = new System.Drawing.Point(6, 264);
|
||||
this.labelExpandCount.Name = "labelExpandCount";
|
||||
this.labelExpandCount.Size = new System.Drawing.Size(94, 13);
|
||||
this.labelExpandCount.TabIndex = 28;
|
||||
this.labelExpandCount.Text = "labelExpandCount";
|
||||
//
|
||||
// VobSubEditCharacters
|
||||
//
|
||||
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
|
||||
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
|
||||
this.ClientSize = new System.Drawing.Size(536, 384);
|
||||
this.ClientSize = new System.Drawing.Size(588, 426);
|
||||
this.Controls.Add(this.labelCount);
|
||||
this.Controls.Add(this.buttonCancel);
|
||||
this.Controls.Add(this.groupBoxCurrentCompareImage);
|
||||
|
@ -16,7 +16,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
private string _directoryPath;
|
||||
private List<bool> _italics = new List<bool>();
|
||||
internal List<VobSubOcr.ImageCompareAddition> Additions { get; private set; }
|
||||
private BinaryOcrDb _binOcrDb = null;
|
||||
private readonly BinaryOcrDb _binOcrDb;
|
||||
|
||||
public XmlDocument ImageCompareDocument
|
||||
{
|
||||
@ -267,15 +267,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
checkBoxItalic.Checked = _italics[listBoxFileNames.SelectedIndex];
|
||||
string name = listBoxFileNames.Items[listBoxFileNames.SelectedIndex].ToString();
|
||||
string databaseName = _directoryPath + "Images.db";
|
||||
string posAsString = GetSelectedFileName();
|
||||
Bitmap bmp = null;
|
||||
labelExpandCount.Text = string.Empty;
|
||||
labelImageInfo.Text = string.Empty;
|
||||
if (_binOcrDb != null)
|
||||
{
|
||||
var bob = GetSelectedBinOcrBitmap();
|
||||
if (bob != null)
|
||||
{
|
||||
bmp = bob.ToOldBitmap();
|
||||
labelImageInfo.Text = string.Format("Top:{0}, {1} colored pixels of {2}", bob.Y, bob.NumberOfColoredPixels, (bob.Width * bob.Height));
|
||||
// labelImageInfo.Text = string.Format("T:{0} -{1} :{2} i{3} !{4} '{5} #{6}/{7}", bob.Y, bob.IsDash(), bob.IsColon(), bob.IsLowercaseI(), bob.IsExclamationMark(), bob.IsApostrophe(), bob.NumberOfColoredPixels, (bob.Width * bob.Height));
|
||||
if (bob.ExpandCount > 0)
|
||||
{
|
||||
labelExpandCount.Text = string.Format("Expand count: {0}", bob.ExpandCount);
|
||||
@ -298,10 +300,17 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
bmp = new Bitmap(1, 1);
|
||||
labelImageInfo.Text = Configuration.Settings.Language.VobSubEditCharacters.ImageFileNotFound;
|
||||
}
|
||||
|
||||
pictureBox1.Image = bmp;
|
||||
pictureBox2.Width = bmp.Width * 2;
|
||||
pictureBox2.Height = bmp.Height * 2;
|
||||
pictureBox2.Image = bmp;
|
||||
pictureBox1.Width = bmp.Width + 2;
|
||||
pictureBox1.Height = bmp.Height + 2;
|
||||
pictureBox1.SizeMode = PictureBoxSizeMode.CenterImage;
|
||||
|
||||
var bmp2 = VobSubOcr.ResizeBitmap(bmp, bmp.Width * 2, bmp.Height * 2);
|
||||
pictureBox2.Image = bmp2;
|
||||
pictureBox2.Width = bmp2.Width + 2;
|
||||
pictureBox2.Height = bmp2.Height + 2;
|
||||
pictureBox2.SizeMode = PictureBoxSizeMode.CenterImage;
|
||||
|
||||
if (Additions != null && Additions.Count > 0)
|
||||
{
|
||||
@ -406,6 +415,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
i++;
|
||||
}
|
||||
}
|
||||
listBoxFileNames.Focus();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -620,5 +630,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
267
src/Forms/VobSubOcr.Designer.cs
generated
267
src/Forms/VobSubOcr.Designer.cs
generated
@ -48,16 +48,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.buttonCancel = new System.Windows.Forms.Button();
|
||||
this.groupBoxOcrMethod = new System.Windows.Forms.GroupBox();
|
||||
this.comboBoxOcrMethod = new System.Windows.Forms.ComboBox();
|
||||
this.groupBoxNOCR = new System.Windows.Forms.GroupBox();
|
||||
this.buttonLineOcrEditLanguage = new System.Windows.Forms.Button();
|
||||
this.buttonLineOcrNewLanguage = new System.Windows.Forms.Button();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.comboBoxNOcrLanguage = new System.Windows.Forms.ComboBox();
|
||||
this.checkBoxNOcrItalic = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxNOcrCorrect = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxRightToLeftNOCR = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelNumberOfPixelsIsSpaceNOCR = new System.Windows.Forms.Label();
|
||||
this.groupBoxImageCompareMethod = new System.Windows.Forms.GroupBox();
|
||||
this.labelMaxErrorPercent = new System.Windows.Forms.Label();
|
||||
this.numericUpDownMaxErrorPct = new System.Windows.Forms.NumericUpDown();
|
||||
@ -78,6 +68,16 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.groupBoxModiMethod = new System.Windows.Forms.GroupBox();
|
||||
this.label1 = new System.Windows.Forms.Label();
|
||||
this.comboBoxModiLanguage = new System.Windows.Forms.ComboBox();
|
||||
this.groupBoxNOCR = new System.Windows.Forms.GroupBox();
|
||||
this.buttonLineOcrEditLanguage = new System.Windows.Forms.Button();
|
||||
this.buttonLineOcrNewLanguage = new System.Windows.Forms.Button();
|
||||
this.label2 = new System.Windows.Forms.Label();
|
||||
this.comboBoxNOcrLanguage = new System.Windows.Forms.ComboBox();
|
||||
this.checkBoxNOcrItalic = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxNOcrCorrect = new System.Windows.Forms.CheckBox();
|
||||
this.checkBoxRightToLeftNOCR = new System.Windows.Forms.CheckBox();
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR = new System.Windows.Forms.NumericUpDown();
|
||||
this.labelNumberOfPixelsIsSpaceNOCR = new System.Windows.Forms.Label();
|
||||
this.groupBoxOCRControls = new System.Windows.Forms.GroupBox();
|
||||
this.labelStartFrom = new System.Windows.Forms.Label();
|
||||
this.numericUpDownStartNumber = new System.Windows.Forms.NumericUpDown();
|
||||
@ -141,13 +141,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.timerHideStatus = new System.Windows.Forms.Timer(this.components);
|
||||
this.contextMenuStripListview.SuspendLayout();
|
||||
this.groupBoxOcrMethod.SuspendLayout();
|
||||
this.groupBoxNOCR.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPixelsIsSpaceNOCR)).BeginInit();
|
||||
this.groupBoxImageCompareMethod.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxErrorPct)).BeginInit();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsIsSpace)).BeginInit();
|
||||
this.GroupBoxTesseractMethod.SuspendLayout();
|
||||
this.groupBoxModiMethod.SuspendLayout();
|
||||
this.groupBoxNOCR.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPixelsIsSpaceNOCR)).BeginInit();
|
||||
this.groupBoxOCRControls.SuspendLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownStartNumber)).BeginInit();
|
||||
this.groupBoxOcrAutoFix.SuspendLayout();
|
||||
@ -428,124 +428,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.comboBoxOcrMethod.TabIndex = 0;
|
||||
this.comboBoxOcrMethod.SelectedIndexChanged += new System.EventHandler(this.ComboBoxOcrMethodSelectedIndexChanged);
|
||||
//
|
||||
// groupBoxNOCR
|
||||
//
|
||||
this.groupBoxNOCR.Controls.Add(this.buttonLineOcrEditLanguage);
|
||||
this.groupBoxNOCR.Controls.Add(this.buttonLineOcrNewLanguage);
|
||||
this.groupBoxNOCR.Controls.Add(this.label2);
|
||||
this.groupBoxNOCR.Controls.Add(this.comboBoxNOcrLanguage);
|
||||
this.groupBoxNOCR.Controls.Add(this.checkBoxNOcrItalic);
|
||||
this.groupBoxNOCR.Controls.Add(this.checkBoxNOcrCorrect);
|
||||
this.groupBoxNOCR.Controls.Add(this.checkBoxRightToLeftNOCR);
|
||||
this.groupBoxNOCR.Controls.Add(this.numericUpDownNumberOfPixelsIsSpaceNOCR);
|
||||
this.groupBoxNOCR.Controls.Add(this.labelNumberOfPixelsIsSpaceNOCR);
|
||||
this.groupBoxNOCR.Location = new System.Drawing.Point(7, 38);
|
||||
this.groupBoxNOCR.Name = "groupBoxNOCR";
|
||||
this.groupBoxNOCR.Size = new System.Drawing.Size(366, 131);
|
||||
this.groupBoxNOCR.TabIndex = 7;
|
||||
this.groupBoxNOCR.TabStop = false;
|
||||
this.groupBoxNOCR.Text = "nOCR";
|
||||
//
|
||||
// buttonLineOcrEditLanguage
|
||||
//
|
||||
this.buttonLineOcrEditLanguage.Location = new System.Drawing.Point(210, 97);
|
||||
this.buttonLineOcrEditLanguage.Name = "buttonLineOcrEditLanguage";
|
||||
this.buttonLineOcrEditLanguage.Size = new System.Drawing.Size(68, 21);
|
||||
this.buttonLineOcrEditLanguage.TabIndex = 41;
|
||||
this.buttonLineOcrEditLanguage.Text = "Edit";
|
||||
this.buttonLineOcrEditLanguage.UseVisualStyleBackColor = true;
|
||||
this.buttonLineOcrEditLanguage.Click += new System.EventHandler(this.buttonLineOcrEditLanguage_Click);
|
||||
//
|
||||
// buttonLineOcrNewLanguage
|
||||
//
|
||||
this.buttonLineOcrNewLanguage.Location = new System.Drawing.Point(283, 97);
|
||||
this.buttonLineOcrNewLanguage.Name = "buttonLineOcrNewLanguage";
|
||||
this.buttonLineOcrNewLanguage.Size = new System.Drawing.Size(68, 21);
|
||||
this.buttonLineOcrNewLanguage.TabIndex = 40;
|
||||
this.buttonLineOcrNewLanguage.Text = "New";
|
||||
this.buttonLineOcrNewLanguage.UseVisualStyleBackColor = true;
|
||||
this.buttonLineOcrNewLanguage.Click += new System.EventHandler(this.buttonLineOcrNewLanguage_Click);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(11, 101);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(54, 13);
|
||||
this.label2.TabIndex = 35;
|
||||
this.label2.Text = "Language";
|
||||
//
|
||||
// comboBoxNOcrLanguage
|
||||
//
|
||||
this.comboBoxNOcrLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxNOcrLanguage.FormattingEnabled = true;
|
||||
this.comboBoxNOcrLanguage.Location = new System.Drawing.Point(74, 97);
|
||||
this.comboBoxNOcrLanguage.Name = "comboBoxNOcrLanguage";
|
||||
this.comboBoxNOcrLanguage.Size = new System.Drawing.Size(130, 21);
|
||||
this.comboBoxNOcrLanguage.TabIndex = 34;
|
||||
this.comboBoxNOcrLanguage.SelectedIndexChanged += new System.EventHandler(this.comboBoxNOcrLanguage_SelectedIndexChanged);
|
||||
//
|
||||
// checkBoxNOcrItalic
|
||||
//
|
||||
this.checkBoxNOcrItalic.AutoSize = true;
|
||||
this.checkBoxNOcrItalic.Location = new System.Drawing.Point(15, 42);
|
||||
this.checkBoxNOcrItalic.Name = "checkBoxNOcrItalic";
|
||||
this.checkBoxNOcrItalic.Size = new System.Drawing.Size(92, 17);
|
||||
this.checkBoxNOcrItalic.TabIndex = 8;
|
||||
this.checkBoxNOcrItalic.Text = "Contains italic";
|
||||
this.checkBoxNOcrItalic.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxNOcrCorrect
|
||||
//
|
||||
this.checkBoxNOcrCorrect.AutoSize = true;
|
||||
this.checkBoxNOcrCorrect.Location = new System.Drawing.Point(235, 17);
|
||||
this.checkBoxNOcrCorrect.Name = "checkBoxNOcrCorrect";
|
||||
this.checkBoxNOcrCorrect.Size = new System.Drawing.Size(116, 17);
|
||||
this.checkBoxNOcrCorrect.TabIndex = 7;
|
||||
this.checkBoxNOcrCorrect.Text = "Draw missing texts";
|
||||
this.checkBoxNOcrCorrect.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRightToLeftNOCR
|
||||
//
|
||||
this.checkBoxRightToLeftNOCR.AutoSize = true;
|
||||
this.checkBoxRightToLeftNOCR.Location = new System.Drawing.Point(235, 40);
|
||||
this.checkBoxRightToLeftNOCR.Name = "checkBoxRightToLeftNOCR";
|
||||
this.checkBoxRightToLeftNOCR.Size = new System.Drawing.Size(83, 17);
|
||||
this.checkBoxRightToLeftNOCR.TabIndex = 6;
|
||||
this.checkBoxRightToLeftNOCR.Text = "Right to left";
|
||||
this.checkBoxRightToLeftNOCR.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownNumberOfPixelsIsSpaceNOCR
|
||||
//
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Location = new System.Drawing.Point(122, 17);
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Maximum = new decimal(new int[] {
|
||||
50,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Name = "numericUpDownNumberOfPixelsIsSpaceNOCR";
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Size = new System.Drawing.Size(50, 21);
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.TabIndex = 5;
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Value = new decimal(new int[] {
|
||||
12,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelNumberOfPixelsIsSpaceNOCR
|
||||
//
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.AutoSize = true;
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Location = new System.Drawing.Point(12, 20);
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Name = "labelNumberOfPixelsIsSpaceNOCR";
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Size = new System.Drawing.Size(104, 13);
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.TabIndex = 4;
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Text = "No of pixels is space";
|
||||
//
|
||||
// groupBoxImageCompareMethod
|
||||
//
|
||||
this.groupBoxImageCompareMethod.Controls.Add(this.labelMaxErrorPercent);
|
||||
@ -794,6 +676,124 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.comboBoxModiLanguage.TabIndex = 0;
|
||||
this.comboBoxModiLanguage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxModiLanguageSelectedIndexChanged);
|
||||
//
|
||||
// groupBoxNOCR
|
||||
//
|
||||
this.groupBoxNOCR.Controls.Add(this.buttonLineOcrEditLanguage);
|
||||
this.groupBoxNOCR.Controls.Add(this.buttonLineOcrNewLanguage);
|
||||
this.groupBoxNOCR.Controls.Add(this.label2);
|
||||
this.groupBoxNOCR.Controls.Add(this.comboBoxNOcrLanguage);
|
||||
this.groupBoxNOCR.Controls.Add(this.checkBoxNOcrItalic);
|
||||
this.groupBoxNOCR.Controls.Add(this.checkBoxNOcrCorrect);
|
||||
this.groupBoxNOCR.Controls.Add(this.checkBoxRightToLeftNOCR);
|
||||
this.groupBoxNOCR.Controls.Add(this.numericUpDownNumberOfPixelsIsSpaceNOCR);
|
||||
this.groupBoxNOCR.Controls.Add(this.labelNumberOfPixelsIsSpaceNOCR);
|
||||
this.groupBoxNOCR.Location = new System.Drawing.Point(7, 38);
|
||||
this.groupBoxNOCR.Name = "groupBoxNOCR";
|
||||
this.groupBoxNOCR.Size = new System.Drawing.Size(366, 131);
|
||||
this.groupBoxNOCR.TabIndex = 7;
|
||||
this.groupBoxNOCR.TabStop = false;
|
||||
this.groupBoxNOCR.Text = "nOCR";
|
||||
//
|
||||
// buttonLineOcrEditLanguage
|
||||
//
|
||||
this.buttonLineOcrEditLanguage.Location = new System.Drawing.Point(210, 97);
|
||||
this.buttonLineOcrEditLanguage.Name = "buttonLineOcrEditLanguage";
|
||||
this.buttonLineOcrEditLanguage.Size = new System.Drawing.Size(68, 21);
|
||||
this.buttonLineOcrEditLanguage.TabIndex = 41;
|
||||
this.buttonLineOcrEditLanguage.Text = "Edit";
|
||||
this.buttonLineOcrEditLanguage.UseVisualStyleBackColor = true;
|
||||
this.buttonLineOcrEditLanguage.Click += new System.EventHandler(this.buttonLineOcrEditLanguage_Click);
|
||||
//
|
||||
// buttonLineOcrNewLanguage
|
||||
//
|
||||
this.buttonLineOcrNewLanguage.Location = new System.Drawing.Point(283, 97);
|
||||
this.buttonLineOcrNewLanguage.Name = "buttonLineOcrNewLanguage";
|
||||
this.buttonLineOcrNewLanguage.Size = new System.Drawing.Size(68, 21);
|
||||
this.buttonLineOcrNewLanguage.TabIndex = 40;
|
||||
this.buttonLineOcrNewLanguage.Text = "New";
|
||||
this.buttonLineOcrNewLanguage.UseVisualStyleBackColor = true;
|
||||
this.buttonLineOcrNewLanguage.Click += new System.EventHandler(this.buttonLineOcrNewLanguage_Click);
|
||||
//
|
||||
// label2
|
||||
//
|
||||
this.label2.AutoSize = true;
|
||||
this.label2.Location = new System.Drawing.Point(11, 101);
|
||||
this.label2.Name = "label2";
|
||||
this.label2.Size = new System.Drawing.Size(54, 13);
|
||||
this.label2.TabIndex = 35;
|
||||
this.label2.Text = "Language";
|
||||
//
|
||||
// comboBoxNOcrLanguage
|
||||
//
|
||||
this.comboBoxNOcrLanguage.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
|
||||
this.comboBoxNOcrLanguage.FormattingEnabled = true;
|
||||
this.comboBoxNOcrLanguage.Location = new System.Drawing.Point(74, 97);
|
||||
this.comboBoxNOcrLanguage.Name = "comboBoxNOcrLanguage";
|
||||
this.comboBoxNOcrLanguage.Size = new System.Drawing.Size(130, 21);
|
||||
this.comboBoxNOcrLanguage.TabIndex = 34;
|
||||
this.comboBoxNOcrLanguage.SelectedIndexChanged += new System.EventHandler(this.comboBoxNOcrLanguage_SelectedIndexChanged);
|
||||
//
|
||||
// checkBoxNOcrItalic
|
||||
//
|
||||
this.checkBoxNOcrItalic.AutoSize = true;
|
||||
this.checkBoxNOcrItalic.Location = new System.Drawing.Point(15, 42);
|
||||
this.checkBoxNOcrItalic.Name = "checkBoxNOcrItalic";
|
||||
this.checkBoxNOcrItalic.Size = new System.Drawing.Size(92, 17);
|
||||
this.checkBoxNOcrItalic.TabIndex = 8;
|
||||
this.checkBoxNOcrItalic.Text = "Contains italic";
|
||||
this.checkBoxNOcrItalic.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxNOcrCorrect
|
||||
//
|
||||
this.checkBoxNOcrCorrect.AutoSize = true;
|
||||
this.checkBoxNOcrCorrect.Location = new System.Drawing.Point(235, 17);
|
||||
this.checkBoxNOcrCorrect.Name = "checkBoxNOcrCorrect";
|
||||
this.checkBoxNOcrCorrect.Size = new System.Drawing.Size(116, 17);
|
||||
this.checkBoxNOcrCorrect.TabIndex = 7;
|
||||
this.checkBoxNOcrCorrect.Text = "Draw missing texts";
|
||||
this.checkBoxNOcrCorrect.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// checkBoxRightToLeftNOCR
|
||||
//
|
||||
this.checkBoxRightToLeftNOCR.AutoSize = true;
|
||||
this.checkBoxRightToLeftNOCR.Location = new System.Drawing.Point(235, 40);
|
||||
this.checkBoxRightToLeftNOCR.Name = "checkBoxRightToLeftNOCR";
|
||||
this.checkBoxRightToLeftNOCR.Size = new System.Drawing.Size(83, 17);
|
||||
this.checkBoxRightToLeftNOCR.TabIndex = 6;
|
||||
this.checkBoxRightToLeftNOCR.Text = "Right to left";
|
||||
this.checkBoxRightToLeftNOCR.UseVisualStyleBackColor = true;
|
||||
//
|
||||
// numericUpDownNumberOfPixelsIsSpaceNOCR
|
||||
//
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Location = new System.Drawing.Point(122, 17);
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Maximum = new decimal(new int[] {
|
||||
50,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Minimum = new decimal(new int[] {
|
||||
1,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Name = "numericUpDownNumberOfPixelsIsSpaceNOCR";
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Size = new System.Drawing.Size(50, 21);
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.TabIndex = 5;
|
||||
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Value = new decimal(new int[] {
|
||||
12,
|
||||
0,
|
||||
0,
|
||||
0});
|
||||
//
|
||||
// labelNumberOfPixelsIsSpaceNOCR
|
||||
//
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.AutoSize = true;
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Location = new System.Drawing.Point(12, 20);
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Name = "labelNumberOfPixelsIsSpaceNOCR";
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Size = new System.Drawing.Size(104, 13);
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.TabIndex = 4;
|
||||
this.labelNumberOfPixelsIsSpaceNOCR.Text = "No of pixels is space";
|
||||
//
|
||||
// groupBoxOCRControls
|
||||
//
|
||||
this.groupBoxOCRControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
|
||||
@ -1491,6 +1491,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.subtitleListView1.UseSyntaxColoring = true;
|
||||
this.subtitleListView1.View = System.Windows.Forms.View.Details;
|
||||
this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged);
|
||||
this.subtitleListView1.DoubleClick += new System.EventHandler(this.subtitleListView1_DoubleClick);
|
||||
this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown);
|
||||
//
|
||||
// timerHideStatus
|
||||
@ -1525,9 +1526,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.Resize += new System.EventHandler(this.VobSubOcr_Resize);
|
||||
this.contextMenuStripListview.ResumeLayout(false);
|
||||
this.groupBoxOcrMethod.ResumeLayout(false);
|
||||
this.groupBoxNOCR.ResumeLayout(false);
|
||||
this.groupBoxNOCR.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPixelsIsSpaceNOCR)).EndInit();
|
||||
this.groupBoxImageCompareMethod.ResumeLayout(false);
|
||||
this.groupBoxImageCompareMethod.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownMaxErrorPct)).EndInit();
|
||||
@ -1536,6 +1534,9 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
this.GroupBoxTesseractMethod.PerformLayout();
|
||||
this.groupBoxModiMethod.ResumeLayout(false);
|
||||
this.groupBoxModiMethod.PerformLayout();
|
||||
this.groupBoxNOCR.ResumeLayout(false);
|
||||
this.groupBoxNOCR.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPixelsIsSpaceNOCR)).EndInit();
|
||||
this.groupBoxOCRControls.ResumeLayout(false);
|
||||
this.groupBoxOCRControls.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.numericUpDownStartNumber)).EndInit();
|
||||
|
@ -3072,13 +3072,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
int index = 0;
|
||||
int smallestDifference = 10000;
|
||||
int smallestIndex = -1;
|
||||
NikseBitmap target = targetItem.NikseBitmap;
|
||||
var target = targetItem.NikseBitmap;
|
||||
if (_binaryOcrDb == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
var bob = new BinaryOcrBitmap(target);
|
||||
var bob = new BinaryOcrBitmap(target) { X = targetItem.X, Y = targetItem.Top };
|
||||
|
||||
for (int k = 0; k < _binaryOcrDb.CompareImagesExpanded.Count; k++)
|
||||
{
|
||||
@ -3100,7 +3100,6 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
if (ok)
|
||||
{
|
||||
secondBestGuess = null;
|
||||
return new CompareMatch(b.Text, b.Italic, b.ExpandCount, b.Key);
|
||||
}
|
||||
}
|
||||
@ -3152,21 +3151,74 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
SetBinOcrLowercaseUppercase(hit.Height, text);
|
||||
}
|
||||
if (differencePercentage > 0)
|
||||
{
|
||||
if ((hit.Text == "l" || hit.Text == "!") && bob.IsLowercaseI())
|
||||
{
|
||||
hit = null;
|
||||
}
|
||||
else if ((hit.Text == "i" || hit.Text == "!") && bob.IsLowercaseL())
|
||||
{
|
||||
hit = null;
|
||||
}
|
||||
else if ((hit.Text == "o" || hit.Text == "O") && bob.IsC())
|
||||
{
|
||||
return new CompareMatch(hit.Text == "o" ? "c" : "C", false, 0, null);
|
||||
}
|
||||
else if ((hit.Text == "c" || hit.Text == "C") && !bob.IsC() && bob.IsO())
|
||||
{
|
||||
return new CompareMatch(hit.Text == "c" ? "o" : "O", false, 0, null);
|
||||
}
|
||||
}
|
||||
|
||||
return new CompareMatch(text, hit.Italic, hit.ExpandCount, hit.Key);
|
||||
if (hit != null)
|
||||
{
|
||||
if (_binOcrLastLowercaseHeight < 0 && differencePercentage < 9 && (text == "e" || text == "d" || text == "a"))
|
||||
_binOcrLastLowercaseHeight = bob.Height;
|
||||
return new CompareMatch(text, hit.Italic, hit.ExpandCount, hit.Key);
|
||||
}
|
||||
}
|
||||
|
||||
var guess = _binaryOcrDb.CompareImages[smallestIndex];
|
||||
secondBestGuess = new CompareMatch(guess.Text, guess.Italic, guess.ExpandCount, guess.Key);
|
||||
}
|
||||
|
||||
if (bob.IsPeriod())
|
||||
{
|
||||
return new CompareMatch(".", false, 0, null);
|
||||
}
|
||||
if (bob.IsComma())
|
||||
{
|
||||
return new CompareMatch(",", false, 0, null);
|
||||
}
|
||||
if (bob.IsApostrophe())
|
||||
{
|
||||
return new CompareMatch("'", false, 0, null);
|
||||
}
|
||||
if (bob.IsLowercaseI())
|
||||
{
|
||||
return new CompareMatch("i", false, 0, null);
|
||||
}
|
||||
if (bob.IsColon())
|
||||
{
|
||||
return new CompareMatch(":", false, 0, null);
|
||||
}
|
||||
if (bob.IsExclamationMark())
|
||||
{
|
||||
return new CompareMatch("!", false, 0, null);
|
||||
}
|
||||
if (bob.IsDash())
|
||||
{
|
||||
return new CompareMatch("-", false, 0, null);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Bitmap CopyBitmapSection(Bitmap srcBitmap, Rectangle section)
|
||||
{
|
||||
Bitmap bmp = new Bitmap(section.Width, section.Height);
|
||||
Graphics g = Graphics.FromImage(bmp);
|
||||
var bmp = new Bitmap(section.Width, section.Height);
|
||||
var g = Graphics.FromImage(bmp);
|
||||
g.DrawImage(srcBitmap, 0, 0, section, GraphicsUnit.Pixel);
|
||||
g.Dispose();
|
||||
return bmp;
|
||||
@ -3885,13 +3937,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
|
||||
if (expandCount > 0)
|
||||
{
|
||||
var bob = new BinaryOcrBitmap(expandList[0].NikseBitmap, isItalic, expandCount, text, expandList[0].X, expandList[0].Y);
|
||||
var bob = new BinaryOcrBitmap(expandList[0].NikseBitmap, isItalic, expandCount, text, expandList[0].X, expandList[0].Top);
|
||||
bob.ExpandedList = new List<BinaryOcrBitmap>();
|
||||
for (int j = 1; j < expandList.Count; j++)
|
||||
{
|
||||
var expandedBob = new BinaryOcrBitmap(expandList[j].NikseBitmap);
|
||||
expandedBob.X = expandList[j].X;
|
||||
expandedBob.Y = expandList[j].Y;
|
||||
expandedBob.Y = expandList[j].Top;
|
||||
bob.ExpandedList.Add(expandedBob);
|
||||
}
|
||||
_binaryOcrDb.Add(bob);
|
||||
@ -3900,7 +3952,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
}
|
||||
else
|
||||
{
|
||||
var bob = new BinaryOcrBitmap(newTarget.NikseBitmap, isItalic, expandCount, text, newTarget.X, newTarget.Y);
|
||||
var bob = new BinaryOcrBitmap(newTarget.NikseBitmap, isItalic, expandCount, text, newTarget.X, newTarget.Top);
|
||||
_binaryOcrDb.Add(bob);
|
||||
_binaryOcrDb.Save();
|
||||
return bob.Key;
|
||||
@ -5462,7 +5514,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
var bitmap = (Bitmap)e.Argument;
|
||||
if (bitmap != null)
|
||||
{
|
||||
if (_tesseractAsyncIndex >= 0 && _tesseractAsyncStrings != null && _tesseractAsyncIndex < _tesseractAsyncStrings.Length)
|
||||
if (_tesseractAsyncIndex >= 0 && _tesseractAsyncStrings != null && _tesseractAsyncIndex < _tesseractAsyncStrings.Length)
|
||||
{
|
||||
if (string.IsNullOrEmpty(_tesseractAsyncStrings[_tesseractAsyncIndex]))
|
||||
_tesseractAsyncStrings[_tesseractAsyncIndex] = Tesseract3DoOcrViaExe(bitmap, _languageId, "-psm 6"); // 6 = Assume a single uniform block of text.);
|
||||
@ -5751,7 +5803,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
SaveNOcr();
|
||||
}
|
||||
|
||||
private static Bitmap ResizeBitmap(Bitmap b, int width, int height)
|
||||
public static Bitmap ResizeBitmap(Bitmap b, int width, int height)
|
||||
{
|
||||
var result = new Bitmap(width, height);
|
||||
using (Graphics g = Graphics.FromImage(result))
|
||||
@ -8753,5 +8805,13 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_numericUpDownMaxErrorPct = (double)numericUpDownMaxErrorPct.Value;
|
||||
}
|
||||
|
||||
private void subtitleListView1_DoubleClick(object sender, EventArgs e)
|
||||
{
|
||||
if (subtitleListView1.SelectedItems.Count > 0 && (_ocrMethodIndex == _ocrMethodBinaryImageCompare || _ocrMethodIndex == _ocrMethodImageCompare))
|
||||
{
|
||||
inspectImageCompareMatchesForCurrentImageToolStripMenuItem_Click(null, null);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
2
src/Forms/VobSubOcrCharacterInspect.Designer.cs
generated
2
src/Forms/VobSubOcrCharacterInspect.Designer.cs
generated
@ -264,7 +264,7 @@
|
||||
this.ShowIcon = false;
|
||||
this.ShowInTaskbar = false;
|
||||
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
|
||||
this.Text = "VobSubOcrCharacterInspect";
|
||||
this.Text = " ";
|
||||
this.groupBoxCurrentCompareImage.ResumeLayout(false);
|
||||
this.groupBoxCurrentCompareImage.PerformLayout();
|
||||
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCompareBitmapDouble)).EndInit();
|
||||
|
@ -147,11 +147,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (node.Attributes["Text"] != null && node.InnerText == match.Name)
|
||||
{
|
||||
string text = node.Attributes["Text"].InnerText;
|
||||
string imageFileName = node.InnerText;
|
||||
imageFileName = Path.Combine(_directoryPath, imageFileName);
|
||||
textBoxText.Text = text;
|
||||
checkBoxItalic.Checked = node.Attributes["Italic"] != null;
|
||||
|
||||
string databaseName = Path.Combine(_directoryPath, "Images.db");
|
||||
using (var f = new FileStream(databaseName, FileMode.Open))
|
||||
{
|
||||
@ -197,8 +194,8 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
{
|
||||
buttonUpdate.Enabled = false;
|
||||
buttonDelete.Enabled = false;
|
||||
buttonAddBetterMatch.Enabled = false;
|
||||
textBoxText.Enabled = false;
|
||||
buttonAddBetterMatch.Enabled = true;
|
||||
textBoxText.Enabled = true;
|
||||
textBoxText.Text = string.Empty;
|
||||
checkBoxItalic.Enabled = false;
|
||||
}
|
||||
@ -238,7 +235,10 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
_selectedCompareBinaryOcrBitmap.Text = newText;
|
||||
_selectedCompareBinaryOcrBitmap.Italic = checkBoxItalic.Checked;
|
||||
listBoxInspectItems.SelectedIndexChanged -= listBoxInspectItems_SelectedIndexChanged;
|
||||
listBoxInspectItems.Items[listBoxInspectItems.SelectedIndex] = newText;
|
||||
if (checkBoxItalic.Checked)
|
||||
listBoxInspectItems.Items[listBoxInspectItems.SelectedIndex] = newText + " (italic)";
|
||||
else
|
||||
listBoxInspectItems.Items[listBoxInspectItems.SelectedIndex] = newText;
|
||||
listBoxInspectItems.SelectedIndexChanged += listBoxInspectItems_SelectedIndexChanged;
|
||||
}
|
||||
else
|
||||
@ -308,15 +308,23 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
return;
|
||||
}
|
||||
|
||||
if (_selectedCompareBinaryOcrBitmap != null || (_binOcrDb != null && _selectedMatch.Text == Configuration.Settings.Language.VobSubOcr.NoMatch))
|
||||
if (_selectedCompareBinaryOcrBitmap != null || (_binOcrDb != null && (_selectedMatch.Text == Configuration.Settings.Language.VobSubOcr.NoMatch || _selectedMatch.NOcrCharacter == null)))
|
||||
{
|
||||
var nbmp = new NikseBitmap((pictureBoxInspectItem.Image as Bitmap));
|
||||
int x = 0;
|
||||
int y = 0;
|
||||
if (_selectedMatch != null && _selectedMatch.ImageSplitterItem != null)
|
||||
{
|
||||
x = _selectedMatch.X;
|
||||
y = _selectedMatch.Y;
|
||||
if (_selectedMatch.ImageSplitterItem != null)
|
||||
{
|
||||
x = _selectedMatch.ImageSplitterItem.X;
|
||||
y = _selectedMatch.ImageSplitterItem.Top;
|
||||
}
|
||||
else
|
||||
{
|
||||
x = _selectedMatch.X;
|
||||
y = _selectedMatch.Y;
|
||||
}
|
||||
}
|
||||
var bob = new BinaryOcrBitmap(nbmp, checkBoxItalic.Checked, 0, textBoxText.Text, x, y);
|
||||
_binOcrDb.Add(bob);
|
||||
@ -338,7 +346,7 @@ namespace Nikse.SubtitleEdit.Forms
|
||||
if (_selectedCompareNode != null)
|
||||
{
|
||||
XmlNode newNode = ImageCompareDocument.CreateElement("Item");
|
||||
XmlAttribute text = newNode.OwnerDocument.CreateAttribute("Text");
|
||||
var text = newNode.OwnerDocument.CreateAttribute("Text");
|
||||
text.InnerText = textBoxText.Text;
|
||||
newNode.Attributes.Append(text);
|
||||
|
||||
|
@ -191,8 +191,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
if (size > 100)
|
||||
return SplitVerticalTransparentOrBlack(bmp);
|
||||
else
|
||||
parts.Add(new ImageSplitterItem(0, startY, bmp));
|
||||
parts.Add(new ImageSplitterItem(0, startY, bmp));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -281,6 +280,8 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
if (size > 2)
|
||||
{
|
||||
NikseBitmap part = bmp.CopyRectangle(new Rectangle(0, startY, bmp.Width, size + 1));
|
||||
|
||||
// int leftStart = part.CropTransparentSidesAndBottom(1000, false);
|
||||
// part.Save("c:\\line_0_to_width.bmp");
|
||||
parts.Add(new ImageSplitterItem(0, startY, part));
|
||||
// bmp.Save("c:\\original.bmp");
|
||||
@ -300,8 +301,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
if (size > 100)
|
||||
return SplitVerticalTransparentOrBlack(bmp);
|
||||
else
|
||||
parts.Add(new ImageSplitterItem(0, startY, bmp));
|
||||
parts.Add(new ImageSplitterItem(0, startY, bmp));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -584,8 +584,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
if (rightToLeft)
|
||||
line.Reverse();
|
||||
foreach (ImageSplitterItem item in line)
|
||||
list.Add(item);
|
||||
list.AddRange(line);
|
||||
lineCount++;
|
||||
}
|
||||
|
||||
@ -603,24 +602,22 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
verticalBitmaps.Reverse();
|
||||
|
||||
// split into letters
|
||||
int lineCount = 0;
|
||||
foreach (ImageSplitterItem b in verticalBitmaps)
|
||||
for (int index = 0; index < verticalBitmaps.Count; index++)
|
||||
{
|
||||
if (lineCount > 0)
|
||||
var b = verticalBitmaps[index];
|
||||
if (index > 0)
|
||||
list.Add(new ImageSplitterItem(Environment.NewLine));
|
||||
var line = new List<ImageSplitterItem>();
|
||||
foreach (ImageSplitterItem item in SplitHorizontalNew(b, xOrMorePixelsMakesSpace))
|
||||
foreach (var item in SplitHorizontalNew(b, xOrMorePixelsMakesSpace))
|
||||
{
|
||||
item.Top = index > 0 ? item.Y - b.Y : item.Y;
|
||||
item.ParentY = item.Y;
|
||||
line.Add(item);
|
||||
}
|
||||
if (rightToLeft)
|
||||
line.Reverse();
|
||||
foreach (ImageSplitterItem item in line)
|
||||
list.Add(item);
|
||||
lineCount++;
|
||||
list.AddRange(line);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
@ -659,26 +656,27 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
{
|
||||
var bmp0 = new NikseBitmap(bmp);
|
||||
// remove pixels after current;
|
||||
int k = 0;
|
||||
foreach (Point p in points)
|
||||
for (int index = 0; index < points.Count; index++)
|
||||
{
|
||||
bmp0.MakeVerticalLinePartTransparent(p.X, p.X + k, p.Y);
|
||||
k++;
|
||||
var p = points[index];
|
||||
bmp0.MakeVerticalLinePartTransparent(p.X, p.X + index, p.Y);
|
||||
}
|
||||
width = FindMaxX(points, x) - startX;
|
||||
width++;
|
||||
NikseBitmap b1 = bmp0.CopyRectangle(new Rectangle(startX, 0, width, bmp.Height));
|
||||
|
||||
if (spacePixels >= xOrMorePixelsMakesSpace && parts.Count > 0)
|
||||
parts.Add(new ImageSplitterItem(" "));
|
||||
width--;
|
||||
startX++;
|
||||
var b1 = bmp0.CopyRectangle(new Rectangle(startX, 0, width, bmp.Height));
|
||||
|
||||
int addY;
|
||||
b1 = CropTopAndBottom(b1, out addY);
|
||||
|
||||
if (spacePixels >= xOrMorePixelsMakesSpace && parts.Count > 0)
|
||||
parts.Add(new ImageSplitterItem(" ") { Y = addY + lineSplitterItem.Y });
|
||||
|
||||
parts.Add(new ImageSplitterItem(startX + lineSplitterItem.X, addY + lineSplitterItem.Y, b1)); //y is what?
|
||||
|
||||
// remove pixels before next letter;
|
||||
const int begin = 0;
|
||||
foreach (Point p in points)
|
||||
foreach (var p in points)
|
||||
{
|
||||
bmp.MakeVerticalLinePartTransparent(begin, p.X, p.Y);
|
||||
}
|
||||
@ -698,17 +696,20 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
|
||||
private static int FindMinX(List<Point> points, int x)
|
||||
{
|
||||
foreach (Point p in points)
|
||||
for (int index = 0; index < points.Count; index++)
|
||||
{
|
||||
var p = points[index];
|
||||
if (p.X < x)
|
||||
x = p.X;
|
||||
}
|
||||
return x;
|
||||
}
|
||||
|
||||
private static int FindMaxX(List<Point> points, int x)
|
||||
{
|
||||
foreach (Point p in points)
|
||||
for (int index = 0; index < points.Count; index++)
|
||||
{
|
||||
var p = points[index];
|
||||
if (p.X > x)
|
||||
x = p.X;
|
||||
}
|
||||
@ -828,8 +829,7 @@ namespace Nikse.SubtitleEdit.Logic
|
||||
}
|
||||
if (rightToLeft)
|
||||
line.Reverse();
|
||||
foreach (ImageSplitterItem item in line)
|
||||
list.Add(item);
|
||||
list.AddRange(line);
|
||||
lineCount++;
|
||||
}
|
||||
|
||||
|
@ -293,5 +293,383 @@ namespace Nikse.SubtitleEdit.Logic.Ocr.Binary
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public bool IsPeriod()
|
||||
{
|
||||
if (ExpandCount > 0 || Y < 20)
|
||||
return false;
|
||||
|
||||
if (Width == 4 && Height == 5 && NumberOfColoredPixels == 20)
|
||||
return true;
|
||||
|
||||
if (Width == 5 && Height == 6 && NumberOfColoredPixels >= 28)
|
||||
return true;
|
||||
|
||||
if (Width == 6 && Height == 7 && NumberOfColoredPixels >= 40)
|
||||
return true;
|
||||
|
||||
if (Width < Height || Width < 5 || Width > 10 || Height < 3 || Height > 9)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsComma()
|
||||
{
|
||||
if (ExpandCount > 0 || Y < 20 || Height < Width || Width < 4 || Width > 12 || Height < 8 || Height > 15)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsApostrophe()
|
||||
{
|
||||
if (ExpandCount > 0 || Y > 10 || Height < Width - 2 || Width < 4 || Width > 12 || Height < 8 || Height > 16)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsLowercaseI()
|
||||
{
|
||||
if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 3 || Width > 17 || Height < 21 || Height > 50)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var transparentHorLines = new bool[Height];
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
transparentHorLines[y] = true;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentHorLines[y] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (transparentHorLines[0] || transparentHorLines[1])
|
||||
return false;
|
||||
for (int i = 0; i < Height / 2; i++)
|
||||
{
|
||||
if (transparentHorLines[Height - i - 1])
|
||||
return false;
|
||||
}
|
||||
var top = Height / 7;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (transparentHorLines[top + i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsColon()
|
||||
{
|
||||
if (ExpandCount > 0 || Y < 5 || Y > 45 || Width > Height / 2 || Width < 3 || Width > 18 || Height < 14 || Height > 45)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NumberOfColoredPixels* 2 > Width * Height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var transparentHorLines = new bool[Height];
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
transparentHorLines[y] = true;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentHorLines[y] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (transparentHorLines[0] || transparentHorLines[1] || transparentHorLines[2])
|
||||
return false;
|
||||
if (transparentHorLines[Height-1] || transparentHorLines[Height - 2] || transparentHorLines[Height - 3])
|
||||
return false;
|
||||
|
||||
int startY = Height / 4;
|
||||
int endY = startY * 3;
|
||||
startY++;
|
||||
endY--;
|
||||
for (int y = startY; y < endY; y++)
|
||||
{
|
||||
if (!transparentHorLines[y])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsDash()
|
||||
{
|
||||
if (ExpandCount > 0 || Y < 13 || Height * 2.3 > Width || Width < 10 || Width > 25 || Height < 3 || Height > 7)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NumberOfColoredPixels + 7 < Width * Height)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var transparentHorLines = new bool[Height];
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
transparentHorLines[y] = true;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentHorLines[y] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < transparentHorLines.Length; i++)
|
||||
{
|
||||
if (transparentHorLines[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
var transparentVerLines = new bool[Width];
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
transparentVerLines[x] = true;
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentVerLines[x] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < transparentVerLines.Length; i++)
|
||||
{
|
||||
if (transparentVerLines[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsExclamationMark()
|
||||
{
|
||||
if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 3 || Width > 17 || Height < 21 || Height > 50)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var transparentHorLines = new bool[Height];
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
transparentHorLines[y] = true;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentHorLines[y] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (transparentHorLines[Height -1 ] || transparentHorLines[Height - 2])
|
||||
return false;
|
||||
for (int i = 0; i < Height / 2; i++)
|
||||
{
|
||||
if (transparentHorLines[i])
|
||||
return false;
|
||||
}
|
||||
var bottom = Height - Height / 7;
|
||||
for (int i = 0; i < 6; i++)
|
||||
{
|
||||
if (transparentHorLines[bottom - i])
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool IsLowercaseL()
|
||||
{
|
||||
if (ExpandCount > 0 || Y > 20 || Height < Width + 10 || Width < 4 || Width > 17 || Height < 21 || Height > 50)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
var transparentHorLines = new bool[Height];
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
transparentHorLines[y] = true;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentHorLines[y] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < transparentHorLines.Length; i++)
|
||||
{
|
||||
if (transparentHorLines[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
public bool IsC()
|
||||
{
|
||||
if (ExpandCount > 0 || Y > 20 || Height < Width + 1 || Width < 12 || Width > 49 || Height < 15 || Height > 55)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetPixel(1, 1) != 0)
|
||||
return false;
|
||||
if (GetPixel(1, Height - 1) != 0)
|
||||
return false;
|
||||
if (GetPixel(Width - 1, 0) != 0)
|
||||
return false;
|
||||
if (GetPixel(Width - 2, Height - 2) != 0)
|
||||
return false;
|
||||
|
||||
var transparentHorLines = new bool[Height];
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
transparentHorLines[y] = true;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentHorLines[y] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < transparentHorLines.Length; i++)
|
||||
{
|
||||
if (transparentHorLines[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
var transparentVerLines = new bool[Width];
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
transparentVerLines[x] = true;
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentVerLines[x] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < transparentVerLines.Length; i++)
|
||||
{
|
||||
if (transparentVerLines[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
int halfWidth = Width/2 - 1;
|
||||
int halfHeight = Height / 2;
|
||||
int halfHeightM1 = halfHeight--;
|
||||
for (int x = halfWidth; x < Width; x++)
|
||||
{
|
||||
if (GetPixel(x, halfHeight) != 0 || GetPixel(x, halfHeightM1) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
public bool IsO()
|
||||
{
|
||||
if (ExpandCount > 0 || Y > 20 || Math.Abs(Height - Width) > (int)Math.Round(Height / 6.0) || Width < 12 || Width > 49 || Height < 15 || Height > 55)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (GetPixel(1, 1) != 0)
|
||||
return false;
|
||||
if (GetPixel(1, Height - 1) != 0)
|
||||
return false;
|
||||
if (GetPixel(Width - 1, 0) != 0)
|
||||
return false;
|
||||
if (GetPixel(Width - 2, Height - 2) != 0)
|
||||
return false;
|
||||
|
||||
var transparentHorLines = new bool[Height];
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
transparentHorLines[y] = true;
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentHorLines[y] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < transparentHorLines.Length; i++)
|
||||
{
|
||||
if (transparentHorLines[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
var transparentVerLines = new bool[Width];
|
||||
for (int x = 0; x < Width; x++)
|
||||
{
|
||||
transparentVerLines[x] = true;
|
||||
for (int y = 0; y < Height; y++)
|
||||
{
|
||||
if (GetPixel(x, y) != 0)
|
||||
{
|
||||
transparentVerLines[x] = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < transparentVerLines.Length; i++)
|
||||
{
|
||||
if (transparentVerLines[i])
|
||||
return false;
|
||||
}
|
||||
|
||||
int halfWidth = Width / 2 - 1;
|
||||
int halfHeight = Height / 2;
|
||||
int runLength = Width/6;
|
||||
for (int x = halfWidth - runLength; x < halfWidth + runLength; x++)
|
||||
{
|
||||
if (GetPixel(x, halfHeight - 1) != 0 ||
|
||||
GetPixel(x, halfHeight + 0) != 0 ||
|
||||
GetPixel(x, halfHeight + 1) != 0)
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1565,7 +1565,7 @@ namespace Test.Logic.Forms
|
||||
target.Settings.ColonSeparateLine = false;
|
||||
target.Settings.RemoveTextBeforeColonOnlyUppercase = false;
|
||||
string text = "- I have a theory, captain--" + Environment.NewLine + "UHURA: Captain Kirk.";
|
||||
string expected = "- I have a theory, captain--" + Environment.NewLine + "- Captain Kirk."; ;
|
||||
string expected = "- I have a theory, captain--" + Environment.NewLine + "- Captain Kirk.";
|
||||
string actual = target.RemoveColon(text);
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
@ -1574,7 +1574,7 @@ namespace Test.Logic.Forms
|
||||
public void RemoveInterjectionDotDotDot()
|
||||
{
|
||||
RemoveTextForHI target = GetRemoveTextForHiLib();
|
||||
string expected = "...alright."; ;
|
||||
string expected = "...alright.";
|
||||
string actual = target.RemoveInterjections("Oh... alright.");
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
@ -1583,7 +1583,7 @@ namespace Test.Logic.Forms
|
||||
public void RemoveInterjectionDotDotDotItalic()
|
||||
{
|
||||
RemoveTextForHI target = GetRemoveTextForHiLib();
|
||||
string expected = "<i>...alright.</i>"; ;
|
||||
string expected = "<i>...alright.</i>";
|
||||
string actual = target.RemoveInterjections("<i>Oh... alright.</i>");
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
@ -1592,7 +1592,7 @@ namespace Test.Logic.Forms
|
||||
public void RemoveInterjectionDotDotDotSecondLineDialog()
|
||||
{
|
||||
RemoveTextForHI target = GetRemoveTextForHiLib();
|
||||
string expected = "- OK." + Environment.NewLine + "- ...alright."; ;
|
||||
string expected = "- OK." + Environment.NewLine + "- ...alright.";
|
||||
string actual = target.RemoveInterjections("- OK." + Environment.NewLine + "- Oh... alright.");
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
@ -1603,7 +1603,7 @@ namespace Test.Logic.Forms
|
||||
RemoveTextForHI target = GetRemoveTextForHiLib();
|
||||
target.Settings.RemoveTextBetweenParentheses = true;
|
||||
target.Settings.RemoveInterjections = true;
|
||||
string expected = "- How many, sir?" + Environment.NewLine + "- 275."; ;
|
||||
string expected = "- How many, sir?" + Environment.NewLine + "- 275.";
|
||||
string actual = target.RemoveTextFromHearImpaired("- How many, sir?" + Environment.NewLine + "- Uh — (clears throat) 275.");
|
||||
Assert.AreEqual(expected, actual);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user