예제 #1
0
        internal override TestFrameResult TestTimeStamp(StateContext context, OsdFrameInfo frameTimestamp)
        {
            attempts++;

            if (lastGoodTimeStamp == null)
            {
                if (frameTimestamp.FrameInfoIsOk())
                    lastGoodTimeStamp = frameTimestamp;
            }
            else
            {
                if (!frameTimestamp.FrameInfoIsOk() ||
                    lastGoodTimeStamp.SecondField.FieldNumber + 1 != frameTimestamp.FirstField.FieldNumber ||
                    Math.Abs(new TimeSpan(frameTimestamp.FirstField.TimeStamp.Ticks - lastGoodTimeStamp.SecondField.TimeStamp.Ticks).TotalMilliseconds - 20) > 1)
                {
                    lastGoodTimeStamp = null;
                }
                else
                {
                    secondLastGoodTimeStamp = frameTimestamp;

                    context.LastTimeStamp = secondLastGoodTimeStamp;
                    context.TransitionToState(CalibratedState.Instance);
                }
            }

            return attempts > 4 ? TestFrameResult.ErrorSaveScreenShotImages : TestFrameResult.Undefined;
        }
예제 #2
0
        internal override TestFrameResult TestTimeStamp(StateContext context, OsdFrameInfo frameTimestamp)
        {
            if (lastTimeStamp.SecondField.FieldNumber + 1 == frameTimestamp.FirstField.FieldNumber &&
                Math.Abs(new TimeSpan(frameTimestamp.FirstField.TimeStamp.Ticks - lastTimeStamp.SecondField.TimeStamp.Ticks).TotalMilliseconds - 20) <= 1)
            {
                // All good
                lastTimeStamp = frameTimestamp;
                return TestFrameResult.Okay;
            }

            suggestedTimeStampTestResult = TestFrameResult.Undefined;

            // Find, record and try to solve problems
            #region Frame/Field Number Corrections
            long expectedFieldNumber = lastTimeStamp.SecondField.FieldNumber + 1;
            int attempts = 5;
            while (expectedFieldNumber != frameTimestamp.FirstField.FieldNumber && attempts > 0)
            {
                // Problem with first frame number
                long correctedFieldNo = CorrectField(expectedFieldNumber, frameTimestamp.FirstField.FieldNumber);
                frameTimestamp.FirstField.FieldNumber = correctedFieldNo;
                frameTimestamp.FrameNumber = correctedFieldNo;
                attempts--;
            }

            attempts = 5;
            expectedFieldNumber = frameTimestamp.FirstField.FieldNumber + 1;
            while (expectedFieldNumber != frameTimestamp.SecondField.FieldNumber && attempts > 0)
            {
                // Problem with first frame number
                long correctedFieldNo = CorrectField(expectedFieldNumber, frameTimestamp.SecondField.FieldNumber);
                frameTimestamp.SecondField.FieldNumber = correctedFieldNo;
                attempts--;
            }
            #endregion

            #region TimeStamp Corrections
            long expectedTicks = lastTimeStamp.SecondField.TimeStamp.Ticks + FIELD_LENGTH_IN_TICKS;
            while (Math.Abs(new TimeSpan(frameTimestamp.FirstField.TimeStamp.Ticks - expectedTicks).TotalMilliseconds) > 1)
            {
                // Correct the timestamp of the first field
                long correctedTicks = CorrectTimeStamp(expectedTicks, frameTimestamp.FirstField.TimeStamp.Ticks);
                frameTimestamp.FirstField.TimeStamp = new DateTime(correctedTicks);
            }
            #endregion

            frameTimestamp.ReCalculate();
            lastTimeStamp = frameTimestamp;

            return suggestedTimeStampTestResult;
        }
예제 #3
0
 internal override void Reset(StateContext context)
 {
     lastGoodTimeStamp = null;
     secondLastGoodTimeStamp = null;
     attempts = 0;
 }
예제 #4
0
 internal override void Reset(StateContext context)
 {
     lastTimeStamp = context.LastTimeStamp;
     correctedChars.Clear();
 }
예제 #5
0
        public string Initialize(OcrConfiguration ocrConfig, int imageWidth, int imageHeight)
        {
            this.ocrConfig = ocrConfig;

            for (int i = 0; i < ocrConfig.Alignment.CharPositions.Count; i++)
            {
                int leftPos = ocrConfig.Alignment.CharPositions[i];
                var ocredChar = new OcredChar(i, leftPos, ocrConfig.Alignment.CharWidth, ocrConfig.Alignment.CharHeight);
                ocredChar.PopulateZones(ocrConfig.Zones);
                ocredCharsOdd.Add(ocredChar);

                ocredChar = new OcredChar(i, leftPos, ocrConfig.Alignment.CharWidth, ocrConfig.Alignment.CharHeight);
                ocredChar.PopulateZones(ocrConfig.Zones);
                ocredCharsEven.Add(ocredChar);
            }

            zoneChecker = new OcrZoneChecker(
                ocrConfig,
                ocrConfig.Alignment.Width,
                ocrConfig.Alignment.Height,
                ocrConfig.Zones,
                ocrConfig.Alignment.CharPositions);

            charRecognizer = new OcrCharRecognizer(
                ocrConfig.Zones,
                ocrConfig.CharDefinitions);

            cameraImage = new CameraImage();
            testContext = new StateContext();
            generateDebugImages = false;

            return null;
        }
예제 #6
0
 internal abstract TestFrameResult TestTimeStamp(StateContext context, OsdFrameInfo frameTimestamp);
예제 #7
0
 internal abstract void Reset(StateContext context);