コード例 #1
0
        public MainWindow()
        {
            MachineName = Environment.MachineName;

            _lastSent = DateTime.Now;

            __listLock__ = new object();

            this.kinectSensor = KinectSensor.GetDefault();

            this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.Body | FrameSourceTypes.BodyIndex);

            this.multiFrameSourceReader.MultiSourceFrameArrived += MultiFrameSourceReader_MultiSourceFrameArrived;

            this.coordinateMapper = this.kinectSensor.CoordinateMapper;

            FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;

            int depthWidth  = depthFrameDescription.Width;
            int depthHeight = depthFrameDescription.Height;

            this.depthFrameData     = new ushort[depthWidth * depthHeight];
            this.bodyIndexFrameData = new byte[depthWidth * depthHeight];
            this.colorPoints        = new ColorSpacePoint[depthWidth * depthHeight];
            this.cameraPoints       = new CameraSpacePoint[depthWidth * depthHeight];

            FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;

            int colorWidth  = colorFrameDescription.Width;
            int colorHeight = colorFrameDescription.Height;

            this.colorFrameData = new byte[colorWidth * colorHeight * this.bytesPerPixel];
            this.displayFrame   = new byte[depthWidth * depthHeight * this.bytesPerPixel];

            this.colorBitmap = new WriteableBitmap(depthWidth, depthHeight, 96.0, 96.0, PixelFormats.Bgr32, null);

            pointsToDepth = new List <Vector3>();
            surfacePoints = new List <CameraSpacePoint>();


            this.InitializeComponent();

            _configFile = new ConfigFile();
            _loadConfig(_configFile);

            _tcp = new TcpSender();

            _frameCounter = new FrameCounter();
            _frameCounter.PropertyChanged += (o, e) => this.StatusText = String.Format("FPS = {0:N1} / CPU = {1:N6}; Streaming = {2}", _frameCounter.FramesPerSecond, _frameCounter.CpuTimePerFrame, _tcp.Connected ? "Connected" : "Not Connected");


            this.kinectSensor.Open();
            this.DataContext = this;

            _connectionLine = null;
            _drawConnectionLine();
        }
コード例 #2
0
        public MainWindow()
        {
            MachineName = Environment.MachineName;

            this.kinectSensor = KinectSensor.GetDefault();

            this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.Body | FrameSourceTypes.BodyIndex);

            this.multiFrameSourceReader.MultiSourceFrameArrived += MultiFrameSourceReader_MultiSourceFrameArrived;

            this.coordinateMapper = this.kinectSensor.CoordinateMapper;

            FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;

            int depthWidth  = depthFrameDescription.Width;
            int depthHeight = depthFrameDescription.Height;

            this.depthFrameData     = new ushort[depthWidth * depthHeight];
            this.bodyIndexFrameData = new byte[depthWidth * depthHeight];
            this.colorPoints        = new ColorSpacePoint[depthWidth * depthHeight];
            this.cameraPoints       = new CameraSpacePoint[depthWidth * depthHeight];

            FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;

            int colorWidth  = colorFrameDescription.Width;
            int colorHeight = colorFrameDescription.Height;

            Console.WriteLine(depthWidth + "x" + depthHeight);

            this.colorFrameData = new byte[colorWidth * colorHeight * this.bytesPerPixel];
            this.displayFrame   = new byte[depthWidth * depthHeight * this.bytesPerPixel];

            this.colorBitmap = new WriteableBitmap(depthWidth, depthHeight, 96.0, 96.0, PixelFormats.Bgr32, null);

            pointsToDepth = new List <Vector3>();
            surfacePoints = new List <CameraSpacePoint>();

            surfaceFile = new SurfaceFile("rectangle.txt");

            _frameCounter = new FrameCounter();
            _frameCounter.PropertyChanged += (o, e) => this.StatusText = String.Format("FPS = {0:N1} / CPU = {1:N6} / " + _notificationText, _frameCounter.FramesPerSecond, _frameCounter.CpuTimePerFrame);



            this.kinectSensor.Open();
            this.DataContext = this;
            this.InitializeComponent();

            SaveSurfaceMenuItem.IsEnabled = false;
        }
コード例 #3
0
        public MainWindow()
        {
            _configFile = new ConfigFile();
            _loadConfig();

            _frameCounter = new FrameCounter();
            _frameCounter.PropertyChanged += (o, e) => this.StatusText = String.Format("FPS = {0:N1} / CPU = {1:N6}", _frameCounter.FramesPerSecond, _frameCounter.CpuTimePerFrame);

            this.kinectSensor = KinectSensor.GetDefault();

            this.coordinateMapper = this.kinectSensor.CoordinateMapper;
            _pointsToDepth        = new List <Point>();
            _calibrationPoints    = new List <CameraSpacePoint>();

            this.multiFrameSourceReader = this.kinectSensor.OpenMultiSourceFrameReader(FrameSourceTypes.Depth | FrameSourceTypes.Color | FrameSourceTypes.Body | FrameSourceTypes.BodyIndex);
            this.multiFrameSourceReader.MultiSourceFrameArrived += this.Reader_MultiSourceFrameArrived;

            FrameDescription depthFrameDescription = this.kinectSensor.DepthFrameSource.FrameDescription;
            int depthWidth  = depthFrameDescription.Width;
            int depthHeight = depthFrameDescription.Height;

            this._depthFrameData    = new ushort[depthWidth * depthHeight];
            this._colorSpacePoints  = new ColorSpacePoint[depthWidth * depthHeight];
            this._cameraPoints      = new CameraSpacePoint[depthWidth * depthHeight];
            this.bodyIndexFrameData = new byte[depthWidth * depthHeight];

            FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.CreateFrameDescription(ColorImageFormat.Bgra);
            //FrameDescription colorFrameDescription = this.kinectSensor.ColorFrameSource.FrameDescription;
            int colorWidth  = colorFrameDescription.Width;
            int colorHeight = colorFrameDescription.Height;

            _colorFrameData = new byte[colorWidth * colorHeight * this.bytesPerPixel];
            _displayFrame   = new byte[colorWidth * colorHeight * this.bytesPerPixel];

            this.colorBitmap = new WriteableBitmap(colorFrameDescription.Width, colorFrameDescription.Height, 96.0, 96.0, PixelFormats.Bgr32, null);

            this.kinectSensor.IsAvailableChanged += this.Sensor_IsAvailableChanged;

            this.kinectSensor.Open();
            this.DataContext = this;
            this.InitializeComponent();
        }
コード例 #4
0
 internal CpuCounter(FrameCounter parent)
 {
     _parent    = parent;
     _stopWatch = new Stopwatch();
 }