Beispiel #1
0
        internal void Initialize(Bitmap bitmap, int pixelsIsSpace, bool rightToLeft, NOcrDb nOcrDb, VobSubOcr vobSubOcr, double unItalicFactor)
        {
            _bitmap = bitmap;
            var nbmp = new NikseBitmap(bitmap);

            nbmp.ReplaceNonWhiteWithTransparent();
            bitmap          = nbmp.GetBitmap();
            _bitmap2        = bitmap;
            _nocrChars      = nOcrDb.OcrCharacters;
            _matchList      = new List <VobSubOcr.CompareMatch>();
            _vobSubOcr      = vobSubOcr;
            _unItalicFactor = unItalicFactor;

            int minLineHeight = 6;

            _imageList = NikseBitmapImageSplitter.SplitBitmapToLettersNew(nbmp, pixelsIsSpace, rightToLeft, Configuration.Settings.VobSubOcr.TopToBottom, minLineHeight);
            // _imageList = NikseBitmapImageSplitter.SplitBitmapToLetters(nbmp, pixelsIsSpace, rightToLeft, Configuration.Settings.VobSubOcr.TopToBottom);

            int index = 0;

            while (index < _imageList.Count)
            {
                ImageSplitterItem item = _imageList[index];
                if (item.NikseBitmap == null)
                {
                    listBoxInspectItems.Items.Add(item.SpecialCharacter);
                    _matchList.Add(null);
                }
                else
                {
                    nbmp = item.NikseBitmap;
                    nbmp.ReplaceNonWhiteWithTransparent();
                    item.Y += nbmp.CropTopTransparent(0);
                    nbmp.CropTransparentSidesAndBottom(0, true);
                    nbmp.ReplaceTransparentWith(Color.Black);

                    //get nocr matches
                    Nikse.SubtitleEdit.Forms.VobSubOcr.CompareMatch match = vobSubOcr.GetNOcrCompareMatchNew(item, nbmp, nOcrDb, _unItalicFactor, false, false);
                    if (match == null)
                    {
                        listBoxInspectItems.Items.Add("?");
                        _matchList.Add(null);
                    }
                    else
                    {
                        listBoxInspectItems.Items.Add(match.Text);
                        _matchList.Add(match);
                    }
                }
                index++;
            }
        }
Beispiel #2
0
        internal void Initialize(Bitmap bitmap, int pixelsIsSpace, bool rightToLeft, NOcrDb nOcrDb, VobSubOcr vobSubOcr, bool italic, int minLineHeight, bool deepSeek)
        {
            _bitmap = bitmap;
            var nikseBitmap = new NikseBitmap(bitmap);

            nikseBitmap.ReplaceNonWhiteWithTransparent();
            _nOcrChars = nOcrDb.OcrCharacters;
            _nOcrDb    = nOcrDb;
            _matchList = new List <VobSubOcr.CompareMatch>();

            _imageList = NikseBitmapImageSplitter.SplitBitmapToLettersNew(nikseBitmap, pixelsIsSpace, rightToLeft, Configuration.Settings.VobSubOcr.TopToBottom, minLineHeight, false);

            int index = 0;

            _indexLookup = new Dictionary <int, int>();
            while (index < _imageList.Count)
            {
                var item = _imageList[index];
                if (item.NikseBitmap == null)
                {
                    _indexLookup.Add(listBoxInspectItems.Items.Count, index);
                    listBoxInspectItems.Items.Add(item.SpecialCharacter);
                    _matchList.Add(null);
                }
                else
                {
                    var match = vobSubOcr.GetNOcrCompareMatchNew(item, nikseBitmap, nOcrDb, italic, deepSeek, index, _imageList);
                    if (match == null)
                    {
                        _indexLookup.Add(listBoxInspectItems.Items.Count, index);
                        listBoxInspectItems.Items.Add("?");
                        _matchList.Add(null);
                    }
                    else
                    {
                        _indexLookup.Add(listBoxInspectItems.Items.Count, index);
                        listBoxInspectItems.Items.Add(match.Text);
                        _matchList.Add(match);
                        if (match.ExpandCount > 0)
                        {
                            index += match.ExpandCount - 1;
                        }
                    }
                }
                index++;
            }
        }