获取3帧后,Kinect 2流会卡住

时间:2015-08-07 20:14:34

标签: c# image kinect

我正在使用Kinect v2并且有一个只显示正文和颜色流的小程序,但是在获取3帧之后,流停止发送帧。这是代码:

_sensor = KinectSensor.GetDefault();

        if (_sensor != null)
        {
            _sensor.Open();

            _reader = _sensor.OpenMultiSourceFrameReader(FrameSourceTypes.Color | FrameSourceTypes.Depth | FrameSourceTypes.Infrared | FrameSourceTypes.Body);
            _reader.MultiSourceFrameArrived += Reader_MultiSourceFrameArrived;
        }

以下是我如何获取帧

Console.WriteLine("==== FRAME FOUND ====");
        var reference = e.FrameReference.AcquireFrame();
        // Body
        using (var frame = reference.ColorFrameReference.AcquireFrame())
        {
            if (frame != null)
            {
                //stream.Children.Clear();
                var c_frame = reference.ColorFrameReference.AcquireFrame();
                ImageBrush ib = new ImageBrush();
                Image im = new Image();
                rgb.Source = frame.ToBitmap();
                var b_frame = reference.BodyFrameReference.AcquireFrame();
                _bodies = new Body[b_frame.BodyFrameSource.BodyCount];
                b_frame.GetAndRefreshBodyData(_bodies);
                if (_bodies[0].IsTracked)
                {
                    stream.DrawSkeleton(_bodies[0]);
                    if (recording)
                    {
                        recorder.RecordFrame(_bodies[0]);
                    }
                }
                b_frame.GetAndRefreshBodyData(_bodies);
            }
        }

1 个答案:

答案 0 :(得分:0)

最有可能的构建目标设置为32位CPU。将其设置为64位。