/// <summary>
 /// Constructor.
 /// </summary>
 /// <param name="detectionResults">The detection results.</param>
 /// <param name="width">The width of the bitmap buffer that was used for detection in screen coordinates.</param>
 /// <param name="height">The height of the bitmap buffer that was used for detection in screen coordinates.</param>
 /// <param name="frameNumber">The frame number where the results where detected.</param>
 public MarkerDetectionEventArgs(DetectionResults detectionResults, int width, int height, long frameNumber)
 {
     this.DetectionResults = detectionResults;
     this.BufferWidth      = width;
     this.BufferHeight     = height;
     this.FrameNumber      = frameNumber;
 }
예제 #2
0
        /// <summary>
        /// Detects all markers in the buffer.
        /// </summary>
        /// <param name="buffer">The buffer which should be searched for markers.</param>
        /// <returns>The results of the detection.</returns>
        protected DetectionResults DetectAllMarkers(INyARRgbRaster buffer)
        {
            // Filter buffer
            if (!isAdaptive)
            {
                ((NyARRasterFilter_ARToolkitThreshold)this.bufferFilter).setThreshold(this.Threshold);
            }

            this.bufferFilter.doFilter(buffer, this.filteredBuffer);

            // Detect and return results
            this.squareDetectionListener.Reset();
            this.squareDetectionListener.Buffer = buffer;
            this.squareDetector.detectMarkerCB(this.filteredBuffer, squareDetectionListener);
            var results = this.squareDetectionListener.Results;

            // Prevent jittering
            if (previousResults != null && JitteringThreshold != 0)
            {
                var jitThresholdSq = JitteringThreshold * JitteringThreshold;
                var newResults     = new DetectionResults();
                foreach (var result in results)
                {
                    var previousResult = previousResults.FirstOrDefault(r => r.Marker == result.Marker);
                    if (previousResult == null)
                    {
                        newResults.Add(result);
                    }
                    else
                    {
                        var pcenter = previousResult.Square.Center;
                        var center  = result.Square.Center;
                        var dx      = pcenter.X - center.X;
                        var dy      = pcenter.X - center.X;
                        var lenSq   = dx * dx + dy * dy;

                        newResults.Add(lenSq > jitThresholdSq ? result : previousResult);
                    }
                }
                previousResults = newResults;
                return(newResults);
            }
            previousResults = results;

            return(results);
        }
 /// <summary>
 /// Resets the Results
 /// </summary>
 public void Reset()
 {
     this.Results = new DetectionResults();
 }