Exemple #1
0
        /// <summary>
        /// This is the entry point of the hands into the Caduhd App.
        /// </summary>
        /// <param name="image">The image, possibly containing hands.</param>
        public void Input(BgrImage image)
        {
            if (Interlocked.CompareExchange(ref this.isWebCameraFrameProcessorBusy, YES, NO) == NO)
            {
                if (this.handsAnalyzer != null)
                {
                    this.uiConnector.SetHandsAnalyzerState(this.handsAnalyzer.State);
                }

                BgrImage    frame       = image;
                MoveCommand moveCommand = null;

                if (this.skinColorHandsDetector.Tuned)
                {
                    HandsDetectorResult result = this.skinColorHandsDetector.DetectHands(frame);
                    frame = result.Image;
                    var hands = result.Hands;
                    moveCommand =
                        (this.handsDroneController.ProcessHandsInput(hands) as DroneControllerHandsInputProcessResult)?.Result;
                }
                else
                {
                    if (this.handsAnalyzer.State == HandsAnalyzerState.ReadyToAnalyzeLeft || this.handsAnalyzer.State == HandsAnalyzerState.AnalyzingLeft)
                    {
                        if (this.handsAnalyzer.State == HandsAnalyzerState.AnalyzingLeft)
                        {
                            this.handsAnalyzer.AnalyzeLeft(frame, this.handsDroneController.HandsInputEvaluator.TunerHands["left"]["poi"]);
                            this.handsAnalyzer.AdvanceState();
                        }

                        frame.MarkPoints(this.handsDroneController.HandsInputEvaluator.TunerHands["left"]["outline"], Color.Yellow);
                    }
                    else if (this.handsAnalyzer.State == HandsAnalyzerState.ReadyToAnalyzeRight || this.handsAnalyzer.State == HandsAnalyzerState.AnalyzingRight)
                    {
                        if (this.handsAnalyzer.State == HandsAnalyzerState.AnalyzingRight)
                        {
                            this.handsAnalyzer.AnalyzeRight(frame, this.handsDroneController.HandsInputEvaluator.TunerHands["right"]["poi"]);
                            this.handsAnalyzer.AdvanceState();
                        }

                        frame.MarkPoints(this.handsDroneController.HandsInputEvaluator.TunerHands["right"]["outline"], Color.Yellow);
                    }
                    else if (this.handsAnalyzer.State == HandsAnalyzerState.Tuning)
                    {
                        HandsAnalyzerResult result       = this.handsAnalyzer.Result;
                        NormalizedHands     neutralHands = this.skinColorHandsDetector.Tune(result);
                        this.handsDroneController.HandsInputEvaluator.Tune(neutralHands);
                    }
                }

                this.uiConnector?.SetComputerCameraImage(frame);
                this.uiConnector?.SetEvaluatedHandsInput(moveCommand);

                Interlocked.Exchange(ref this.isWebCameraFrameProcessorBusy, NO);
            }
        }
        public HandsAnalyzerResultTests()
        {
            var histogramMock = new Mock <IHistogram>();
            var colorMap      = new ColorMap(histogramMock.Object, histogramMock.Object, histogramMock.Object);

            this.handsColorMaps      = new HandsColorMaps(colorMap, colorMap);
            this.handsBackground     = BgrImage.GetBlank(100, 100, Color.Red);
            this.handsForeground     = BgrImage.GetBlank(100, 100, Color.Green);
            this.handsAnalyzerResult = new HandsAnalyzerResult(this.handsColorMaps, this.handsBackground, this.handsForeground);
        }