AForge.Vision.Motion.MotionDetector.CreateMotionZonesFrame C# (CSharp) Méthode

CreateMotionZonesFrame() private méthode

private CreateMotionZonesFrame ( ) : void
Résultat void
        private unsafe void CreateMotionZonesFrame( )
        {
            lock ( sync )
            {
                // free previous motion zones frame
                if ( zonesFrame != null )
                {
                    zonesFrame.Dispose( );
                    zonesFrame = null;
                }

                // create motion zones frame only in the case if the algorithm has processed at least one frame
                if ( ( motionZones != null ) && ( motionZones.Length != 0 ) && ( videoWidth != 0 ) )
                {
                    zonesFrame = UnmanagedImage.Create( videoWidth, videoHeight, PixelFormat.Format8bppIndexed );

                    Rectangle imageRect = new Rectangle( 0, 0, videoWidth, videoHeight );

                    // draw all motion zones on motion frame
                    foreach ( Rectangle rect in motionZones )
                    {
                        rect.Intersect( imageRect );

                        // rectangle's dimenstion
                        int rectWidth  = rect.Width;
                        int rectHeight = rect.Height;

                        // start pointer
                        int stride = zonesFrame.Stride;
                        byte* ptr = (byte*) zonesFrame.ImageData.ToPointer( ) + rect.Y * stride + rect.X;

                        for ( int y = 0; y < rectHeight; y++ )
                        {
                            AForge.SystemTools.SetUnmanagedMemory( ptr, 255, rectWidth );
                            ptr += stride;
                        }
                    }
                }
            }
        }
    }