Testing some line ocr

git-svn-id: https://subtitleedit.googlecode.com/svn/trunk@1813 99eadd0c-20b8-1223-b5c4-2a2b2df33de2
This commit is contained in:
niksedk 2013-04-27 13:21:48 +00:00
parent 27773f1cfc
commit bcb957b7c2
9 changed files with 1086 additions and 351 deletions

View File

@ -0,0 +1,272 @@
namespace Nikse.SubtitleEdit.Forms
{
partial class VobSubNOcrCharacterInspect
{
/// <summary>
/// Required designer variable.
/// </summary>
private System.ComponentModel.IContainer components = null;
/// <summary>
/// Clean up any resources being used.
/// </summary>
/// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Windows Form Designer generated code
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.buttonOK = new System.Windows.Forms.Button();
this.buttonCancel = new System.Windows.Forms.Button();
this.groupBoxInspectItems = new System.Windows.Forms.GroupBox();
this.pictureBoxInspectItem = new System.Windows.Forms.PictureBox();
this.listBoxInspectItems = new System.Windows.Forms.ListBox();
this.groupBoxCurrentCompareImage = new System.Windows.Forms.GroupBox();
this.buttonZoomOut = new System.Windows.Forms.Button();
this.buttonZoomIn = new System.Windows.Forms.Button();
this.labelCharacters = new System.Windows.Forms.Label();
this.pictureBoxCharacter = new System.Windows.Forms.PictureBox();
this.buttonAddBetterMatch = new System.Windows.Forms.Button();
this.checkBoxItalic = new System.Windows.Forms.CheckBox();
this.labelTextAssociatedWithImage = new System.Windows.Forms.Label();
this.buttonDelete = new System.Windows.Forms.Button();
this.buttonUpdate = new System.Windows.Forms.Button();
this.textBoxText = new System.Windows.Forms.TextBox();
this.groupBoxInspectItems.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxInspectItem)).BeginInit();
this.groupBoxCurrentCompareImage.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCharacter)).BeginInit();
this.SuspendLayout();
//
// buttonOK
//
this.buttonOK.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
this.buttonOK.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonOK.Location = new System.Drawing.Point(658, 413);
this.buttonOK.Name = "buttonOK";
this.buttonOK.Size = new System.Drawing.Size(75, 21);
this.buttonOK.TabIndex = 8;
this.buttonOK.Text = "&OK";
this.buttonOK.UseVisualStyleBackColor = true;
//
// buttonCancel
//
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(739, 413);
this.buttonCancel.Name = "buttonCancel";
this.buttonCancel.Size = new System.Drawing.Size(75, 21);
this.buttonCancel.TabIndex = 9;
this.buttonCancel.Text = "C&ancel";
this.buttonCancel.UseVisualStyleBackColor = true;
//
// groupBoxInspectItems
//
this.groupBoxInspectItems.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.groupBoxInspectItems.Controls.Add(this.pictureBoxInspectItem);
this.groupBoxInspectItems.Controls.Add(this.listBoxInspectItems);
this.groupBoxInspectItems.Location = new System.Drawing.Point(12, 12);
this.groupBoxInspectItems.Name = "groupBoxInspectItems";
this.groupBoxInspectItems.Size = new System.Drawing.Size(425, 395);
this.groupBoxInspectItems.TabIndex = 15;
this.groupBoxInspectItems.TabStop = false;
this.groupBoxInspectItems.Text = "Inspect items";
//
// pictureBoxInspectItem
//
this.pictureBoxInspectItem.BackColor = System.Drawing.Color.Red;
this.pictureBoxInspectItem.Location = new System.Drawing.Point(252, 114);
this.pictureBoxInspectItem.Name = "pictureBoxInspectItem";
this.pictureBoxInspectItem.Size = new System.Drawing.Size(52, 52);
this.pictureBoxInspectItem.TabIndex = 23;
this.pictureBoxInspectItem.TabStop = false;
//
// listBoxInspectItems
//
this.listBoxInspectItems.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Bottom)
| System.Windows.Forms.AnchorStyles.Left)));
this.listBoxInspectItems.FormattingEnabled = true;
this.listBoxInspectItems.Location = new System.Drawing.Point(6, 19);
this.listBoxInspectItems.Name = "listBoxInspectItems";
this.listBoxInspectItems.Size = new System.Drawing.Size(240, 368);
this.listBoxInspectItems.TabIndex = 12;
this.listBoxInspectItems.SelectedIndexChanged += new System.EventHandler(this.listBoxInspectItems_SelectedIndexChanged);
//
// groupBoxCurrentCompareImage
//
this.groupBoxCurrentCompareImage.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.groupBoxCurrentCompareImage.Controls.Add(this.buttonZoomOut);
this.groupBoxCurrentCompareImage.Controls.Add(this.buttonZoomIn);
this.groupBoxCurrentCompareImage.Controls.Add(this.labelCharacters);
this.groupBoxCurrentCompareImage.Controls.Add(this.pictureBoxCharacter);
this.groupBoxCurrentCompareImage.Controls.Add(this.buttonAddBetterMatch);
this.groupBoxCurrentCompareImage.Controls.Add(this.checkBoxItalic);
this.groupBoxCurrentCompareImage.Controls.Add(this.labelTextAssociatedWithImage);
this.groupBoxCurrentCompareImage.Controls.Add(this.buttonDelete);
this.groupBoxCurrentCompareImage.Controls.Add(this.buttonUpdate);
this.groupBoxCurrentCompareImage.Controls.Add(this.textBoxText);
this.groupBoxCurrentCompareImage.Location = new System.Drawing.Point(443, 12);
this.groupBoxCurrentCompareImage.Name = "groupBoxCurrentCompareImage";
this.groupBoxCurrentCompareImage.Size = new System.Drawing.Size(371, 395);
this.groupBoxCurrentCompareImage.TabIndex = 14;
this.groupBoxCurrentCompareImage.TabStop = false;
this.groupBoxCurrentCompareImage.Text = "Current compare image";
//
// buttonZoomOut
//
this.buttonZoomOut.Location = new System.Drawing.Point(89, 149);
this.buttonZoomOut.Name = "buttonZoomOut";
this.buttonZoomOut.Size = new System.Drawing.Size(25, 23);
this.buttonZoomOut.TabIndex = 36;
this.buttonZoomOut.Text = "-";
this.buttonZoomOut.UseVisualStyleBackColor = true;
this.buttonZoomOut.Click += new System.EventHandler(this.buttonZoomOut_Click);
//
// buttonZoomIn
//
this.buttonZoomIn.Location = new System.Drawing.Point(120, 149);
this.buttonZoomIn.Name = "buttonZoomIn";
this.buttonZoomIn.Size = new System.Drawing.Size(25, 23);
this.buttonZoomIn.TabIndex = 35;
this.buttonZoomIn.Text = "+";
this.buttonZoomIn.UseVisualStyleBackColor = true;
this.buttonZoomIn.Click += new System.EventHandler(this.buttonZoomIn_Click);
//
// labelCharacters
//
this.labelCharacters.AutoSize = true;
this.labelCharacters.Location = new System.Drawing.Point(19, 160);
this.labelCharacters.Name = "labelCharacters";
this.labelCharacters.Size = new System.Drawing.Size(64, 13);
this.labelCharacters.TabIndex = 34;
this.labelCharacters.Text = "Character(s)";
//
// pictureBoxCharacter
//
this.pictureBoxCharacter.Location = new System.Drawing.Point(17, 181);
this.pictureBoxCharacter.Name = "pictureBoxCharacter";
this.pictureBoxCharacter.Size = new System.Drawing.Size(99, 47);
this.pictureBoxCharacter.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize;
this.pictureBoxCharacter.TabIndex = 33;
this.pictureBoxCharacter.TabStop = false;
this.pictureBoxCharacter.Paint += new System.Windows.Forms.PaintEventHandler(this.pictureBoxCharacter_Paint);
//
// buttonAddBetterMatch
//
this.buttonAddBetterMatch.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonAddBetterMatch.Location = new System.Drawing.Point(120, 98);
this.buttonAddBetterMatch.Name = "buttonAddBetterMatch";
this.buttonAddBetterMatch.Size = new System.Drawing.Size(140, 21);
this.buttonAddBetterMatch.TabIndex = 28;
this.buttonAddBetterMatch.Text = "Add better match";
this.buttonAddBetterMatch.UseVisualStyleBackColor = true;
this.buttonAddBetterMatch.Click += new System.EventHandler(this.buttonAddBetterMatch_Click);
//
// checkBoxItalic
//
this.checkBoxItalic.AutoSize = true;
this.checkBoxItalic.Location = new System.Drawing.Point(15, 61);
this.checkBoxItalic.Name = "checkBoxItalic";
this.checkBoxItalic.Size = new System.Drawing.Size(58, 17);
this.checkBoxItalic.TabIndex = 2;
this.checkBoxItalic.Text = "Is &italic";
this.checkBoxItalic.UseVisualStyleBackColor = true;
//
// labelTextAssociatedWithImage
//
this.labelTextAssociatedWithImage.AutoSize = true;
this.labelTextAssociatedWithImage.Location = new System.Drawing.Point(14, 19);
this.labelTextAssociatedWithImage.Name = "labelTextAssociatedWithImage";
this.labelTextAssociatedWithImage.Size = new System.Drawing.Size(135, 13);
this.labelTextAssociatedWithImage.TabIndex = 0;
this.labelTextAssociatedWithImage.Text = "Text associated with image";
//
// buttonDelete
//
this.buttonDelete.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonDelete.Location = new System.Drawing.Point(120, 62);
this.buttonDelete.Name = "buttonDelete";
this.buttonDelete.Size = new System.Drawing.Size(140, 21);
this.buttonDelete.TabIndex = 4;
this.buttonDelete.Text = "Delete ";
this.buttonDelete.UseVisualStyleBackColor = true;
this.buttonDelete.Click += new System.EventHandler(this.buttonDelete_Click);
//
// buttonUpdate
//
this.buttonUpdate.ImeMode = System.Windows.Forms.ImeMode.NoControl;
this.buttonUpdate.Location = new System.Drawing.Point(120, 35);
this.buttonUpdate.Name = "buttonUpdate";
this.buttonUpdate.Size = new System.Drawing.Size(140, 21);
this.buttonUpdate.TabIndex = 3;
this.buttonUpdate.Text = "Update";
this.buttonUpdate.UseVisualStyleBackColor = true;
this.buttonUpdate.Click += new System.EventHandler(this.buttonUpdate_Click);
//
// textBoxText
//
this.textBoxText.Location = new System.Drawing.Point(14, 35);
this.textBoxText.Name = "textBoxText";
this.textBoxText.Size = new System.Drawing.Size(100, 20);
this.textBoxText.TabIndex = 1;
//
// VobSubNOcrCharacterInspect
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(826, 446);
this.Controls.Add(this.groupBoxInspectItems);
this.Controls.Add(this.groupBoxCurrentCompareImage);
this.Controls.Add(this.buttonOK);
this.Controls.Add(this.buttonCancel);
this.KeyPreview = true;
this.Name = "VobSubNOcrCharacterInspect";
this.ShowIcon = false;
this.ShowInTaskbar = false;
this.Text = "VobSubNOcrCharacterInspect";
this.KeyDown += new System.Windows.Forms.KeyEventHandler(this.VobSubNOcrCharacterInspect_KeyDown);
this.groupBoxInspectItems.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.pictureBoxInspectItem)).EndInit();
this.groupBoxCurrentCompareImage.ResumeLayout(false);
this.groupBoxCurrentCompareImage.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.pictureBoxCharacter)).EndInit();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.Button buttonOK;
private System.Windows.Forms.Button buttonCancel;
private System.Windows.Forms.GroupBox groupBoxInspectItems;
private System.Windows.Forms.PictureBox pictureBoxInspectItem;
private System.Windows.Forms.ListBox listBoxInspectItems;
private System.Windows.Forms.GroupBox groupBoxCurrentCompareImage;
private System.Windows.Forms.Button buttonAddBetterMatch;
private System.Windows.Forms.CheckBox checkBoxItalic;
private System.Windows.Forms.Label labelTextAssociatedWithImage;
private System.Windows.Forms.Button buttonDelete;
private System.Windows.Forms.Button buttonUpdate;
private System.Windows.Forms.TextBox textBoxText;
private System.Windows.Forms.Button buttonZoomOut;
private System.Windows.Forms.Button buttonZoomIn;
private System.Windows.Forms.Label labelCharacters;
private System.Windows.Forms.PictureBox pictureBoxCharacter;
}
}

View File

@ -0,0 +1,209 @@
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.OCR;
using System.IO;
namespace Nikse.SubtitleEdit.Forms
{
public partial class VobSubNOcrCharacterInspect : Form
{
private List<ImageSplitterItem> _imageList;
private List<VobSubOcr.CompareMatch> _matchList;
private List<NOcrChar> _nocrChars;
private NOcrChar _nocrChar = null;
private VobSubOcr _vobSubOcr;
private Bitmap _bitmap;
private double _zoomFactor = 3.0;
public VobSubNOcrCharacterInspect()
{
InitializeComponent();
}
private void VobSubNOcrCharacterInspect_KeyDown(object sender, KeyEventArgs e)
{
if (e.KeyCode == Keys.Escape)
DialogResult = DialogResult.Cancel;
}
internal void Initialize(Bitmap bitmap, int pixelsIsSpace, bool rightToLeft, List<NOcrChar> nocrChars, VobSubOcr vobSubOcr)
{
_bitmap = bitmap;
NikseBitmap nbmp = new NikseBitmap(bitmap);
nbmp.ReplaceNonWhiteWithTransparent();
bitmap = nbmp.GetBitmap();
_nocrChars = nocrChars;
_matchList = new List<VobSubOcr.CompareMatch>();
_vobSubOcr = vobSubOcr;
_imageList = ImageSplitter.SplitBitmapToLetters(bitmap, pixelsIsSpace, rightToLeft, Configuration.Settings.VobSubOcr.TopToBottom);
int index = 0;
while (index < _imageList.Count)
{
ImageSplitterItem item = _imageList[index];
if (item.Bitmap == null)
{
listBoxInspectItems.Items.Add(item.SpecialCharacter);
_matchList.Add(null);
}
else
{
nbmp = new NikseBitmap(item.Bitmap);
nbmp.ReplaceNonWhiteWithTransparent();
item.Y += nbmp.CropTopTransparent(0);
nbmp.CropTransparentSidesAndBottom(0, true);
nbmp.ReplaceTransparentWith(Color.Black);
item.Bitmap = nbmp.GetBitmap();
//get nocr matches
Nikse.SubtitleEdit.Forms.VobSubOcr.CompareMatch bestGuess;
Nikse.SubtitleEdit.Forms.VobSubOcr.CompareMatch match = vobSubOcr.GetNOcrCompareMatch(item, bitmap, out bestGuess);
if (match == null)
{
listBoxInspectItems.Items.Add("?");
_matchList.Add(null);
}
else
{
listBoxInspectItems.Items.Add(match.Text);
_matchList.Add(match);
}
}
index++;
}
}
private void listBoxInspectItems_SelectedIndexChanged(object sender, EventArgs e)
{
if (listBoxInspectItems.SelectedIndex < 0)
return;
var img = _imageList[listBoxInspectItems.SelectedIndex];
if (img.Bitmap != null)
{
pictureBoxInspectItem.Width = img.Bitmap.Width;
pictureBoxInspectItem.Height = img.Bitmap.Height;
pictureBoxInspectItem.Image = img.Bitmap;
pictureBoxCharacter.Image = img.Bitmap;
SizePictureBox();
}
else
{
pictureBoxInspectItem.Image = null;
pictureBoxCharacter.Image = null;
}
var match = _matchList[listBoxInspectItems.SelectedIndex];
if (match == null)
{
_nocrChar = null;
pictureBoxCharacter.Invalidate();
}
else
{
textBoxText.Text = match.Text;
checkBoxItalic.Checked = match.Italic;
_nocrChar = match.NOcrCharacter;
pictureBoxCharacter.Invalidate();
}
}
private void pictureBoxCharacter_Paint(object sender, PaintEventArgs e)
{
if (_nocrChar == null)
return;
var foreground = new Pen(new SolidBrush(Color.Green));
var background = new Pen(new SolidBrush(Color.Red));
if (pictureBoxCharacter.Image != null)
{
foreach (NOcrPoint op in _nocrChar.LinesForeground)
{
e.Graphics.DrawLine(foreground, op.GetScaledStart(_nocrChar, pictureBoxCharacter.Width, pictureBoxCharacter.Height), op.GetScaledEnd(_nocrChar, pictureBoxCharacter.Width, pictureBoxCharacter.Height));
}
foreach (NOcrPoint op in _nocrChar.LinesBackground)
{
e.Graphics.DrawLine(background, op.GetScaledStart(_nocrChar, pictureBoxCharacter.Width, pictureBoxCharacter.Height), op.GetScaledEnd(_nocrChar, pictureBoxCharacter.Width, pictureBoxCharacter.Height));
}
}
}
private void SizePictureBox()
{
if (pictureBoxCharacter.Image != null)
{
Bitmap bmp = pictureBoxCharacter.Image as Bitmap;
pictureBoxCharacter.SizeMode = PictureBoxSizeMode.StretchImage;
pictureBoxCharacter.Width = (int)Math.Round(bmp.Width * _zoomFactor);
pictureBoxCharacter.Height = (int)Math.Round(bmp.Height * _zoomFactor);
pictureBoxCharacter.Invalidate();
}
}
private void buttonZoomIn_Click(object sender, EventArgs e)
{
if (_zoomFactor < 10)
{
_zoomFactor++;
SizePictureBox();
}
}
private void buttonZoomOut_Click(object sender, EventArgs e)
{
if (_zoomFactor > 1)
{
_zoomFactor--;
SizePictureBox();
}
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (_nocrChar != null)
{
_nocrChar.Text = textBoxText.Text;
_nocrChar.Italic = checkBoxItalic.Checked;
_vobSubOcr.SaveNOcr(Path.Combine(Configuration.DictionariesFolder, "nOCR_eng.xml"));
MessageBox.Show("nOCR saved!");
}
}
private void buttonDelete_Click(object sender, EventArgs e)
{
if (_nocrChar != null)
{
_nocrChars.Remove(_nocrChar);
_vobSubOcr.SaveNOcr(Path.Combine(Configuration.DictionariesFolder, "nOCR_eng.xml"));
MessageBox.Show("nOCR saved!");
}
}
private void buttonAddBetterMatch_Click(object sender, EventArgs e)
{
if (listBoxInspectItems.SelectedIndex < 0)
return;
var img = _imageList[listBoxInspectItems.SelectedIndex];
if (img.Bitmap == null)
return;
var match = _matchList[listBoxInspectItems.SelectedIndex];
var vobSubOcrNOcrCharacter = new VobSubOcrNOcrCharacter();
vobSubOcrNOcrCharacter.Initialize(_bitmap, img, new Point(0,0), false, false, null, null, _vobSubOcr);
DialogResult result = vobSubOcrNOcrCharacter.ShowDialog(this);
if (result == DialogResult.OK)
{
_nocrChars.Add(vobSubOcrNOcrCharacter.NOcrChar);
_vobSubOcr.SaveNOcr(Path.Combine(Configuration.DictionariesFolder, "nOCR_eng.xml"));
DialogResult = DialogResult.OK;
}
}
}
}

View File

@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
</root>

View File

@ -44,6 +44,7 @@ namespace Nikse.SubtitleEdit.Forms
this.bluraySupToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.vobSubToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparatorImageCompare = new System.Windows.Forms.ToolStripSeparator();
this.toolStripMenuItemInspectNOcrMatches = new System.Windows.Forms.ToolStripMenuItem();
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.EditLastAdditionsToolStripMenuItem = new System.Windows.Forms.ToolStripMenuItem();
this.toolStripSeparator4 = new System.Windows.Forms.ToolStripSeparator();
@ -57,16 +58,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.GroupBoxTesseractMethod = new System.Windows.Forms.GroupBox();
this.buttonGetTesseractDictionaries = new System.Windows.Forms.Button();
this.checkBoxTesseractMusicOn = new System.Windows.Forms.CheckBox();
this.checkBoxTesseractItalicsOn = new System.Windows.Forms.CheckBox();
this.checkBoxUseModiInTesseractForUnknownWords = new System.Windows.Forms.CheckBox();
this.labelTesseractLanguage = new System.Windows.Forms.Label();
this.comboBoxTesseractLanguages = new System.Windows.Forms.ComboBox();
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.checkBoxNOcrItalic = new System.Windows.Forms.CheckBox();
this.checkBoxNOcrCorrect = new System.Windows.Forms.CheckBox();
@ -81,6 +72,16 @@ namespace Nikse.SubtitleEdit.Forms
this.comboBoxCharacterDatabase = new System.Windows.Forms.ComboBox();
this.labelImageDatabase = new System.Windows.Forms.Label();
this.buttonNewCharacterDatabase = new System.Windows.Forms.Button();
this.GroupBoxTesseractMethod = new System.Windows.Forms.GroupBox();
this.buttonGetTesseractDictionaries = new System.Windows.Forms.Button();
this.checkBoxTesseractMusicOn = new System.Windows.Forms.CheckBox();
this.checkBoxTesseractItalicsOn = new System.Windows.Forms.CheckBox();
this.checkBoxUseModiInTesseractForUnknownWords = new System.Windows.Forms.CheckBox();
this.labelTesseractLanguage = new System.Windows.Forms.Label();
this.comboBoxTesseractLanguages = new System.Windows.Forms.ComboBox();
this.groupBoxModiMethod = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.comboBoxModiLanguage = new System.Windows.Forms.ComboBox();
this.groupBoxOCRControls = new System.Windows.Forms.GroupBox();
this.labelStartFrom = new System.Windows.Forms.Label();
this.numericUpDownStartNumber = new System.Windows.Forms.NumericUpDown();
@ -97,6 +98,8 @@ namespace Nikse.SubtitleEdit.Forms
this.listBoxLog = new System.Windows.Forms.ListBox();
this.tabPageSuggestions = new System.Windows.Forms.TabPage();
this.listBoxLogSuggestions = new System.Windows.Forms.ListBox();
this.contextMenuStripGuessesUsed = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemClearGuesses = new System.Windows.Forms.ToolStripMenuItem();
this.tabPageUnknownWords = new System.Windows.Forms.TabPage();
this.buttonGoogleIt = new System.Windows.Forms.Button();
this.buttonAddToOcrReplaceList = new System.Windows.Forms.Button();
@ -131,16 +134,14 @@ namespace Nikse.SubtitleEdit.Forms
this.splitContainerBottom = new System.Windows.Forms.SplitContainer();
this.textBoxCurrentText = new Nikse.SubtitleEdit.Controls.SETextBox();
this.subtitleListView1 = new Nikse.SubtitleEdit.Controls.SubtitleListView();
this.contextMenuStripGuessesUsed = new System.Windows.Forms.ContextMenuStrip(this.components);
this.toolStripMenuItemClearGuesses = new System.Windows.Forms.ToolStripMenuItem();
this.contextMenuStripListview.SuspendLayout();
this.groupBoxOcrMethod.SuspendLayout();
this.GroupBoxTesseractMethod.SuspendLayout();
this.groupBoxModiMethod.SuspendLayout();
this.groupBoxNOCR.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPixelsIsSpaceNOCR)).BeginInit();
this.groupBoxImageCompareMethod.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsIsSpace)).BeginInit();
this.GroupBoxTesseractMethod.SuspendLayout();
this.groupBoxModiMethod.SuspendLayout();
this.groupBoxOCRControls.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownStartNumber)).BeginInit();
this.groupBoxOcrAutoFix.SuspendLayout();
@ -148,6 +149,7 @@ namespace Nikse.SubtitleEdit.Forms
this.contextMenuStripAllFixes.SuspendLayout();
this.tabPageAllFixes.SuspendLayout();
this.tabPageSuggestions.SuspendLayout();
this.contextMenuStripGuessesUsed.SuspendLayout();
this.tabPageUnknownWords.SuspendLayout();
this.contextMenuStripUnknownWords.SuspendLayout();
this.groupBoxImagePalette.SuspendLayout();
@ -160,7 +162,6 @@ namespace Nikse.SubtitleEdit.Forms
this.splitContainerBottom.Panel1.SuspendLayout();
this.splitContainerBottom.Panel2.SuspendLayout();
this.splitContainerBottom.SuspendLayout();
this.contextMenuStripGuessesUsed.SuspendLayout();
this.SuspendLayout();
//
// contextMenuStripListview
@ -175,6 +176,7 @@ namespace Nikse.SubtitleEdit.Forms
this.saveAllImagesWithHtmlIndexViewToolStripMenuItem,
this.toolStripMenuItemExport,
this.toolStripSeparatorImageCompare,
this.toolStripMenuItemInspectNOcrMatches,
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem,
this.EditLastAdditionsToolStripMenuItem,
this.toolStripSeparator4,
@ -182,7 +184,7 @@ namespace Nikse.SubtitleEdit.Forms
this.toolStripSeparator3,
this.deleteToolStripMenuItem});
this.contextMenuStripListview.Name = "contextMenuStripListview";
this.contextMenuStripListview.Size = new System.Drawing.Size(306, 254);
this.contextMenuStripListview.Size = new System.Drawing.Size(306, 298);
this.contextMenuStripListview.Opening += new System.ComponentModel.CancelEventHandler(this.ContextMenuStripListviewOpening);
//
// normalToolStripMenuItem
@ -266,6 +268,13 @@ namespace Nikse.SubtitleEdit.Forms
this.toolStripSeparatorImageCompare.Name = "toolStripSeparatorImageCompare";
this.toolStripSeparatorImageCompare.Size = new System.Drawing.Size(302, 6);
//
// toolStripMenuItemInspectNOcrMatches
//
this.toolStripMenuItemInspectNOcrMatches.Name = "toolStripMenuItemInspectNOcrMatches";
this.toolStripMenuItemInspectNOcrMatches.Size = new System.Drawing.Size(305, 22);
this.toolStripMenuItemInspectNOcrMatches.Text = "Inspect nocr matches for current image...";
this.toolStripMenuItemInspectNOcrMatches.Click += new System.EventHandler(this.toolStripMenuItemInspectNOcrMatches_Click);
//
// inspectImageCompareMatchesForCurrentImageToolStripMenuItem
//
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem.Name = "inspectImageCompareMatchesForCurrentImageToolStripMenuItem";
@ -359,10 +368,10 @@ namespace Nikse.SubtitleEdit.Forms
// groupBoxOcrMethod
//
this.groupBoxOcrMethod.Controls.Add(this.comboBoxOcrMethod);
this.groupBoxOcrMethod.Controls.Add(this.GroupBoxTesseractMethod);
this.groupBoxOcrMethod.Controls.Add(this.groupBoxModiMethod);
this.groupBoxOcrMethod.Controls.Add(this.groupBoxNOCR);
this.groupBoxOcrMethod.Controls.Add(this.groupBoxImageCompareMethod);
this.groupBoxOcrMethod.Controls.Add(this.GroupBoxTesseractMethod);
this.groupBoxOcrMethod.Controls.Add(this.groupBoxModiMethod);
this.groupBoxOcrMethod.Location = new System.Drawing.Point(13, 5);
this.groupBoxOcrMethod.Name = "groupBoxOcrMethod";
this.groupBoxOcrMethod.Size = new System.Drawing.Size(392, 192);
@ -385,6 +394,177 @@ namespace Nikse.SubtitleEdit.Forms
this.comboBoxOcrMethod.TabIndex = 0;
this.comboBoxOcrMethod.SelectedIndexChanged += new System.EventHandler(this.ComboBoxOcrMethodSelectedIndexChanged);
//
// groupBoxNOCR
//
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";
//
// checkBoxNOcrItalic
//
this.checkBoxNOcrItalic.AutoSize = true;
this.checkBoxNOcrItalic.Location = new System.Drawing.Point(16, 81);
this.checkBoxNOcrItalic.Name = "checkBoxNOcrItalic";
this.checkBoxNOcrItalic.Size = new System.Drawing.Size(49, 17);
this.checkBoxNOcrItalic.TabIndex = 8;
this.checkBoxNOcrItalic.Text = "Italic";
this.checkBoxNOcrItalic.UseVisualStyleBackColor = true;
//
// checkBoxNOcrCorrect
//
this.checkBoxNOcrCorrect.AutoSize = true;
this.checkBoxNOcrCorrect.Location = new System.Drawing.Point(16, 58);
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(16, 105);
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, 22);
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[] {
1,
0,
0,
0});
//
// labelNumberOfPixelsIsSpaceNOCR
//
this.labelNumberOfPixelsIsSpaceNOCR.AutoSize = true;
this.labelNumberOfPixelsIsSpaceNOCR.Location = new System.Drawing.Point(12, 25);
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.checkBoxRightToLeft);
this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownPixelsIsSpace);
this.groupBoxImageCompareMethod.Controls.Add(this.buttonEditCharacterDatabase);
this.groupBoxImageCompareMethod.Controls.Add(this.labelNoOfPixelsIsSpace);
this.groupBoxImageCompareMethod.Controls.Add(this.comboBoxCharacterDatabase);
this.groupBoxImageCompareMethod.Controls.Add(this.labelImageDatabase);
this.groupBoxImageCompareMethod.Controls.Add(this.buttonNewCharacterDatabase);
this.groupBoxImageCompareMethod.Location = new System.Drawing.Point(13, 38);
this.groupBoxImageCompareMethod.Name = "groupBoxImageCompareMethod";
this.groupBoxImageCompareMethod.Size = new System.Drawing.Size(366, 131);
this.groupBoxImageCompareMethod.TabIndex = 2;
this.groupBoxImageCompareMethod.TabStop = false;
this.groupBoxImageCompareMethod.Text = "Image compare";
//
// checkBoxRightToLeft
//
this.checkBoxRightToLeft.AutoSize = true;
this.checkBoxRightToLeft.Location = new System.Drawing.Point(173, 100);
this.checkBoxRightToLeft.Name = "checkBoxRightToLeft";
this.checkBoxRightToLeft.Size = new System.Drawing.Size(80, 17);
this.checkBoxRightToLeft.TabIndex = 6;
this.checkBoxRightToLeft.Text = "Right to left";
this.checkBoxRightToLeft.UseVisualStyleBackColor = true;
//
// numericUpDownPixelsIsSpace
//
this.numericUpDownPixelsIsSpace.Location = new System.Drawing.Point(173, 67);
this.numericUpDownPixelsIsSpace.Maximum = new decimal(new int[] {
50,
0,
0,
0});
this.numericUpDownPixelsIsSpace.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDownPixelsIsSpace.Name = "numericUpDownPixelsIsSpace";
this.numericUpDownPixelsIsSpace.Size = new System.Drawing.Size(50, 21);
this.numericUpDownPixelsIsSpace.TabIndex = 5;
this.numericUpDownPixelsIsSpace.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// buttonEditCharacterDatabase
//
this.buttonEditCharacterDatabase.Location = new System.Drawing.Point(278, 46);
this.buttonEditCharacterDatabase.Name = "buttonEditCharacterDatabase";
this.buttonEditCharacterDatabase.Size = new System.Drawing.Size(68, 21);
this.buttonEditCharacterDatabase.TabIndex = 3;
this.buttonEditCharacterDatabase.Text = "Edit";
this.buttonEditCharacterDatabase.UseVisualStyleBackColor = true;
this.buttonEditCharacterDatabase.Click += new System.EventHandler(this.ButtonEditCharacterDatabaseClick);
//
// labelNoOfPixelsIsSpace
//
this.labelNoOfPixelsIsSpace.AutoSize = true;
this.labelNoOfPixelsIsSpace.Location = new System.Drawing.Point(6, 69);
this.labelNoOfPixelsIsSpace.Name = "labelNoOfPixelsIsSpace";
this.labelNoOfPixelsIsSpace.Size = new System.Drawing.Size(104, 13);
this.labelNoOfPixelsIsSpace.TabIndex = 4;
this.labelNoOfPixelsIsSpace.Text = "No of pixels is space";
//
// comboBoxCharacterDatabase
//
this.comboBoxCharacterDatabase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCharacterDatabase.FormattingEnabled = true;
this.comboBoxCharacterDatabase.Location = new System.Drawing.Point(130, 19);
this.comboBoxCharacterDatabase.Name = "comboBoxCharacterDatabase";
this.comboBoxCharacterDatabase.Size = new System.Drawing.Size(142, 21);
this.comboBoxCharacterDatabase.TabIndex = 1;
this.comboBoxCharacterDatabase.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCharacterDatabaseSelectedIndexChanged);
//
// labelImageDatabase
//
this.labelImageDatabase.AutoSize = true;
this.labelImageDatabase.Location = new System.Drawing.Point(7, 22);
this.labelImageDatabase.Name = "labelImageDatabase";
this.labelImageDatabase.Size = new System.Drawing.Size(85, 13);
this.labelImageDatabase.TabIndex = 0;
this.labelImageDatabase.Text = "Image database";
//
// buttonNewCharacterDatabase
//
this.buttonNewCharacterDatabase.Location = new System.Drawing.Point(278, 19);
this.buttonNewCharacterDatabase.Name = "buttonNewCharacterDatabase";
this.buttonNewCharacterDatabase.Size = new System.Drawing.Size(68, 21);
this.buttonNewCharacterDatabase.TabIndex = 2;
this.buttonNewCharacterDatabase.Text = "New";
this.buttonNewCharacterDatabase.UseVisualStyleBackColor = true;
this.buttonNewCharacterDatabase.Click += new System.EventHandler(this.ButtonNewCharacterDatabaseClick);
//
// GroupBoxTesseractMethod
//
this.GroupBoxTesseractMethod.Controls.Add(this.buttonGetTesseractDictionaries);
@ -496,177 +676,6 @@ namespace Nikse.SubtitleEdit.Forms
this.comboBoxModiLanguage.TabIndex = 0;
this.comboBoxModiLanguage.SelectedIndexChanged += new System.EventHandler(this.ComboBoxModiLanguageSelectedIndexChanged);
//
// groupBoxNOCR
//
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";
//
// checkBoxNOcrItalic
//
this.checkBoxNOcrItalic.AutoSize = true;
this.checkBoxNOcrItalic.Location = new System.Drawing.Point(187, 28);
this.checkBoxNOcrItalic.Name = "checkBoxNOcrItalic";
this.checkBoxNOcrItalic.Size = new System.Drawing.Size(48, 17);
this.checkBoxNOcrItalic.TabIndex = 8;
this.checkBoxNOcrItalic.Text = "Italic";
this.checkBoxNOcrItalic.UseVisualStyleBackColor = true;
//
// checkBoxNOcrCorrect
//
this.checkBoxNOcrCorrect.AutoSize = true;
this.checkBoxNOcrCorrect.Location = new System.Drawing.Point(27, 38);
this.checkBoxNOcrCorrect.Name = "checkBoxNOcrCorrect";
this.checkBoxNOcrCorrect.Size = new System.Drawing.Size(113, 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(173, 100);
this.checkBoxRightToLeftNOCR.Name = "checkBoxRightToLeftNOCR";
this.checkBoxRightToLeftNOCR.Size = new System.Drawing.Size(80, 17);
this.checkBoxRightToLeftNOCR.TabIndex = 6;
this.checkBoxRightToLeftNOCR.Text = "Right to left";
this.checkBoxRightToLeftNOCR.UseVisualStyleBackColor = true;
//
// numericUpDownNumberOfPixelsIsSpaceNOCR
//
this.numericUpDownNumberOfPixelsIsSpaceNOCR.Location = new System.Drawing.Point(173, 67);
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[] {
1,
0,
0,
0});
//
// labelNumberOfPixelsIsSpaceNOCR
//
this.labelNumberOfPixelsIsSpaceNOCR.AutoSize = true;
this.labelNumberOfPixelsIsSpaceNOCR.Location = new System.Drawing.Point(6, 69);
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.checkBoxRightToLeft);
this.groupBoxImageCompareMethod.Controls.Add(this.numericUpDownPixelsIsSpace);
this.groupBoxImageCompareMethod.Controls.Add(this.buttonEditCharacterDatabase);
this.groupBoxImageCompareMethod.Controls.Add(this.labelNoOfPixelsIsSpace);
this.groupBoxImageCompareMethod.Controls.Add(this.comboBoxCharacterDatabase);
this.groupBoxImageCompareMethod.Controls.Add(this.labelImageDatabase);
this.groupBoxImageCompareMethod.Controls.Add(this.buttonNewCharacterDatabase);
this.groupBoxImageCompareMethod.Location = new System.Drawing.Point(13, 38);
this.groupBoxImageCompareMethod.Name = "groupBoxImageCompareMethod";
this.groupBoxImageCompareMethod.Size = new System.Drawing.Size(366, 131);
this.groupBoxImageCompareMethod.TabIndex = 2;
this.groupBoxImageCompareMethod.TabStop = false;
this.groupBoxImageCompareMethod.Text = "Image compare";
//
// checkBoxRightToLeft
//
this.checkBoxRightToLeft.AutoSize = true;
this.checkBoxRightToLeft.Location = new System.Drawing.Point(173, 100);
this.checkBoxRightToLeft.Name = "checkBoxRightToLeft";
this.checkBoxRightToLeft.Size = new System.Drawing.Size(80, 17);
this.checkBoxRightToLeft.TabIndex = 6;
this.checkBoxRightToLeft.Text = "Right to left";
this.checkBoxRightToLeft.UseVisualStyleBackColor = true;
//
// numericUpDownPixelsIsSpace
//
this.numericUpDownPixelsIsSpace.Location = new System.Drawing.Point(173, 67);
this.numericUpDownPixelsIsSpace.Maximum = new decimal(new int[] {
50,
0,
0,
0});
this.numericUpDownPixelsIsSpace.Minimum = new decimal(new int[] {
1,
0,
0,
0});
this.numericUpDownPixelsIsSpace.Name = "numericUpDownPixelsIsSpace";
this.numericUpDownPixelsIsSpace.Size = new System.Drawing.Size(50, 21);
this.numericUpDownPixelsIsSpace.TabIndex = 5;
this.numericUpDownPixelsIsSpace.Value = new decimal(new int[] {
1,
0,
0,
0});
//
// buttonEditCharacterDatabase
//
this.buttonEditCharacterDatabase.Location = new System.Drawing.Point(278, 46);
this.buttonEditCharacterDatabase.Name = "buttonEditCharacterDatabase";
this.buttonEditCharacterDatabase.Size = new System.Drawing.Size(68, 21);
this.buttonEditCharacterDatabase.TabIndex = 3;
this.buttonEditCharacterDatabase.Text = "Edit";
this.buttonEditCharacterDatabase.UseVisualStyleBackColor = true;
this.buttonEditCharacterDatabase.Click += new System.EventHandler(this.ButtonEditCharacterDatabaseClick);
//
// labelNoOfPixelsIsSpace
//
this.labelNoOfPixelsIsSpace.AutoSize = true;
this.labelNoOfPixelsIsSpace.Location = new System.Drawing.Point(6, 69);
this.labelNoOfPixelsIsSpace.Name = "labelNoOfPixelsIsSpace";
this.labelNoOfPixelsIsSpace.Size = new System.Drawing.Size(104, 13);
this.labelNoOfPixelsIsSpace.TabIndex = 4;
this.labelNoOfPixelsIsSpace.Text = "No of pixels is space";
//
// comboBoxCharacterDatabase
//
this.comboBoxCharacterDatabase.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.comboBoxCharacterDatabase.FormattingEnabled = true;
this.comboBoxCharacterDatabase.Location = new System.Drawing.Point(130, 19);
this.comboBoxCharacterDatabase.Name = "comboBoxCharacterDatabase";
this.comboBoxCharacterDatabase.Size = new System.Drawing.Size(142, 21);
this.comboBoxCharacterDatabase.TabIndex = 1;
this.comboBoxCharacterDatabase.SelectedIndexChanged += new System.EventHandler(this.ComboBoxCharacterDatabaseSelectedIndexChanged);
//
// labelImageDatabase
//
this.labelImageDatabase.AutoSize = true;
this.labelImageDatabase.Location = new System.Drawing.Point(7, 22);
this.labelImageDatabase.Name = "labelImageDatabase";
this.labelImageDatabase.Size = new System.Drawing.Size(85, 13);
this.labelImageDatabase.TabIndex = 0;
this.labelImageDatabase.Text = "Image database";
//
// buttonNewCharacterDatabase
//
this.buttonNewCharacterDatabase.Location = new System.Drawing.Point(278, 19);
this.buttonNewCharacterDatabase.Name = "buttonNewCharacterDatabase";
this.buttonNewCharacterDatabase.Size = new System.Drawing.Size(68, 21);
this.buttonNewCharacterDatabase.TabIndex = 2;
this.buttonNewCharacterDatabase.Text = "New";
this.buttonNewCharacterDatabase.UseVisualStyleBackColor = true;
this.buttonNewCharacterDatabase.Click += new System.EventHandler(this.ButtonNewCharacterDatabaseClick);
//
// groupBoxOCRControls
//
this.groupBoxOCRControls.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Right)));
@ -862,6 +871,20 @@ namespace Nikse.SubtitleEdit.Forms
this.listBoxLogSuggestions.SelectedIndexChanged += new System.EventHandler(this.ListBoxLogSelectedIndexChanged);
this.listBoxLogSuggestions.KeyDown += new System.Windows.Forms.KeyEventHandler(this.listBoxCopyToClipboard_KeyDown);
//
// contextMenuStripGuessesUsed
//
this.contextMenuStripGuessesUsed.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemClearGuesses});
this.contextMenuStripGuessesUsed.Name = "contextMenuStripUnknownWords";
this.contextMenuStripGuessesUsed.Size = new System.Drawing.Size(153, 48);
//
// toolStripMenuItemClearGuesses
//
this.toolStripMenuItemClearGuesses.Name = "toolStripMenuItemClearGuesses";
this.toolStripMenuItemClearGuesses.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItemClearGuesses.Text = "Clear";
this.toolStripMenuItemClearGuesses.Click += new System.EventHandler(this.toolStripMenuItemClearGuesses_Click);
//
// tabPageUnknownWords
//
this.tabPageUnknownWords.Controls.Add(this.buttonGoogleIt);
@ -1248,20 +1271,6 @@ namespace Nikse.SubtitleEdit.Forms
this.subtitleListView1.SelectedIndexChanged += new System.EventHandler(this.SubtitleListView1SelectedIndexChanged);
this.subtitleListView1.KeyDown += new System.Windows.Forms.KeyEventHandler(this.subtitleListView1_KeyDown);
//
// contextMenuStripGuessesUsed
//
this.contextMenuStripGuessesUsed.Items.AddRange(new System.Windows.Forms.ToolStripItem[] {
this.toolStripMenuItemClearGuesses});
this.contextMenuStripGuessesUsed.Name = "contextMenuStripUnknownWords";
this.contextMenuStripGuessesUsed.Size = new System.Drawing.Size(153, 48);
//
// toolStripMenuItemClearGuesses
//
this.toolStripMenuItemClearGuesses.Name = "toolStripMenuItemClearGuesses";
this.toolStripMenuItemClearGuesses.Size = new System.Drawing.Size(152, 22);
this.toolStripMenuItemClearGuesses.Text = "Clear";
this.toolStripMenuItemClearGuesses.Click += new System.EventHandler(this.toolStripMenuItemClearGuesses_Click);
//
// VobSubOcr
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
@ -1289,16 +1298,16 @@ namespace Nikse.SubtitleEdit.Forms
this.Resize += new System.EventHandler(this.VobSubOcr_Resize);
this.contextMenuStripListview.ResumeLayout(false);
this.groupBoxOcrMethod.ResumeLayout(false);
this.GroupBoxTesseractMethod.ResumeLayout(false);
this.GroupBoxTesseractMethod.PerformLayout();
this.groupBoxModiMethod.ResumeLayout(false);
this.groupBoxModiMethod.PerformLayout();
this.groupBoxNOCR.ResumeLayout(false);
this.groupBoxNOCR.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownNumberOfPixelsIsSpaceNOCR)).EndInit();
this.groupBoxImageCompareMethod.ResumeLayout(false);
this.groupBoxImageCompareMethod.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownPixelsIsSpace)).EndInit();
this.GroupBoxTesseractMethod.ResumeLayout(false);
this.GroupBoxTesseractMethod.PerformLayout();
this.groupBoxModiMethod.ResumeLayout(false);
this.groupBoxModiMethod.PerformLayout();
this.groupBoxOCRControls.ResumeLayout(false);
this.groupBoxOCRControls.PerformLayout();
((System.ComponentModel.ISupportInitialize)(this.numericUpDownStartNumber)).EndInit();
@ -1308,6 +1317,7 @@ namespace Nikse.SubtitleEdit.Forms
this.contextMenuStripAllFixes.ResumeLayout(false);
this.tabPageAllFixes.ResumeLayout(false);
this.tabPageSuggestions.ResumeLayout(false);
this.contextMenuStripGuessesUsed.ResumeLayout(false);
this.tabPageUnknownWords.ResumeLayout(false);
this.contextMenuStripUnknownWords.ResumeLayout(false);
this.groupBoxImagePalette.ResumeLayout(false);
@ -1323,7 +1333,6 @@ namespace Nikse.SubtitleEdit.Forms
this.splitContainerBottom.Panel1.PerformLayout();
this.splitContainerBottom.Panel2.ResumeLayout(false);
this.splitContainerBottom.ResumeLayout(false);
this.contextMenuStripGuessesUsed.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@ -1433,5 +1442,6 @@ namespace Nikse.SubtitleEdit.Forms
private System.Windows.Forms.CheckBox checkBoxNOcrCorrect;
private System.Windows.Forms.CheckBox checkBoxNOcrItalic;
private System.Windows.Forms.Button buttonGetTesseractDictionaries;
private System.Windows.Forms.ToolStripMenuItem toolStripMenuItemInspectNOcrMatches;
}
}

View File

@ -3,6 +3,7 @@ using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Reflection;
using System.Text;
@ -13,7 +14,6 @@ using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.OCR;
using Nikse.SubtitleEdit.Logic.SubtitleFormats;
using Nikse.SubtitleEdit.Logic.VobSub;
using System.Globalization;
namespace Nikse.SubtitleEdit.Forms
{
@ -55,6 +55,7 @@ namespace Nikse.SubtitleEdit.Forms
public bool Italic { get; set; }
public int ExpandCount { get; set; }
public string Name { get; set; }
public NOcrChar NOcrCharacter { get; set; }
public CompareMatch(string text, bool italic, int expandCount, string name)
{
Text = text;
@ -62,6 +63,14 @@ namespace Nikse.SubtitleEdit.Forms
ExpandCount = expandCount;
Name = name;
}
public CompareMatch(string text, bool italic, int expandCount, string name, NOcrChar character)
{
Text = text;
Italic = italic;
ExpandCount = expandCount;
Name = name;
NOcrCharacter = character;
}
}
internal class ImageCompareAddition
@ -419,6 +428,7 @@ namespace Nikse.SubtitleEdit.Forms
progressBar1.Maximum = 100;
progressBar1.Value = 0;
numericUpDownPixelsIsSpace.Value = vobSubOcrSettings.XOrMorePixelsMakesSpace;
numericUpDownNumberOfPixelsIsSpaceNOCR.Value = vobSubOcrSettings.XOrMorePixelsMakesSpace;
_vobSubOcrSettings = vobSubOcrSettings;
InitializeModi();
@ -446,6 +456,7 @@ namespace Nikse.SubtitleEdit.Forms
progressBar1.Maximum = 100;
progressBar1.Value = 0;
numericUpDownPixelsIsSpace.Value = vobSubOcrSettings.XOrMorePixelsMakesSpace;
numericUpDownNumberOfPixelsIsSpaceNOCR.Value = vobSubOcrSettings.XOrMorePixelsMakesSpace;
_vobSubOcrSettings = vobSubOcrSettings;
InitializeModi();
@ -476,6 +487,7 @@ namespace Nikse.SubtitleEdit.Forms
progressBar1.Maximum = 100;
progressBar1.Value = 0;
numericUpDownPixelsIsSpace.Value = vobSubOcrSettings.XOrMorePixelsMakesSpace;
numericUpDownNumberOfPixelsIsSpaceNOCR.Value = vobSubOcrSettings.XOrMorePixelsMakesSpace;
_vobSubOcrSettings = vobSubOcrSettings;
_vobSubMergedPackist = vobSubMergedPackist;
_palette = palette;
@ -578,6 +590,7 @@ namespace Nikse.SubtitleEdit.Forms
progressBar1.Maximum = 100;
progressBar1.Value = 0;
numericUpDownPixelsIsSpace.Value = 11; // vobSubOcrSettings.XOrMorePixelsMakesSpace;
numericUpDownNumberOfPixelsIsSpaceNOCR.Value = 11;
_vobSubOcrSettings = vobSubOcrSettings;
InitializeModi();
@ -1174,7 +1187,7 @@ namespace Nikse.SubtitleEdit.Forms
return new Point((int)Math.Round(p.X + (height - p.Y) * _unItalicFactor), p.Y);
}
private string NOcrFindBestMatch(Bitmap bmp, int topMargin, out bool italic)
private NOcrChar NOcrFindBestMatch(Bitmap bmp, int topMargin, out bool italic)
{
italic = false;
@ -1182,7 +1195,8 @@ namespace Nikse.SubtitleEdit.Forms
foreach (NOcrChar oc in _nocrChars)
{
if (Math.Abs(oc.Width - nbmp.Width) < 3 && Math.Abs(oc.Height - nbmp.Height) < 3 && Math.Abs(oc.MarginTop - topMargin) < 3)
{
{ // only very accurate matches
bool ok = true;
foreach (NOcrPoint op in oc.LinesForeground)
{
@ -1218,16 +1232,17 @@ namespace Nikse.SubtitleEdit.Forms
}
}
if (ok)
return oc.Text;
return oc;
}
}
double widthPercent = nbmp.Height * 100.0 / nbmp.Width;
foreach (NOcrChar oc in _nocrChars)
{
if (Math.Abs(oc.WidthPercent - widthPercent) < 10 && nbmp.Width > 25 && nbmp.Height > 20 && Math.Abs(oc.MarginTop - topMargin) < nbmp.Height / 5)
{
int marginTopDiff = Math.Abs(oc.MarginTop - topMargin);
if (Math.Abs(oc.Width - nbmp.Width) < 3 && Math.Abs(oc.Height - nbmp.Height) < 3 && marginTopDiff > 3 && marginTopDiff < 8)
{ // only very accurate matches - but not for margin top
bool ok = true;
foreach (NOcrPoint op in oc.LinesForeground)
{
@ -1263,142 +1278,186 @@ namespace Nikse.SubtitleEdit.Forms
}
}
if (ok)
return oc.Text;
return oc;
}
}
if (!checkBoxNOcrCorrect.Checked)
{
foreach (NOcrChar oc in _nocrChars)
{
if (Math.Abs(oc.WidthPercent - widthPercent) < 40 && nbmp.Width > 20 && nbmp.Height > 10 && Math.Abs(oc.MarginTop - topMargin) < 10)
{
bool ok = true;
foreach (NOcrPoint op in oc.LinesForeground)
{
foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height))
{
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
{
}
else
{
ok = false;
break;
}
}
}
}
foreach (NOcrPoint op in oc.LinesBackground)
{
foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height))
{
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
{
ok = false;
break;
}
}
}
}
if (ok)
return oc.Text;
}
}
//double widthPercent = nbmp.Height * 100.0 / nbmp.Width;
//foreach (NOcrChar oc in _nocrChars)
//{
// if (Math.Abs(oc.WidthPercent - widthPercent) < 10 && nbmp.Width > 25 && nbmp.Height > 20 && Math.Abs(oc.MarginTop - topMargin) < nbmp.Height / 4)
// {
// bool ok = true;
// foreach (NOcrPoint op in oc.LinesForeground)
// {
// foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height))
// {
// if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
// {
// Color c = nbmp.GetPixel(point.X, point.Y);
// if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
// {
// }
// else
// {
// ok = false;
// break;
// }
// }
// }
// }
// foreach (NOcrPoint op in oc.LinesBackground)
// {
// foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height))
// {
// if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
// {
// Color c = nbmp.GetPixel(point.X, point.Y);
// if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
// {
// ok = false;
// break;
// }
// }
// }
// }
// if (ok)
// return oc;
// }
//}
foreach (NOcrChar oc in _nocrChars)
{
if (Math.Abs(oc.WidthPercent - widthPercent) < 40 && nbmp.Width > 20 && nbmp.Height > 10 && Math.Abs(oc.MarginTop - topMargin) < 10)
{
bool ok = true;
foreach (NOcrPoint op in oc.LinesForeground)
{
foreach (Point point in op.GetPoints(nbmp.Width-3, nbmp.Height))
{
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
{
}
else
{
ok = false;
break;
}
}
}
}
foreach (NOcrPoint op in oc.LinesBackground)
{
foreach (Point point in op.GetPoints(nbmp.Width-3, nbmp.Height))
{
if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y);
if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
{
ok = false;
break;
}
}
}
}
if (ok)
return oc.Text;
}
}
//if (!checkBoxNOcrCorrect.Checked)
//{
// foreach (NOcrChar oc in _nocrChars)
// {
// if (Math.Abs(oc.WidthPercent - widthPercent) < 40 && nbmp.Width > 20 && nbmp.Height > 10 && Math.Abs(oc.MarginTop - topMargin) < 10)
// {
// bool ok = true;
// foreach (NOcrPoint op in oc.LinesForeground)
// {
// foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height))
// {
// if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
// {
// Color c = nbmp.GetPixel(point.X, point.Y);
// if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
// {
// }
// else
// {
// ok = false;
// break;
// }
// }
// }
// }
// foreach (NOcrPoint op in oc.LinesBackground)
// {
// foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height))
// {
// if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
// {
// Color c = nbmp.GetPixel(point.X, point.Y);
// if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
// {
// ok = false;
// break;
// }
// }
// }
// }
// if (ok)
// return oc;
// }
// }
foreach (NOcrChar oc in _nocrChars)
{
if (Math.Abs(oc.WidthPercent - widthPercent) < 40 && nbmp.Width > 20 && nbmp.Height > 10 && Math.Abs(oc.MarginTop - topMargin) < 10)
{
bool ok = true;
foreach (NOcrPoint op in oc.LinesForeground)
{
foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height-4))
{
if (point.X >= 0 && point.Y+4 >= 0 && point.X < nbmp.Width && point.Y+4 < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y+4);
if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
{
}
else
{
ok = false;
break;
}
}
}
}
foreach (NOcrPoint op in oc.LinesBackground)
{
foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height-4))
{
if (point.X >= 0 && point.Y+4 >= 0 && point.X < nbmp.Width && point.Y+4 < nbmp.Height)
{
Color c = nbmp.GetPixel(point.X, point.Y+4);
if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
{
ok = false;
break;
}
}
}
}
if (ok)
return oc.Text;
}
}
// foreach (NOcrChar oc in _nocrChars)
// {
// if (Math.Abs(oc.WidthPercent - widthPercent) < 40 && nbmp.Width > 20 && nbmp.Height > 10 && Math.Abs(oc.MarginTop - topMargin) < 10)
// {
// bool ok = true;
// foreach (NOcrPoint op in oc.LinesForeground)
// {
// foreach (Point point in op.GetPoints(nbmp.Width-3, nbmp.Height))
// {
// if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
// {
// Color c = nbmp.GetPixel(point.X, point.Y);
// if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
// {
// }
// else
// {
// ok = false;
// break;
// }
// }
// }
// }
// foreach (NOcrPoint op in oc.LinesBackground)
// {
// foreach (Point point in op.GetPoints(nbmp.Width-3, nbmp.Height))
// {
// if (point.X >= 0 && point.Y >= 0 && point.X < nbmp.Width && point.Y < nbmp.Height)
// {
// Color c = nbmp.GetPixel(point.X, point.Y);
// if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
// {
// ok = false;
// break;
// }
// }
// }
// }
// if (ok)
// return oc;
// }
// }
}
// foreach (NOcrChar oc in _nocrChars)
// {
// if (Math.Abs(oc.WidthPercent - widthPercent) < 40 && nbmp.Width > 20 && nbmp.Height > 10 && Math.Abs(oc.MarginTop - topMargin) < 10)
// {
// bool ok = true;
// foreach (NOcrPoint op in oc.LinesForeground)
// {
// foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height-4))
// {
// if (point.X >= 0 && point.Y+4 >= 0 && point.X < nbmp.Width && point.Y+4 < nbmp.Height)
// {
// Color c = nbmp.GetPixel(point.X, point.Y+4);
// if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
// {
// }
// else
// {
// ok = false;
// break;
// }
// }
// }
// }
// foreach (NOcrPoint op in oc.LinesBackground)
// {
// foreach (Point point in op.GetPoints(nbmp.Width, nbmp.Height-4))
// {
// if (point.X >= 0 && point.Y+4 >= 0 && point.X < nbmp.Width && point.Y+4 < nbmp.Height)
// {
// Color c = nbmp.GetPixel(point.X, point.Y+4);
// if (c.A > 150 && c.R > 100 && c.G > 100 && c.B > 100)
// {
// ok = false;
// break;
// }
// }
// }
// }
// if (ok)
// return oc;
// }
// }
//}
//foreach (NOcrChar oc in _nocrChars)
//{
@ -1604,11 +1663,11 @@ namespace Nikse.SubtitleEdit.Forms
return null;
}
private CompareMatch GetNOcrCompareMatch(ImageSplitterItem targetItem, Bitmap parentBitmap, out CompareMatch secondBestGuess)
internal CompareMatch GetNOcrCompareMatch(ImageSplitterItem targetItem, Bitmap parentBitmap, out CompareMatch secondBestGuess)
{
secondBestGuess = null;
bool italic;
var result = NOcrFindBestMatch(targetItem.Bitmap, targetItem.Y, out italic);
var result = NOcrFindBestMatch(targetItem.Bitmap, targetItem.Y - targetItem.ParentY , out italic);
if (result == null)
{
if (checkBoxNOcrCorrect.Checked)
@ -1616,7 +1675,7 @@ namespace Nikse.SubtitleEdit.Forms
else
return new CompareMatch("*", false, 0, null);
}
return new CompareMatch(result, false, 0, null);
return new CompareMatch(result.Text, false, 0, null, result);
}
private CompareMatch GetCompareMatch(ImageSplitterItem targetItem, Bitmap parentBitmap, out CompareMatch secondBestGuess)
@ -2213,7 +2272,7 @@ namespace Nikse.SubtitleEdit.Forms
return line;
}
private void SaveNOcr(string fileName)
internal void SaveNOcr(string fileName)
{
try
{
@ -2310,7 +2369,7 @@ namespace Nikse.SubtitleEdit.Forms
bitmap = nbmp.GetBitmap();
var matches = new List<CompareMatch>();
List<ImageSplitterItem> list = ImageSplitter.SplitBitmapToLetters(bitmap, (int)numericUpDownPixelsIsSpace.Value, checkBoxRightToLeft.Checked, Configuration.Settings.VobSubOcr.TopToBottom);
List<ImageSplitterItem> list = ImageSplitter.SplitBitmapToLetters(bitmap, (int)numericUpDownNumberOfPixelsIsSpaceNOCR.Value, checkBoxRightToLeft.Checked, Configuration.Settings.VobSubOcr.TopToBottom);
foreach (ImageSplitterItem item in list)
{
@ -2439,6 +2498,28 @@ namespace Nikse.SubtitleEdit.Forms
}
}
string line = GetStringWithItalicTags(matches);
// fix I/l
int start = line.IndexOf("I");
while (start > 0)
{
if (start > 0 && line[start - 1].ToString() != line[start - 1].ToString().ToUpper())
line = line.Remove(start, 1).Insert(start, "l");
else if (start < line.Length-1 && line[start + 1].ToString() != line[start + 1].ToString().ToUpper())
line = line.Remove(start, 1).Insert(start, "l");
start++;
start = line.IndexOf("I", start);
}
start = line.IndexOf("l");
while (start > 0)
{
if (start < line.Length - 1 && line[start + 1].ToString() != line[start + 1].ToString().ToLower())
line = line.Remove(start, 1).Insert(start, "I");
start++;
start = line.IndexOf("l", start);
}
if (checkBoxAutoFixCommonErrors.Checked)
line = OcrFixEngine.FixOcrErrorsViaHardcodedRules(line, _lastLine, null); // TODO: add abbreviations list
@ -4177,6 +4258,18 @@ namespace Nikse.SubtitleEdit.Forms
inspectImageCompareMatchesForCurrentImageToolStripMenuItem.Visible = false;
EditLastAdditionsToolStripMenuItem.Visible = false;
}
if (comboBoxOcrMethod.SelectedIndex == 3) // nocr compare
{
toolStripMenuItemInspectNOcrMatches.Visible = true;
toolStripSeparatorImageCompare.Visible = true;
}
else
{
toolStripMenuItemInspectNOcrMatches.Visible = false;
toolStripSeparatorImageCompare.Visible = false;
}
}
private void SaveImageAsToolStripMenuItemClick(object sender, EventArgs e)
@ -5068,5 +5161,25 @@ namespace Nikse.SubtitleEdit.Forms
InitializeTesseract();
}
private void toolStripMenuItemInspectNOcrMatches_Click(object sender, EventArgs e)
{
if (subtitleListView1.SelectedItems.Count != 1)
return;
Cursor = Cursors.WaitCursor;
Bitmap bitmap = GetSubtitleBitmap(subtitleListView1.SelectedItems[0].Index);
bool oldPrompt = checkBoxPromptForUnknownWords.Checked;
string result = OcrViaNOCR(bitmap, subtitleListView1.SelectedItems[0].Index);
checkBoxPromptForUnknownWords.Checked = oldPrompt;
Cursor = Cursors.Default;
var inspect = new VobSubNOcrCharacterInspect();
inspect.Initialize(bitmap, (int)numericUpDownNumberOfPixelsIsSpaceNOCR.Value, checkBoxRightToLeft.Checked, _nocrChars, this);
if (inspect.ShowDialog(this) == DialogResult.OK)
{
Cursor = Cursors.WaitCursor;
Cursor = Cursors.Default;
}
}
}
}

View File

@ -86,7 +86,7 @@ namespace Nikse.SubtitleEdit.Forms
_vobSubForm = vobSubForm;
_additions = additions;
_nocrChar = new NOcrChar();
_nocrChar.MarginTop = character.Y;
_nocrChar.MarginTop = character.Y - character.ParentY;
_imageWidth = character.Bitmap.Width;
_imageHeight = character.Bitmap.Height;
_drawLineOn = false;

View File

@ -477,6 +477,7 @@ namespace Nikse.SubtitleEdit.Logic
var line = new List<ImageSplitterItem>();
foreach (ImageSplitterItem item in SplitHorizontal(b, xOrMorePixelsMakesSpace))
{
item.ParentY = item.Y;
line.Add(item);
}
if (rightToLeft)

View File

@ -6,6 +6,7 @@ namespace Nikse.SubtitleEdit.Logic
{
public int X { get; set; }
public int Y { get; set; }
public int ParentY { get; set; }
public Bitmap Bitmap { get; set; }
public string SpecialCharacter { get; set; }

View File

@ -602,6 +602,12 @@
<Compile Include="Forms\VobSubEditCharacters.Designer.cs">
<DependentUpon>VobSubEditCharacters.cs</DependentUpon>
</Compile>
<Compile Include="Forms\VobSubNOcrCharacterInspect.cs">
<SubType>Form</SubType>
</Compile>
<Compile Include="Forms\VobSubNOcrCharacterInspect.Designer.cs">
<DependentUpon>VobSubNOcrCharacterInspect.cs</DependentUpon>
</Compile>
<Compile Include="Forms\VobSubOcr.cs">
<SubType>Form</SubType>
</Compile>
@ -1258,6 +1264,9 @@
<DependentUpon>VisualSync.cs</DependentUpon>
<SubType>Designer</SubType>
</EmbeddedResource>
<EmbeddedResource Include="Forms\VobSubNOcrCharacterInspect.resx">
<DependentUpon>VobSubNOcrCharacterInspect.cs</DependentUpon>
</EmbeddedResource>
<EmbeddedResource Include="Forms\VobSubOcr.resx">
<DependentUpon>VobSubOcr.cs</DependentUpon>
<SubType>Designer</SubType>