This example continues to explore the Video module in OpenCV. It uses one of the BackgroundSubtractors, the BackgroundSubtractorKNN. It learns the motion in front of the camera and treats the stationary scene as background.
In the code, the important command is
bkg.apply(frame, fgmask); |
The subtractor object bkg takes in the latest frame and generates a foreground mask, fgmask. We can use the foreground mask to single out the foreground moving object.
Here are a number of screen shots from the testing. The background is the planet Earth image from NASA.
Continue reading