public unsafe void ProcessFrame( UnmanagedImage videoFrame, UnmanagedImage motionFrame )
{
if ( motionFrame.PixelFormat != PixelFormat.Format8bppIndexed )
{
throw new InvalidImagePropertiesException( "Motion frame must be 8 bpp image." );
}
if ( ( videoFrame.PixelFormat != PixelFormat.Format8bppIndexed ) &&
( videoFrame.PixelFormat != PixelFormat.Format24bppRgb ) &&
( videoFrame.PixelFormat != PixelFormat.Format32bppRgb ) &&
( videoFrame.PixelFormat != PixelFormat.Format32bppArgb ) )
{
throw new UnsupportedImageFormatException( "Video frame must be 8 bpp grayscale image or 24/32 bpp color image." );
}
int width = videoFrame.Width;
int height = videoFrame.Height;
if ( ( motionFrame.Width != width ) || ( motionFrame.Height != height ) )
return;
lock ( blobCounter )
{
blobCounter.ProcessImage( motionFrame );
}
if ( highlightMotionRegions )
{
// highlight each moving object
Rectangle[] rects = blobCounter.GetObjectsRectangles( );
foreach ( Rectangle rect in rects )
{
Drawing.Rectangle( videoFrame, rect, highlightColor );
}
}
}