public void DifferentKeyInputsAfterEachOther_BothSent() { var skinColorHandsDetector = new SkinColorHandsDetector(); var keyInputEvaluator = new GeneralDroneKeyInputEvaluator(); var handsInputEvaluator = new DroneControllerHandsInputEvaluator(); this.caduhdApp = new CaduhdApp(null, skinColorHandsDetector, this.tello, keyInputEvaluator, handsInputEvaluator); this.udpClient.Client.ReceiveTimeout = 1000; this.caduhdApp.Input(new KeyInfo(Key.Right, KeyState.Down)); this.caduhdApp.Input(new KeyInfo(Key.Up, KeyState.Down)); int counter = 0; try { string response = this.udpClient.Receive(ref this.anyEndPoint).AsString(); Assert.Equal($"rc {this.tello.Speed} 0 0 0", response); counter++; response = this.udpClient.Receive(ref this.anyEndPoint).AsString(); Assert.Equal($"rc {this.tello.Speed} {this.tello.Speed} 0 0", response); counter++; } catch (SocketException) { } this.tello.Dispose(); Assert.Equal(2, counter); }
public SkinColorHandsDetectorTests() { int blue = 44; int green = 87; int red = 123; this.skinColor = Color.FromArgb(red, green, blue); this.handsBackground = BgrImage.GetBlank(WIDTH, HEIGHT, Color.White); this.handsForeground = this.handsBackground.Copy(); var blueHistogramMock = new Mock <IHistogram>(); blueHistogramMock.Setup(bh => bh.Smallest).Returns(blue - PIXEL_TOLERANCE); blueHistogramMock.Setup(bh => bh.Greatest).Returns(blue + PIXEL_TOLERANCE); var greenHistogramMock = new Mock <IHistogram>(); greenHistogramMock.Setup(bh => bh.Smallest).Returns(green - PIXEL_TOLERANCE); greenHistogramMock.Setup(bh => bh.Greatest).Returns(green + PIXEL_TOLERANCE); var redHistogramMock = new Mock <IHistogram>(); redHistogramMock.Setup(bh => bh.Smallest).Returns(red - PIXEL_TOLERANCE); redHistogramMock.Setup(bh => bh.Greatest).Returns(red + PIXEL_TOLERANCE); var leftColorMap = new ColorMap(blueHistogramMock.Object, greenHistogramMock.Object, redHistogramMock.Object); var rightColorMap = new ColorMap(blueHistogramMock.Object, greenHistogramMock.Object, redHistogramMock.Object); var handsColorMaps = new HandsColorMaps(leftColorMap, rightColorMap); var tuningMock = new Mock <IHandsDetectorTuning>(); tuningMock.Setup(t => t.HandsBackground).Returns(this.handsBackground); tuningMock.Setup(t => t.HandsForeground).Returns(this.handsForeground); tuningMock.Setup(t => t.HandsColorMaps).Returns(handsColorMaps); this.handsDetector = new SkinColorHandsDetector(); this.handsDetector.Tune(tuningMock.Object); }
/// <summary> /// Initializes a new instance of the <see cref="MainViewModel"/> class. /// </summary> public MainViewModel() { var handsAnalyzer = new HandsAnalyzer(); var skiColorHandDetector = new SkinColorHandsDetector(); var drone = new Tello(); var droneControllerKeyInputEvaluator = new TelloKeyInputEvaluator(); var droneControllerHandsInputEvaluator = new DroneControllerHandsInputEvaluator(); this.app = new CaduhdApp(handsAnalyzer, skiColorHandDetector, drone, droneControllerKeyInputEvaluator, droneControllerHandsInputEvaluator); this.app.Bind(this.UserInterfaceConnector); this.webCamera = new WebCamera(320, 180); this.webCamera.NewFrame += this.ProcessWebCameraFrame; this.webCamera.On(); this.keyEventProcessor = new KeyEventProcessor(); }