Minor OCR improvements

This commit is contained in:
Nikolaj Olsson 2017-09-12 17:25:56 +02:00
parent 4bcdaae335
commit d3eaa58f4f
4 changed files with 42 additions and 20 deletions

View File

@ -994,8 +994,10 @@
<Word from="ofa" to="of a" />
<Word from="ofajudge" to="of a judge" />
<Word from="ofall" to="of all" />
<Word from="Ofall" to="Of all" />
<Word from="ofBedford" to="of Bedford" />
<Word from="ofcourse" to="of course" />
<Word from="Ofcourse" to="Of course" />
<Word from="ofeach" to="of each" />
<Word from="ofeither" to="of either" />
<Word from="Offioer's" to="Officer's" />
@ -1068,6 +1070,7 @@
<Word from="orjust" to="or just" />
<Word from="Orjust" to="Or just" />
<Word from="Orthat" to="Or that" />
<Word from="orwould" to="or would" />
<Word from="Orwould" to="Or would" />
<Word from="Othenzvise" to="Otherwise" />
<Word from="our joumey" to="our journey" />
@ -1942,6 +1945,18 @@
<Word from="ifit's" to="if it's" />
<Word from="ornot" to="or not" />
<Word from="myposition" to="my position" />
<Word from="lndistinct" to="Indistinct" />
<Word from="anybiscuits" to="any biscuits" />
<Word from="Andifyou" to="And if you" />
<Word from="lfwe" to="If we" />
<Word from="yourarm" to="your arm" />
<Word from="lnteresting" to="Interesting" />
<Word from="findit" to="find it" />
<Word from="it'llstart" to="it'll start" />
<Word from="holdit" to="hold it" />
<Word from="ofkilling" to="of killing" />
<Word from="Howyou" to="How you" />
<Word from="lnhales" to="Inhales" />
</WholeWords>
<PartialWordsAlways>
<!-- Will be replaced always -->

Binary file not shown.

View File

@ -21,6 +21,7 @@ using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using Nikse.SubtitleEdit.Controls;
namespace Nikse.SubtitleEdit.Forms.Ocr
{
@ -352,6 +353,10 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
buttonOK.Text = Configuration.Settings.Language.General.Ok;
buttonCancel.Text = Configuration.Settings.Language.General.Cancel;
subtitleListView1.InitializeLanguage(Configuration.Settings.Language.General, Configuration.Settings);
subtitleListView1.HideColumn(SubtitleListView.SubtitleColumn.CharactersPerSeconds);
subtitleListView1.HideColumn(SubtitleListView.SubtitleColumn.Actor);
subtitleListView1.HideColumn(SubtitleListView.SubtitleColumn.WordsPerMinute);
subtitleListView1.HideColumn(SubtitleListView.SubtitleColumn.Region);
subtitleListView1.AutoSizeColumns();
groupBoxImagePalette.Text = language.ImagePalette;

View File

@ -80,7 +80,14 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
_selectedCompareNode = null;
_selectedCompareBinaryOcrBitmap = null;
pictureBoxInspectItem.Image = _imageSources[listBoxInspectItems.SelectedIndex];
var img = _imageSources[listBoxInspectItems.SelectedIndex];
pictureBoxInspectItem.Image = img;
if (img != null)
{
pictureBoxInspectItem.Width = img.Width;
pictureBoxInspectItem.Height = img.Height;
}
pictureBoxCompareBitmap.Image = null;
pictureBoxCompareBitmapDouble.Image = null;
@ -99,13 +106,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
textBoxText.Text = bob.Text;
checkBoxItalic.Checked = bob.Italic;
_selectedCompareBinaryOcrBitmap = bob;
var bitmap = bob.ToOldBitmap();
pictureBoxCompareBitmap.Image = bitmap;
pictureBoxCompareBitmapDouble.Width = bitmap.Width * 2;
pictureBoxCompareBitmapDouble.Height = bitmap.Height * 2;
pictureBoxCompareBitmapDouble.Image = bitmap;
SetDbItemView(bob.ToOldBitmap());
var matchBob = new BinaryOcrBitmap(new NikseBitmap(_imageSources[listBoxInspectItems.SelectedIndex]));
if (matchBob.Hash == bob.Hash && matchBob.Width == bob.Width && matchBob.Height == bob.Height && matchBob.NumberOfColoredPixels == bob.NumberOfColoredPixels)
{
@ -115,7 +116,6 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
{
buttonAddBetterMatch.Enabled = true;
}
bobFound = true;
break;
}
@ -129,14 +129,9 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
textBoxText.Text = bob.Text;
checkBoxItalic.Checked = bob.Italic;
_selectedCompareBinaryOcrBitmap = bob;
var bitmap = bob.ToOldBitmap();
pictureBoxCompareBitmap.Image = bitmap;
pictureBoxCompareBitmapDouble.Width = bitmap.Width * 2;
pictureBoxCompareBitmapDouble.Height = bitmap.Height * 2;
pictureBoxCompareBitmapDouble.Image = bitmap;
SetDbItemView(bob.ToOldBitmap());
buttonAddBetterMatch.Enabled = false; // exact match
labelExpandCount.Text = string.Format("Expand count: {0}", bob.ExpandCount);
labelExpandCount.Text = $"Expand count: {bob.ExpandCount}";
break;
}
}
@ -161,10 +156,7 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
f.Position = pos;
var mbmp = new ManagedBitmap(f);
var bitmap = mbmp.ToOldBitmap();
pictureBoxCompareBitmap.Image = bitmap;
pictureBoxCompareBitmapDouble.Width = bitmap.Width * 2;
pictureBoxCompareBitmapDouble.Height = bitmap.Height * 2;
pictureBoxCompareBitmapDouble.Image = bitmap;
SetDbItemView(mbmp.ToOldBitmap());
labelImageInfo.Text = string.Format(Configuration.Settings.Language.VobSubEditCharacters.Image + " - {0}x{1}", bitmap.Width, bitmap.Height);
}
catch (Exception exception)
@ -212,6 +204,16 @@ namespace Nikse.SubtitleEdit.Forms.Ocr
}
}
private void SetDbItemView(Bitmap bitmap)
{
pictureBoxCompareBitmap.Image = bitmap;
pictureBoxCompareBitmap.Width = bitmap.Width;
pictureBoxCompareBitmap.Height = bitmap.Height;
pictureBoxCompareBitmapDouble.Width = bitmap.Width * 2;
pictureBoxCompareBitmapDouble.Height = bitmap.Height * 2;
pictureBoxCompareBitmapDouble.Image = bitmap;
}
private void buttonUpdate_Click(object sender, EventArgs e)
{
if (_selectedCompareNode == null && _selectedCompareBinaryOcrBitmap == null)