Example #1
0
        public void SetOcredString(IotaVtiTimeStampStrings ocredValue)
        {
            CurrentOcredString = string.Format("{0}|{1}:{2}:{3}|{4} {5}|{6}", ocredValue.NumSat, ocredValue.HH, ocredValue.MM, ocredValue.SS, ocredValue.FFFF1, ocredValue.FFFF2, ocredValue.FRAMENO);

            if (ocredValue.AllCharsPresent())
            {
                CurrentOcredTimeStamp = new IotaVtiTimeStamp(ocredValue);
            }
            else
            {
                CurrentOcredTimeStamp = null;
            }
        }
Example #2
0
        private bool RecognizedTimestampsConsistent(IotaVtiOcrProcessor stateManager, List <CalibratedBlockPosition> normalizedPositions)
        {
            var allTimeStamps   = new List <IotaVtiTimeStamp>();
            int index           = 0;
            int totalTimestamps = normalizedPositions.Count;

            for (; ;)
            {
                if (index == totalTimestamps - 1)
                {
                    break;
                }

                IotaVtiTimeStampStrings timeStampStrings = IotaVtiOcrCalibratedState.OcrField(normalizedPositions[index].Image, stateManager, normalizedPositions[index].IsOddField);
                if (!timeStampStrings.AllCharsPresent())
                {
                    return(false);
                }

                var timeStamp = new IotaVtiTimeStamp(timeStampStrings);

                if (stateManager.SwapFieldsOrder)
                {
                    if (index + 1 == totalTimestamps - 1)
                    {
                        break;
                    }

                    IotaVtiTimeStampStrings timeStampStrings2 = IotaVtiOcrCalibratedState.OcrField(normalizedPositions[index + 1].Image, stateManager, normalizedPositions[index + 1].IsOddField);
                    if (!timeStampStrings2.AllCharsPresent())
                    {
                        return(false);
                    }
                    var timeStamp2 = new IotaVtiTimeStamp(timeStampStrings2);
                    allTimeStamps.Add(timeStamp2);

                    index++;
                }

                allTimeStamps.Add(timeStamp);

                index++;
            }

            float fieldDurationMS = 0;

            for (int i = 0; i < allTimeStamps.Count - 1; i++)
            {
                if (allTimeStamps[i].FrameNumber != allTimeStamps[i + 1].FrameNumber - 1 &&
                    allTimeStamps[i].FrameNumber != allTimeStamps[i + 1].FrameNumber + 1)
                {
                    return(false);
                }

                int totalMillisecondsThis = (allTimeStamps[i].Hours * 3600 + allTimeStamps[i].Minutes * 60 + allTimeStamps[i].Seconds) * 10000 + allTimeStamps[i].Milliseconds10;
                int totalMillisecondsNext = (allTimeStamps[i + 1].Hours * 3600 + allTimeStamps[i + 1].Minutes * 60 + allTimeStamps[i + 1].Seconds) * 10000 + allTimeStamps[i + 1].Milliseconds10;

                fieldDurationMS = Math.Abs((totalMillisecondsNext - totalMillisecondsThis) / 10f);

                if (Math.Abs(fieldDurationMS - IotaVtiOcrProcessor.FIELD_DURATION_PAL) > 0.15 && Math.Abs(fieldDurationMS - IotaVtiOcrProcessor.FIELD_DURATION_NTSC) > 0.15)
                {
                    return(false);
                }
            }

            if (Math.Abs(fieldDurationMS - IotaVtiOcrProcessor.FIELD_DURATION_PAL) < 0.15)
            {
                stateManager.VideoFormat = VideoFormat.PAL;
            }
            else if (Math.Abs(fieldDurationMS - IotaVtiOcrProcessor.FIELD_DURATION_NTSC) < 0.15)
            {
                stateManager.VideoFormat = VideoFormat.NTSC;
            }
            else
            {
                stateManager.VideoFormat = null;
            }

            return(true);
        }