Пример #1
0
        private void ProcessCurrentImage()
        {
            if (m_CurrentIndex >= 0 && m_CurrentIndex < m_InputFiles.Count)
            {
                string fileName = m_InputFiles[m_CurrentIndex];
                lblDisplayedFile.Text = fileName;
                m_CurrentImage        = (Bitmap)Bitmap.FromFile(fileName);
                m_Pixelmap            = Pixelmap.ConstructFromBitmap(m_CurrentImage, TangraConfig.ColourChannel.Red);

                using (Graphics g = Graphics.FromImage(m_CurrentImage))
                {
                    m_Processor.Process(m_Pixelmap.Pixels, m_Pixelmap.Width, m_Pixelmap.Height, g, m_CurrentIndex, m_CurrentIndex % 2 == 0);
                    g.Flush();
                }

                picField.Image = m_CurrentImage;
                picField.Update();

                lblBlockWidth.Text  = m_Processor.BlockWidth.ToString();
                lblBlockHeight.Text = m_Processor.BlockHeight.ToString();
                lblBlockXOffs.Text  = m_Processor.BlockOffsetX.ToString();

                if (m_Processor.BlockOffsetYOdd != m_Processor.BlockOffsetYEven)
                {
                    lblBlockYOffs.Text = string.Format("o:{0} e:{1}", m_Processor.BlockOffsetYOdd, m_Processor.BlockOffsetYEven);
                }
                else
                {
                    lblBlockYOffs.Text = m_Processor.BlockOffsetYOdd.ToString();
                }

                PlotDigitPatterns();

                if (string.IsNullOrEmpty(m_Processor.CurrentOcredString))
                {
                    lblOcredText.Text = "";
                }
                else
                {
                    lblOcredText.Text = m_Processor.CurrentOcredString;
                }
            }
        }
Пример #2
0
        public bool ExtractTime(int frameNo, int frameStep, uint[] data, bool debug, out DateTime time)
        {
            LastOddFieldOSD = null;

            if (m_Processor.IsCalibrated && m_TimeStampComposer != null)
            {
                if (m_VideoController != null)
                {
                    m_VideoController.RegisterExtractingOcrTimestamps();
                }

                PrepareOsdVideoFields(data);

                m_Processor.Process(m_OddFieldPixelsPreProcessed, m_FieldAreaWidth, m_FieldAreaHeight, null, frameNo, true);
                LastOddFieldOSD = m_Processor.CurrentOcredTimeStamp;

                m_Processor.Process(m_EvenFieldPixelsPreProcessed, m_FieldAreaWidth, m_FieldAreaHeight, null, frameNo, false);
                LastEvenFieldOSD = m_Processor.CurrentOcredTimeStamp;
                string failedReason;

                if (m_InitializationData.IntegratedAAVFrames > 0)
                {
                    time             = m_TimeStampComposer.ExtractAAVDateTime(frameNo, frameStep, LastOddFieldOSD, LastEvenFieldOSD, out failedReason);
                    LastFailedReason = failedReason;
                }
                else
                {
                    time             = m_TimeStampComposer.ExtractDateTime(frameNo, frameStep, LastOddFieldOSD, LastEvenFieldOSD, out failedReason);
                    LastFailedReason = failedReason;
                }
            }
            else
            {
                time = DateTime.MinValue;
            }

            return(time != DateTime.MinValue);
        }
Пример #3
0
        public override void Process(IotaVtiOcrProcessor stateManager, Graphics graphics, int frameNo, bool isOddField)
        {
            if (m_Width != stateManager.CurrentImageWidth || m_Height != stateManager.CurrentImageHeight)
            {
                Reinitialise(stateManager.CurrentImageWidth, stateManager.CurrentImageHeight);
                ROUTH_START_FRAME_NUMBER_BLOCKS = (int)Math.Round(IotaVtiOcrProcessor.COEFF_FIRST_FRAME_NO_DIGIT_POSITION * stateManager.CurrentImageWidth);
            }

            CalibrateBlockPositonsTop(stateManager, isOddField);
            CalibrateBlockPositonsWidth(stateManager, isOddField);

            if (m_CalibratedPositons.Count == 10)
            {
                stateManager.BlockOffsetYOdd = m_CalibratedPositons.Where(x => x.IsOddField).MostCommonValue(x => x.BlockOffsetY);
                stateManager.BlockOffsetYEven = m_CalibratedPositons.Where(x => !x.IsOddField).MostCommonValue(x => x.BlockOffsetY);

                var normalizedPositions = new List<CalibratedBlockPosition>();

                if (CalibrateFrameNumberBlockPositions(stateManager, out normalizedPositions) &&
                    RecognizedTimestampsConsistent(stateManager, normalizedPositions))
                {
                    stateManager.ChangeState<IotaVtiOcrCalibratedState>();
                    stateManager.Process(stateManager.CurrentImage, stateManager.CurrentImageWidth, stateManager.CurrentImageHeight, graphics, frameNo, isOddField);
                    return;
                }
                else
                {
                    // Make sure we always remove the whole frame, so swapped fields create less issues when learning the characters
                    m_CalibratedPositons.RemoveAt(0);
                    m_CalibratedPositons.RemoveAt(0);
                }
            }

            if (graphics != null)
                base.PlotImage(graphics, stateManager, isOddField);
        }