Пример #1
0
        async void Start()
        {
            sequence  = GetComponent <ITextureSequence>();
            converter = GetComponent <ITextureConverter>();
            detector  = GetComponent <IDetectService>();
            consumer  = FaceConsumer.GetComponent <IFaceListConsumer>();

            // start a logic loop
            IEnumerable <FaceData> faces = null;

            foreach (Task <Texture> request in sequence.Repeat())
            {
                if (request == null)
                {
                    continue;
                }

                var texture = await request;
                var image   = await converter.Convert(texture);

                var translator = await detector.Detect(ref image);

                faces = translator.Fetch <FaceData>(faces);
                if (faces != null)
                {
                    consumer.Consume(ref image, faces);
                }

                // release holding resources for detection
                translator.Dispose();
            }
        }
Пример #2
0
        internal static IObservable <ElementIndex <Texture> > Process(ITextureSequence texture, double playbackRate, bool loop)
        {
            playbackRate = playbackRate > 0 ? playbackRate : texture.PlaybackRate;
            var periodTicks = (long)(TimeSpan.TicksPerSecond / playbackRate);
            var timer       = new Timer {
                Period = TimeSpan.FromTicks(periodTicks)
            };

            return(Observable.Using(
                       () => texture.GetEnumerator(loop),
                       enumerator => timer.Generate().TakeWhile(x => enumerator.MoveNext()).Select(x => enumerator.Current)));
        }
Пример #3
0
        async void Start()
        {
            sequence  = GetComponent <ITextureSequence>();
            converter = GetComponent <ITextureConverter>();

            var detectors = GetComponents <IDetectService>();

            Debug.Log("Number of Detectors: " + detectors.Length);
            faceService = detectors[0];
            handService = detectors[1];

            faceConsumer = FaceConsumer.GetComponent <IFaceListConsumer>();
            handConsumer = HandConsumer.GetComponent <IHandListConsumer>();

            // start a logic loop
            IEnumerable <FaceData> faces = null;
            IEnumerable <HandData> hands = null;

            foreach (Task <Texture> request in sequence.Repeat())
            {
                if (request == null)
                {
                    continue;
                }

                var texture = await request;

                var image = await converter.Convert(texture);

                var faceTranslator = await faceService.Detect(ref image);

                faces = faceTranslator.Fetch <FaceData>(faces);
                if (faces != null)
                {
                    faceConsumer.Consume(ref image, faces);
                }
                //release holding resources for detection
                faceTranslator.Dispose();

                image = await converter.Convert(texture);

                var handTranslator = await handService.Detect(ref image);

                hands = handTranslator.Fetch <HandData>(hands);
                if (faces != null)
                {
                    handConsumer.Consume(ref image, hands);
                }
                //release holding resources for detection
                handTranslator.Dispose();
            }
        }
        async void Start()
        {
            sequence  = GetComponent <ITextureSequence>();
            converter = GetComponent <ITextureConverter>();
            consumer  = GetComponent <IConsumer <Texture> >();

            foreach (Task <Texture> request in sequence.Repeat())
            {
                if (request == null)
                {
                    continue;
                }
                var texture = await request;
                var image   = await converter.Convert(texture);

                if (consumer != null)
                {
                    consumer.Consume(ref image, texture);
                }
            }
        }
Пример #5
0
        public async void Start()
        {
            sequence  = GetComponent <ITextureSequence>();
            converter = GetComponent <ITextureConverter>();
            detector  = GetComponent <IDetectService>();
            consumer  = FaceConsumer.GetComponent <IFaceListConsumer>();


            IEnumerable <FaceData> faces = null;

            foreach (Task <Texture> request in sequence.Repeat())
            {
                if (request == null)
                {
                    continue;
                }

                var texture = await request;
                var image   = await converter.Convert(texture);

                var translator = await detector.Detect(ref image);

                faces = translator.Fetch <FaceData>(faces);
                if (faces != null)
                {
                    consumer.Consume(ref image, faces);
                }
                else
                {
                    faceDetected = false;
                }
                translator.Dispose();
                Debug.Log("face state: " + faceDetected);
                //faceDetected = false;
            }
        }