public void StartDisplay(TravelOffer lastTravel) { _currentOffer = lastTravel; try { InitializeComponent(); InitList(); var helper = KinectHelper.Instance; helper.ReadyEvent += (s, _) => HelperReady(); GreenScreen.Start(helper.Sensor, false); SetNewHat(); Accessories.Start(helper.Sensor); RectNavigationControl.Start(helper.Sensor); RectNavigationControl.SwipeLeftEvent += SwipeLeft; RectNavigationControl.SwipeRightEvent += SwipeRight; RectNavigationControl.SwipeUpEvent += SwipeUp; RectNavigationControl.SwipeDownEvent += SwipeDown; RectNavigationControl.NoSwipe += NoSwipe; string[] texts = MyTextLoopList.GetNeighbourTexts(); RectNavigationControl.SetTopText(texts[0]); RectNavigationControl.SetBottomText(texts[1]); InitGenderDetection(); } catch (Exception exc) { ExceptionTextBlock.Text = exc.Message + "\r\n" + exc.InnerException + "\r\n" + exc.StackTrace; } }
/* * Event */ private void HelperReady() { helper = KinectHelper.Instance; skeleton = helper.GetFixedSkeleton(); GreenScreen.RenderImageData(helper.DepthImagePixels, helper.ColorPixels); Accessories.SetSkeletons(helper.Skeletons); KinectHelper.Instance.SetTransform(GreenScreen); KinectHelper.Instance.SetTransform(Accessories); }
private void StartGreenScreenAndHat() { var helper = KinectHelper.Instance; GreenScreen.Start(helper.Sensor, false);// TODO wieder auf true sonst kein antialiasing Accessories.AccessoryItems.Clear(); AccessoryItem hat = new AccessoryItem(AccessoryPositon.Hat, _currentOffer.Category.CategoryId, false); Accessories.AccessoryItems.Add(hat); Accessories.Start(helper.Sensor); helper.ReadyEvent += (s, _) => HelperReady(); }
private void GreenControlMode_Click(object sender, RoutedEventArgs e) { if (greenType == GreenScreen.Local) { GreenControlMode.Content = "G Mode: System"; greenType = GreenScreen.System; } else { GreenControlMode.Content = "G Mode: Local"; greenType = GreenScreen.Local; } }
/*Callback fur ein fertiges Frame vom Kinect-Sensor*/ private void HelperReady() { var helper = KinectHelper.Instance; Skeleton skeleton = helper.GetFixedSkeleton(); if (skeleton != null) { RectNavigationControl.GestureRecognition(skeleton); } GreenScreen.RenderImageData(helper.DepthImagePixels, helper.ColorPixels); SetAccessoriesNew(helper); KinectHelper.Instance.SetTransform(GreenScreen); KinectHelper.Instance.SetTransform(Accessories); KinectHelper.Instance.SetTransform(RectNavigationControl); }
/// <summary> /// Event handler for Kinect sensor's DepthFrameReady event /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void SensorAllFramesReady(object sender, AllFramesReadyEventArgs e) { // in the middle of shutting down, so nothing to do if (null == this.sensor) { return; } bool depthReceived = false; bool colorReceived = false; using (DepthImageFrame depthFrame = e.OpenDepthImageFrame()) { if (null != depthFrame) { // Copy the pixel data from the image to a temporary array depthFrame.CopyDepthImagePixelDataTo(this.depthPixels); depthReceived = true; } } using (ColorImageFrame colorFrame = e.OpenColorImageFrame()) { if (null != colorFrame) { // Copy the pixel data from the image to a temporary array colorFrame.CopyPixelDataTo(this.colorPixels); colorReceived = true; } } // do our processing outside of the using block // so that we return resources to the kinect as soon as possible // do our processing outside of the using block // so that we return resources to the kinect as soon as possible if (depthReceived && colorReceived) { GreenScreen.RenderImageData(depthPixels, colorPixels); } }
/// <summary> /// Execute startup tasks /// </summary> /// <param name="sender">object sending the event</param> /// <param name="e">event arguments</param> private void WindowLoaded(object sender, RoutedEventArgs e) { // Look through all sensors and start the first connected one. // This requires that a Kinect is connected at the time of app startup. // To make your app robust against plug/unplug, // it is recommended to use KinectSensorChooser provided in Microsoft.Kinect.Toolkit foreach (var potentialSensor in KinectSensor.KinectSensors) { if (potentialSensor.Status == KinectStatus.Connected) { this.sensor = potentialSensor; break; } } if (null != this.sensor) { // Turn on the depth stream to receive depth frames this.sensor.DepthStream.Enable(DepthFormat); this.depthWidth = this.sensor.DepthStream.FrameWidth; this.depthHeight = this.sensor.DepthStream.FrameHeight; this.sensor.ColorStream.Enable(ColorFormat); int colorWidth = this.sensor.ColorStream.FrameWidth; int colorHeight = this.sensor.ColorStream.FrameHeight; this.colorToDepthDivisor = colorWidth / this.depthWidth; // Turn on to get player masks this.sensor.SkeletonStream.Enable(); // Allocate space to put the depth pixels we'll receive this.depthPixels = new DepthImagePixel[this.sensor.DepthStream.FramePixelDataLength]; // Allocate space to put the color pixels we'll create this.colorPixels = new byte[this.sensor.ColorStream.FramePixelDataLength]; this.greenScreenPixelData = new int[this.sensor.DepthStream.FramePixelDataLength]; this.colorCoordinates = new ColorImagePoint[this.sensor.DepthStream.FramePixelDataLength]; // This is the bitmap we'll display on-screen this.colorBitmap = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgr32, null); // Set the image we display to point to the bitmap where we'll put the image data //this.MaskedColor.Source = this.colorBitmap; // Add an event handler to be called whenever there is new depth frame data this.sensor.AllFramesReady += this.SensorAllFramesReady; GreenScreen.Start(sensor, false); // Start the sensor! try { this.sensor.Start(); } catch (IOException) { this.sensor = null; Console.WriteLine("Error Antialiasing"); } } if (null == this.sensor) { this.statusBarText.Text = Properties.Resources.NoKinectReady; } }