コード例 #1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CannyEdgeDetector"/> class.
 /// </summary>
 ///
 public CannyEdgeDetector(float gaussianSigma = GaussianBlurProcessor.DefaultSigma, int?gaussianRadius = null)
 {
     if (gaussianRadius.NotNull())
     {
         this.gaussianFilter = new GaussianBlurProcessor(gaussianSigma, gaussianRadius.Value);
     }
     else
     {
         this.gaussianFilter = new GaussianBlurProcessor(gaussianSigma);
     }
 }
コード例 #2
0
        protected void AverageAndBlurPixels(int[] depthFrameDataInt, ref double[] averagedDepthFrameData)
        {
            // Average across multiple frames
            for (var pixel = 0; pixel < depthFrameDataInt.Length; pixel++)
            {
                if (depthFrameDataInt[pixel] > 200) // We have a valid pixel.
                {
                    runningSum[pixel] += depthFrameDataInt[pixel];
                }
                else
                {
                    if (pixel > 0) // Pixel is invalid and we have a neighbor to steal information from
                    {
                        runningSum[pixel] += depthFrameDataInt[pixel - 1];
                        // Replace the zero value from the depth array with the one from the neighboring pixel
                        renderBuffer.Last.Value[pixel] = depthFrameDataInt[pixel - 1];
                    }
                    else // Pixel is invalid and it is the first one in the list. (No neighbor on the left hand side, so we set it to the lowest point on the table)
                    {
                        runningSum[pixel] += (int)sensorElevation;
                        renderBuffer.Last.Value[pixel] = (int)sensorElevation;
                    }
                }

                averagedDepthFrameData[pixel] = runningSum[pixel] / renderBuffer.Count; // Calculate average values
                if (elevationArray.Length > 0)
                {
                    averagedDepthFrameData[pixel] -= elevationArray[pixel];                            // Correct for Kinect's inacurracies using input from the calibration component
                }
                if (renderBuffer.Count >= averageFrames)
                {
                    runningSum[pixel] -= renderBuffer.First.Value[pixel]; // Subtract the oldest value from the sum
                }
            }

            Core.LogTiming(ref output, timer, "Frames averaging"); // Debug Info

            if (blurRadius > 1)                                    // Apply gaussian blur
            {
                var gaussianBlurProcessor = new GaussianBlurProcessor(blurRadius, trimmedWidth, trimmedHeight);
                gaussianBlurProcessor.Apply(averagedDepthFrameData);
                Core.LogTiming(ref output, timer, "Gaussian blurring"); // Debug Info
            }
        }