The GEM library includes image-processing objects for us to isolate the foreground and background of a scene. The logic is simple. It takes a snapshot of a background image first. When the subject enters into the scene, it compares the current frame with the stored background image. Only the pixels with change in the color are highlighted in the resulting image. Those areas without any changes remain black.
The object is pix_background
. It has a parameter in its first inlet, a reset
message. Clicking on this message will store a copy of the current frame as the background image. The second parameter is the list of three numbers in the right inlet. In this example, we have used a horizontal slider with a range between 0 and 1. The three numbers $1
are the red, green, blue values forming the threshold that will turn black after the frame comparison.
To operate this patch, first point your webcam to a static background, such as a wall. Click on the reset
message...