你能在Kinect SDK(WPF,C#)中对深度帧进行边缘检测吗?

你能在Kinect SDK(WPF,C#)中对深度帧进行边缘检测吗?,c#,wpf,bitmap,kinect-sdk,edge-detection,C#,Wpf,Bitmap,Kinect Sdk,Edge Detection,我已经处理了深度帧到字节数组,这是用户的一种特殊颜色,否则为黑色。此字节数组(depthColorImage)使用以下代码转换为位图: public static Bitmap ToBitmap(this byte[] data, int width, int height, PixelFormat format) { var bitmap = new Bitmap(width, height, format); var bitma

我已经处理了深度帧到字节数组,这是用户的一种特殊颜色,否则为黑色。此字节数组(depthColorImage)使用以下代码转换为位图:

public static Bitmap ToBitmap(this byte[] data, int width, int height, PixelFormat format)
        {
            var bitmap = new Bitmap(width, height, format);
            var bitmapData = bitmap.LockBits(
            new System.Drawing.Rectangle(0, 0, bitmap.Width, bitmap.Height),
            ImageLockMode.WriteOnly,
            bitmap.PixelFormat);
            Marshal.Copy(data, 0, bitmapData.Scan0, data.Length);
            bitmap.UnlockBits(bitmapData);
            return bitmap;
        }
然后,我尝试使用找到的代码应用单矩阵卷积

我使用以下代码将生成的位图转换回bitmapsource:

public static Media.Imaging.BitmapSource ToBitmapSource(this Bitmap bitmap)
        {
            if (bitmap == null) return null;
            IntPtr ptr = bitmap.GetHbitmap();
            var source  =System.Windows.Interop.Imaging.CreateBitmapSourceFromHBitmap(
            ptr,
            IntPtr.Zero,
            Int32Rect.Empty,
            Media.Imaging.BitmapSizeOptions.FromEmptyOptions());
            DeleteObject(ptr);
            return source;
        }
最后,我尝试使用以下方法来显示:

this.depthImage.Source = depthColorImage.ToBitmap(depthFrame.Width, depthFrame.Height,PixelFormats.Bgr32).ConvolutionFilter().ToBitmapSource();
但是我的窗户挂着。如果我去掉卷积滤波器,它就可以正常工作。我是C#的初学者,我正在研究openCV,但我想知道我的代码是否有问题,或者是其他问题