none
Can anyone help me with my code? it is about comparing the depth data in 1s. RRS feed

  • Question

  • I am working on a code which will compare the depth data in 1s. If the difference is larger than a certain limit, there will be a alarm. Right now, the problem is that it seems too sensitive even I make the threshold very large. I donot know why. Can anyone help? Thanks

           int i=0;
           short[] array1, array2;
            void sensor_DepthFrameReady(object sender, DepthImageFrameReadyEventArgs e)
            {
                int perPixelThreshold = 5 << DepthImageFrame.PlayerIndexBitmaskWidth;  // 5 mm
                int percentPixelLimit = 5;
                int changedPixelCount = 0;
                
                using (DepthImageFrame depthFrame = e.OpenDepthImageFrame())
                {
                    if (depthFrame == null)
                    {
                        return;
                    }
                    if (i == 0)
                    {
                        {
                            this.array1 = new short[depthFrame.PixelDataLength];
                            depthFrame.CopyPixelDataTo(this.array1);
                        }
                    }
                    else if (i == 30)
                    {
                            this.array2 = new short[depthFrame.PixelDataLength];
                            depthFrame.CopyPixelDataTo(this.array2);
                        }
                        i = 0;
                    }
                    if (array2 != null)
                    {
                        for (int j = 0; j < this.array2.Length; j++)
                        {
                            if (Math.Abs(array1[j] - array2[j]) > perPixelThreshold)
                            {
                                ++changedPixelCount;
                            }
                        }
                    }
                    if (changedPixelCount * 100 / depthFrame.PixelDataLength >= percentPixelLimit)
                    {
                        MessageBoxResult dres;
                        dres = MessageBox.Show("Attention! The patient may want to get up", "Warning", MessageBoxButton.OK);
                    }
                    i++;
                }
            }


    • Edited by ZDsam Tuesday, June 19, 2012 3:23 AM Change quesiton
    Tuesday, June 19, 2012 3:19 AM