Capture moving objects using OpenCV

RAJESH KUMAR
2 min readMar 1, 2019

--

With the advent of a camera, capturing an image is really easy today but as the camera technology evolves people thought about to get a context about the image and finding the objects inside that image. So, if you have ever given a thought about ‘Can we get identify or capture moving objects’ boundaries in the image or video?’ then this blog is for you.

OpenCV (Open Source Computer Vision) is an open source library to get insights for the given image or video. Background subtraction is a major part of any vision-based applications. There are two most popular algorithms you can use to get the Background subtractor frame in OpenCV, MOG2 or KNN.

The basics behind these algorithms how they work, you can get it from the below image:

Source: https://docs.opencv.org/3.4/Background_Subtraction_Tutorial_Scheme.png

If you want to get in-depth knowledge I highly recommend you to visit https://docs.opencv.org/3.4/d1/dc5/tutorial_background_subtraction.html

Below examples will give you more understanding:

I’ve run the MOG2 algorithm on my webcam feed and below is what I got. You can check the GitHub link for the code, it’s very simple and easy to use.

Output:

--

--