I have two questions about MotionDetector.CreateMotionZonesFrame( ) method.
Here is the code:
- Code: Select all
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;
}
My first question is, Why do you use intersect method? - Because you want to handle the MotionRectangle and ImageRectangle at the corners?
My second question is, could you explain this part of your code?
- Code: Select all
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;
}
Thank you very much!
