/// <summary> /// 初始化多重幀數 /// </summary> private void InitializeMultiSourceFrameReader() { //MultiSourceFrameReader and event _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.BodyIndex); _reader.MultiSourceFrameArrived += _reader_MultiSourceFrameArrived; //Initialize the background removal tool. _backgroundRemovalTool = new BackgroundRemovalTool(_sensor.CoordinateMapper); }
public BackgroundRemovalPage() { InitializeComponent(); _navigationHelper = new NavigationHelper(this); _sensor = KinectSensor.GetDefault(); if (_sensor != null) { _sensor.Open(); _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body | FrameSourceTypes.BodyIndex); _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; _backgroundRemoval = new BackgroundRemovalTool(_sensor.CoordinateMapper); } }
private void StartNonTraceableMode() { SetUIInNoTrackableMode(); _sensor = KinectSensor.GetDefault(); //todo - check, not working if (_sensor != null) { _sensor.Open(); // 2) Initialize the background removal tool. _backgroundRemovalTool = new BackgroundRemovalTool(_sensor.CoordinateMapper); _drawSkeleton = new DrawSkeleton(_sensor, (int)(KinectSkeleton.Width), (int)(KinectSkeleton.Height)); _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.BodyIndex | FrameSourceTypes.Body); _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived_NonTraceable; } }
private void StartTraceableMode() { SetUIInTrackingMode(); //ExerciseVideo.Play(); _sensor = KinectSensor.GetDefault(); //todo - check, not working if (_sensor != null) { _sensor.Open(); // 2) Initialize the background removal tool. _backgroundRemovalTool = new BackgroundRemovalTool(_sensor.CoordinateMapper); _drawSkeleton = new DrawSkeleton(_sensor, (int)(KinectSkeleton.Width), (int)(KinectSkeleton.Height)); _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.BodyIndex | FrameSourceTypes.Body); _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; //Gesture detection Exercise tempExercise = CurrentExercise; _gestureAnalysis = new GestureAnalysis(ref tempExercise); _gestureDetector = new GestureDetector(_sensor, _gestureAnalysis, CurrentExercise); _gestureAnalysis.startGestureDeteced += _gestureAnalysis_startGestureDeteced; CurrentExercise.CreateRounds(); //_timer.Start(); } ExerciseVideo.Play(); inPlayMode = true; }
private void Window_Loaded(object sender, RoutedEventArgs e) { //獲取感測器資料 _sensor = KinectSensor.GetDefault(); if (_sensor != null) { //_sensor.Open(); //姿勢事件 poseture.Poseture_List += Poseture_result; // 2) Initialize the background removal tool. _backgroundRemovalTool = new BackgroundRemovalTool(_sensor.CoordinateMapper); //MultiSourceFrameReader and event _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.BodyIndex); _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived; //骨架、骨架事件 bodyFrameReader = _sensor.BodyFrameSource.OpenReader(); bodyFrameReader.FrameArrived += BodyFrameReader_FrameArrived; _faceSource = new FaceFrameSource(_sensor, 0, FaceFrameFeatures.BoundingBoxInColorSpace | FaceFrameFeatures.FaceEngagement | FaceFrameFeatures.Glasses | FaceFrameFeatures.Happy | FaceFrameFeatures.LeftEyeClosed | FaceFrameFeatures.MouthOpen | FaceFrameFeatures.PointsInColorSpace | FaceFrameFeatures.RightEyeClosed); // Open face Reader and build face event _faceReader = _faceSource.OpenReader(); _faceReader.FrameArrived += _faceReader_FrameArrived; } }
/// <summary> /// Initializes a new instance of the MainWindow class. /// </summary> public MainWindow() { this.kinectSensor = KinectSensor.GetDefault(); this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.BodyIndex | FrameSourceTypes.Body); this.multiFrameSourceReader.MultiSourceFrameArrived += this.Reader_MultiSourceFrameArrived; this.coordinateMapper = this.kinectSensor.CoordinateMapper; FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription; int depthWidth = depthFrameDescription.Width; int depthHeight = depthFrameDescription.Height; FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription; int colorWidth = colorFrameDescription.Width; int colorHeight = colorFrameDescription.Height; this.colorMappedToDepthPoints = new DepthSpacePoint[colorWidth * colorHeight]; this.bitmap = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null); this.capturedBackground = new WriteableBitmap(colorWidth, colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null); // Calculate the WriteableBitmap back buffer size this.bitmapBackBufferSize = (uint)((this.bitmap.BackBufferStride * (this.bitmap.PixelHeight - 1)) + (this.bitmap.PixelWidth * this.bytesPerPixel)); this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged; this.kinectSensor.Open(); this.StatusText = this.kinectSensor.IsAvailable ? Properties.Resources.RunningStatusText : Properties.Resources.NoSensorStatusText; this.DataContext = this; this.InitializeComponent(); this.morphingEngine = new ClassIMFD(); this.dispatcherTimer = new DispatcherTimer(); this.dispatcherTimer.Tick += new EventHandler(dispatcherTimer_Tick); this.dispatcherTimer.Interval = new TimeSpan(0, 0, 5); KinectRegion.SetKinectRegion(this, kinectRegion); App app = ((App)Application.Current); app.KinectRegion = kinectRegion; // Use the default sensor this.kinectRegion.KinectSensor = KinectSensor.GetDefault(); this.sceneObject = new string[2, 4] { { "\\Images\\BackgroundLion.png", "\\Images\\GestureLion.png", "Images\\Lion.png", "\\Images\\Lion2.png" }, { "\\Images\\BackgroundAngryBird.png", "\\Images\\GestureAngryBird.png", "Images\\AngryBird.png", "\\Images\\AngryBird.gif" } }; this.stickerObject = new string[4] { "\\Images\\Sticker1.gif", "\\Images\\Sticker2.gif", "\\Images\\Sticker3.gif", "\\Images\\Sticker4.gif" }; this._backgroundRemovalTool = new BackgroundRemovalTool(this.kinectSensor.CoordinateMapper); this._gestureController = new GestureController(); this._gestureController.GestureRecognized += GestureController_GestureRecognized; UpdateBackground(); }