1
동작 감지에 AForge를 사용하고 있으며 동작 영역을 설정할 수 있음을 알고 있습니다. 움직임이있는 경우에만 트리거하도록 할 수 있습니까? 정의 된 모든 영역? 위의 기능을 쉽게 사용할 수없는 경우 필자는이를 작성하려고 생각하고 있습니다.Aforge.Net의 동작 감지 영역
현재 비전 라이브러리의 MotionDetector.cs에서 region이 zoneFrame으로 설정되어 있습니다. 나는 각 지역을 위해 이것을하는 것을 생각하고있다. 그러나 그것은 효율적이 아닌 것처럼 보인다.
가장 효율적인 방법은 무엇입니까?
누군가 나에게 아래 코드를 설명해 주시겠습니까?
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;
}
}
}
}
}