O'Reilly logo

Hands-On Machine Learning with C# by Matt R. Cole

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Adding detection to your application

Here's a simple example of all you need to do to add video recognition to your application. As you can see, it couldn't be any easier!

// create motion detectorMotionDetector detector = new MotionDetector(  new SimpleBackgroundModelingDetector(),  new MotionAreaHighlighting());// continuously feed video frames to motion detectorwhile (){  // process new video frame and check motion level  if (detector.ProcessFrame(videoFrame) > 0.02)  {   // ring alarm or do somethng else  }}Opening our video sourcevideoSourcePlayer.VideoSource = new AsyncVideoSource(source);

When we receive a new video frame, that's when all the magic happens. Here's all the code it takes to make processing a new video frame a success:

private ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required