Ejemplo n.º 1
0
        /// <summary>
        /// Highlights a motion detection cell, typically to indicate a threshold was tripped.
        /// </summary>
        /// <param name="r">Red channel of the highlight RGB color</param>
        /// <param name="g">Green channel of the highlight RGB color</param>
        /// <param name="b">Blue channel of the highlight RGB color</param>
        /// <param name="driver">The <see cref="FrameDiffDriver"/> containing the buffer</param>
        /// <param name="metadata">The <see cref="FrameAnalysisMetadata"/> structure with frame properties</param>
        /// <param name="index">The array index of the cell to highlight</param>
        /// <param name="buffer">The frame buffer to draw into</param>
        protected void HighlightCell(byte r, byte g, byte b, FrameDiffDriver driver, FrameAnalysisMetadata metadata, int index, byte[] buffer)
        {
            for (int x = driver.CellRect[index].X; x < driver.CellRect[index].X + driver.CellRect[index].Width; x++)
            {
                var y = driver.CellRect[index].Y;
                var i = (x * metadata.Bpp) + (y * metadata.Stride);
                buffer[i]     = r;
                buffer[i + 1] = g;
                buffer[i + 2] = b;
                y            += driver.CellRect[index].Height - 1;
                i             = (x * metadata.Bpp) + (y * metadata.Stride);
                buffer[i]     = r;
                buffer[i + 1] = g;
                buffer[i + 2] = b;
            }

            for (int y = driver.CellRect[index].Y; y < driver.CellRect[index].Y + driver.CellRect[index].Height; y++)
            {
                var x = driver.CellRect[index].X;
                var i = (x * metadata.Bpp) + (y * metadata.Stride);
                buffer[i]     = r;
                buffer[i + 1] = g;
                buffer[i + 2] = b;
                x            += driver.CellRect[index].Width - 1;
                i             = (x * metadata.Bpp) + (y * metadata.Stride);
                buffer[i]     = r;
                buffer[i + 1] = g;
                buffer[i + 2] = b;
            }
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Creates a new <see cref="FrameBufferCaptureHandler"/> configured for motion detection analysis (either using a recorded
 /// raw video stream where MMALStandalone.Instance is used, or when the camera is used but triggering motion detection events
 /// is unnecessary). If motion detection events are desired, use the camera's WithMotionDetection method.
 /// </summary>
 /// <param name="motionConfig">The motion configuration.</param>
 /// <param name="onDetect">A callback for when motion is detected.</param>
 public FrameBufferCaptureHandler(MotionConfig motionConfig, Action onDetect)
     : base()
 {
     _driver          = new FrameDiffDriver(motionConfig, onDetect);
     _detectingMotion = true;
 }
Ejemplo n.º 3
0
 /// <inheritdoc />
 public void ConfigureMotionDetection(MotionConfig config, Action onDetect)
 {
     _driver = new FrameDiffDriver(config, onDetect);
     this.EnableMotionDetection();
 }