Exemple #1
0
        public RecordWindow()
        {
            // 基本設定の初期化処理

            // Kinect関連初期化処理
            this.kinectSensor           = KinectSensor.GetDefault();
            this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.Body | FrameSourceTypes.BodyIndex);
            this.coordinateMapper       = this.kinectSensor.CoordinateMapper;

            FrameDescription deapthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
            FrameDescription colorFrameDescription  = this.kinectSensor.ColorFrameSource.FrameDescription;

            this.depthWidth  = deapthFrameDescription.Width;
            this.depthHeight = deapthFrameDescription.Height;
            this.colorWidth  = colorFrameDescription.Width;
            this.colorHeight = colorFrameDescription.Height;

            this.motionDataHandler = new MotionDataHandler(this.recordPath, this.colorWidth, this.colorHeight, this.depthWidth, this.depthHeight);

            // 描画関連
            this.drawingGroup = new DrawingGroup();
            this.imageSource  = new DrawingImage(this.drawingGroup);
            this.colorBitmap  = new WriteableBitmap(this.colorWidth, this.colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null);

            // allocate space to put the pixels being received
            this.colorPixels     = new byte[this.colorWidth * this.colorHeight * this.bytesPerPixel];
            this.depthBuffer     = new ushort[this.depthWidth * this.depthHeight];
            this.bodyIndexBuffer = new byte[this.depthWidth * this.depthHeight];

            // a bone defined as a line between two joints
            this.bones = Utility.GetBones();

            // populate body colors, one for each BodyIndex
            this.bodyColors = new List <Pen>();
            this.bodyColors.Add(new Pen(Brushes.Red, 6));
            this.bodyColors.Add(new Pen(Brushes.Orange, 6));
            this.bodyColors.Add(new Pen(Brushes.Green, 6));
            this.bodyColors.Add(new Pen(Brushes.Blue, 6));
            this.bodyColors.Add(new Pen(Brushes.Indigo, 6));
            this.bodyColors.Add(new Pen(Brushes.Violet, 6));

            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;
            this.kinectSensor.Open();

            this.DataContext = this;

            this.InitializeComponent();
        }
Exemple #2
0
 bool openMotionData(out MotionDataHandler handler, out string path)
 {
     handler = null;
     path    = null;
     _dialogOpenTrackImage.SelectedPath = Properties.Settings.Default.InitialRecordPath;
     if (_dialogOpenTrackImage.ShowDialog() != System.Windows.Forms.DialogResult.OK)
     {
         return(false);
     }
     Properties.Settings.Default.InitialRecordPath = _dialogOpenTrackImage.SelectedPath;
     Properties.Settings.Default.Save();
     try
     {
         handler = new MotionDataHandler(_dialogOpenTrackImage.SelectedPath);
         path    = _dialogOpenTrackImage.SelectedPath;
     }
     catch (NotImplementedException ex)
     {
         System.Windows.MessageBox.Show(ex.Message, ex.GetType().Name);
         return(false);
     }
     return(true);
 }
 bool openMotionData(out MotionDataHandler handler, out string path)
 {
     handler = null;
     path = null;
     _dialogOpenTrackImage.SelectedPath = Properties.Settings.Default.InitialRecordPath;
     if (_dialogOpenTrackImage.ShowDialog() != System.Windows.Forms.DialogResult.OK)
         return false;
     Properties.Settings.Default.InitialRecordPath = _dialogOpenTrackImage.SelectedPath;
     Properties.Settings.Default.Save();
     try
     {
         handler = new MotionDataHandler(_dialogOpenTrackImage.SelectedPath);
         path = _dialogOpenTrackImage.SelectedPath;
     }
     catch (NotImplementedException ex)
     {
         System.Windows.MessageBox.Show(ex.Message, ex.GetType().Name);
         return false;
     }
     return true;
 }
        public RecordWindow()
        {
            // 基本設定の初期化処理

            // Kinect関連初期化処理
            this.kinectSensor = KinectSensor.GetDefault();
            this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.Body | FrameSourceTypes.BodyIndex);
            this.coordinateMapper = this.kinectSensor.CoordinateMapper;

            FrameDescription deapthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
            FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;

            this.depthWidth = deapthFrameDescription.Width;
            this.depthHeight = deapthFrameDescription.Height;
            this.colorWidth = colorFrameDescription.Width;
            this.colorHeight = colorFrameDescription.Height;

            this.motionDataHandler = new MotionDataHandler(this.recordPath , this.colorWidth, this.colorHeight, this.depthWidth, this.depthHeight);            

            // 描画関連
            this.drawingGroup = new DrawingGroup();
            this.imageSource = new DrawingImage(this.drawingGroup);
            this.colorBitmap = new WriteableBitmap(this.colorWidth, this.colorHeight, 96.0, 96.0, PixelFormats.Bgra32, null);

            // allocate space to put the pixels being received
            this.colorPixels = new byte[this.colorWidth * this.colorHeight * this.bytesPerPixel];
            this.depthBuffer = new ushort[this.depthWidth * this.depthHeight];
            this.bodyIndexBuffer = new byte[this.depthWidth * this.depthHeight];

            // a bone defined as a line between two joints
            this.bones = Utility.GetBones();

            // populate body colors, one for each BodyIndex
            this.bodyColors = new List<Pen>();
            this.bodyColors.Add(new Pen(Brushes.Red, 6));
            this.bodyColors.Add(new Pen(Brushes.Orange, 6));
            this.bodyColors.Add(new Pen(Brushes.Green, 6));
            this.bodyColors.Add(new Pen(Brushes.Blue, 6));
            this.bodyColors.Add(new Pen(Brushes.Indigo, 6));
            this.bodyColors.Add(new Pen(Brushes.Violet, 6));

            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;
            this.kinectSensor.Open();

            this.DataContext = this;

            this.InitializeComponent();
        }