0
我想使用AForge.NET框架来设置motiondetection。我正在使用this页面上提供的信息。如何使用AForge设置动作检测?
我已经设置了一个DirectShow videostream,它通过一个流提供我的桌面的一部分。我可以在随AForge一起提供的示例视频播放器项目中选择此流。 (我通过播放器看到我的桌面)。
但是,当我运行下面的代码时,我收到一个NullReferenceException。我错过了什么?
// New frame received by the player
private void videoSourcePlayer_NewFrame(object sender, ref Bitmap image)
{
if (this.detector.ProcessFrame(image) > 0.02)
{
Console.WriteLine("Motion");
}
else
{
Console.WriteLine("No motion");
}
}
的detector
选择一个视频流时被初始化为私有类变量。
private MotionDetector detector;
private BlobCountingObjectsProcessing motionProcessor;
// Open video source
private void OpenVideoSource(IVideoSource source)
{
BlobCountingObjectsProcessing motionProcessor = new BlobCountingObjectsProcessing();
MotionDetector detector = new MotionDetector(
new SimpleBackgroundModelingDetector(),
motionProcessor);
}
正确:)。我习惯了VB,愚蠢的错误哈哈 – Ropstah 2009-12-21 18:18:09