Frame differencing

It should be straightforward to think of a simple background subtraction in order to retrieve foreground objects. A simple solution could look similar to the following line of code:

Core.absdiff(backgroundImage,inputImage , foregroundImage);

This function simply subtracts each pixel of backgroundImage from inputImage and writes its absolute value in foregroundImage. As long as we have initialized the background to backgroundImage and we have that clear from objects, this could work as a simple solution.

Here follows the background subtraction video processor code:

public class AbsDifferenceBackground implements VideoProcessor { private Mat backgroundImage; public AbsDifferenceBackground(Mat backgroundImage) { this.backgroundImage ...

Get OpenCV 3.0 Computer Vision with Java now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.