Я использую AForge для обнаружения движения и знаю, что области движения можно установить.Можно ли сделать так, чтобы это срабатывало только при наличии движений в ВСЕХ определенных областей ?Если вышеупомянутая функциональность недоступна, я подумываю о ее написании.
В настоящее время мое понимание состоит в том, что для регионов задано значение zoneFrame в MotionDetector.cs в Vision Library.Я думаю сделать это для каждого региона, но это кажется неэффективным.
Какой самый эффективный способ сделать это?
Может кто-нибудь объяснить, пожалуйста, код ниже?
private unsafe void CreateMotionZonesFrame( )
{
lock ( this )
{
// 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 )
{
//Please explain here
rect.Intersect( imageRect );
// rectangle's dimenstion
int rectWidth = rect.Width;
int rectHeight = rect.Height;
// start pointer
//Please explain here
int stride = zonesFrame.Stride;
//Please explain here
byte* ptr = (byte*) zonesFrame.ImageData.ToPointer( ) + rect.Y * stride + rect.X;
for ( int y = 0; y < rectHeight; y++ )
{
//Please explain here
AForge.SystemTools.SetUnmanagedMemory( ptr, 255, rectWidth );
ptr += stride;
}
}
}
}
}