示例#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
        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);
                }
            }
        }
示例#4
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;
            }
        }