Fixed name spaces for OCR forms + minor fix for guessing "min line with"

This commit is contained in:
Nikolaj Olsson 2017-02-26 10:20:00 +01:00
parent 874caecf77
commit 9f6c98f9b5
32 changed files with 95 additions and 84 deletions

View File

@ -13,6 +13,7 @@ using System.Globalization;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Forms.Ocr;
namespace Nikse.SubtitleEdit.Forms
{

View File

@ -5,6 +5,7 @@ using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Forms.Ocr;
namespace Nikse.SubtitleEdit.Forms
{

View File

@ -18,6 +18,7 @@ using System.Text.RegularExpressions;
using System.Threading;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Forms.Ocr;
namespace Nikse.SubtitleEdit.Forms
{

View File

@ -25,6 +25,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core.SpellCheck;
using Nikse.SubtitleEdit.Forms.Ocr;
namespace Nikse.SubtitleEdit.Forms
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
partial class AddToOcrReplaceList
{

View File

@ -1,11 +1,11 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.Dictionaries;
using Nikse.SubtitleEdit.Logic;
using System;
using System;
using System.Globalization;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.Dictionaries;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public partial class AddToOcrReplaceList : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
sealed partial class OcrSpellCheck
{

View File

@ -1,11 +1,11 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public sealed partial class OcrSpellCheck : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
sealed partial class VobSubCharactersImport
{

View File

@ -7,7 +7,7 @@ using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic.Ocr.Binary;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public sealed partial class VobSubCharactersImport : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
sealed partial class VobSubEditCharacters
{

View File

@ -1,14 +1,14 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr.Binary;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.IO;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr.Binary;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public sealed partial class VobSubEditCharacters : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
partial class VobSubNOcrCharacterInspect
{

View File

@ -1,12 +1,12 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public partial class VobSubNOcrCharacterInspect : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
partial class VobSubNOcrEdit
{

View File

@ -1,11 +1,11 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic.Ocr;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic.Ocr;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public partial class VobSubNOcrEdit : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
partial class VobSubNOcrTrain
{

View File

@ -1,8 +1,4 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Drawing2D;
@ -10,8 +6,12 @@ using System.Drawing.Text;
using System.IO;
using System.Text;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public partial class VobSubNOcrTrain : Form
{

View File

@ -1,6 +1,6 @@
using Nikse.SubtitleEdit.Controls;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
sealed partial class VobSubOcr
{
@ -307,7 +307,7 @@ namespace Nikse.SubtitleEdit.Forms
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem.Name = "inspectImageCompareMatchesForCurrentImageToolStripMenuItem";
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem.Size = new System.Drawing.Size(305, 22);
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem.Text = "Inspect compare matches for current image";
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem.Click += new System.EventHandler(this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem_Click);
this.inspectImageCompareMatchesForCurrentImageToolStripMenuItem.Click += new System.EventHandler(this.InspectImageCompareMatchesForCurrentImageToolStripMenuItem_Click);
//
// EditLastAdditionsToolStripMenuItem
//

View File

@ -1,18 +1,11 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.BluRaySup;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Core.TransportStream;
using Nikse.SubtitleEdit.Core.VobSub;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr;
using Nikse.SubtitleEdit.Logic.Ocr.Binary;
using System;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Net;
using System.Reflection;
using System.Text;
@ -20,17 +13,25 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Core.BluRaySup;
using Nikse.SubtitleEdit.Core.SubtitleFormats;
using Nikse.SubtitleEdit.Core.TransportStream;
using Nikse.SubtitleEdit.Core.VobSub;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr;
using Nikse.SubtitleEdit.Logic.Ocr.Binary;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public sealed partial class VobSubOcr : PositionAndSizeForm
{
internal class CompareItem
{
public ManagedBitmap Bitmap { get; private set; }
public string Name { get; private set; }
public ManagedBitmap Bitmap { get; }
public string Name { get; }
public bool Italic { get; set; }
public int ExpandCount { get; private set; }
public int ExpandCount { get; }
public int NumberOfForegroundColors { get; set; }
public string Text { get; set; }
@ -47,9 +48,9 @@ namespace Nikse.SubtitleEdit.Forms
internal class SubPicturesWithSeparateTimeCodes
{
public SubPicture Picture { get; private set; }
public TimeSpan Start { get; private set; }
public TimeSpan End { get; private set; }
public SubPicture Picture { get; }
public TimeSpan Start { get; }
public TimeSpan End { get; }
public SubPicturesWithSeparateTimeCodes(SubPicture subPicture, TimeSpan start, TimeSpan end)
{
@ -4226,10 +4227,14 @@ namespace Nikse.SubtitleEdit.Forms
if (_ocrFixEngine == null)
LoadOcrFixEngine(null, LanguageString);
string line = string.Empty;
var matches = new List<CompareMatch>();
var parentBitmap = new NikseBitmap(bitmap);
int minLineHeight = _binOcrLastLowercaseHeight - 3;
if (_binOcrLastLowercaseHeight == -1 && _nocrLastLowercaseHeight == -1)
{ // try to guess lowercase height
var letters = NikseBitmapImageSplitter.SplitBitmapToLettersNew(parentBitmap, _numericUpDownPixelsIsSpace, checkBoxRightToLeft.Checked, Configuration.Settings.VobSubOcr.TopToBottom, 6, _ocrCount > 20 ? _ocrHeight : -1);
minLineHeight = (int)Math.Round(letters.Where(p => p.NikseBitmap != null).Average(p => p.NikseBitmap.Height) * 0.5);
}
if (minLineHeight < 5)
minLineHeight = _nocrLastLowercaseHeight;
if (minLineHeight < 5)
@ -7787,7 +7792,7 @@ namespace Nikse.SubtitleEdit.Forms
}
}
private void inspectImageCompareMatchesForCurrentImageToolStripMenuItem_Click(object sender, EventArgs e)
private void InspectImageCompareMatchesForCurrentImageToolStripMenuItem_Click(object sender, EventArgs e)
{
if (subtitleListView1.SelectedItems.Count != 1)
return;
@ -8851,7 +8856,7 @@ namespace Nikse.SubtitleEdit.Forms
{
if (subtitleListView1.SelectedItems.Count > 0 && (_ocrMethodIndex == _ocrMethodBinaryImageCompare || _ocrMethodIndex == _ocrMethodImageCompare))
{
inspectImageCompareMatchesForCurrentImageToolStripMenuItem_Click(null, null);
InspectImageCompareMatchesForCurrentImageToolStripMenuItem_Click(null, null);
}
}

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
sealed partial class VobSubOcrCharacter
{

View File

@ -1,11 +1,11 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public sealed partial class VobSubOcrCharacter : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
partial class VobSubOcrCharacterInspect
{

View File

@ -1,15 +1,15 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr.Binary;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Globalization;
using System.IO;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr.Binary;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public sealed partial class VobSubOcrCharacterInspect : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
partial class VobSubOcrNOcrCharacter
{

View File

@ -1,12 +1,12 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr;
using System;
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using Nikse.SubtitleEdit.Logic.Ocr;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public partial class VobSubOcrNOcrCharacter : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
sealed partial class VobSubOcrNewFolder
{

View File

@ -1,10 +1,10 @@
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
using System;
using System;
using System.IO;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
using Nikse.SubtitleEdit.Logic;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public sealed partial class VobSubOcrNewFolder : Form
{

View File

@ -1,4 +1,4 @@
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
sealed partial class VobSubOcrSetItalicFactor
{

View File

@ -1,9 +1,9 @@
using Nikse.SubtitleEdit.Core;
using System;
using System;
using System.Drawing;
using System.Windows.Forms;
using Nikse.SubtitleEdit.Core;
namespace Nikse.SubtitleEdit.Forms
namespace Nikse.SubtitleEdit.Forms.Ocr
{
public sealed partial class VobSubOcrSetItalicFactor : Form
{

View File

@ -10,6 +10,7 @@ using System.Globalization;
using System.IO;
using System.Linq;
using System.Text;
using Nikse.SubtitleEdit.Forms.Ocr;
namespace Nikse.SubtitleEdit.Logic
{

View File

@ -12,6 +12,7 @@ using System.Text;
using System.Text.RegularExpressions;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Forms.Ocr;
namespace Nikse.SubtitleEdit.Logic.Ocr
{