Cropping

Back to Tutorials

7. User Tracking 9. Simple Gestures 1 2  3  4  5  6  7  8  9  10  11  12  13  14  15  16



Here is the fourth unit: ViiMUnitCropping is responsible for removing the background only to leave the user in the foreground. If you haven't done it yet, we strongly advise you to check the first tutorial on using the ViiM engine, the Unit Process tutorial about registering a unit and the Events tutorial where we introduce some of ViiM's events.

Now let's get to the code. Here is the new stuff on the .h

Here we create a new ViiMUnitCropping variable.

In the .cpp, in the setup method, the new stuff is in line 29:

Processing edges is a feature ViiM offers to create a nice effect on the edges of a person in front of the camera. It provides an image with shiny edges over an alpha channel background. This allows the use of this image on its own, over a background and over the regular RGB or cropped images. In the sample it is commented out, so in order to use it, just take the comment //.

Now the update method:

Here we update three images: getCroppedPixels gets the cropped RGB image, which is nothing but the user in front of the camera over an alpha channel background, getEdgesPixels gets the image with the shiny edges over an alpha channel background and getDepthPixels the regular depth image.

Now on to the new stuff on the draw method: This will enable alpha blending in OpenFrameworks to use the overlapped images.

Here we simply draw the edges image on top of the cropped one. Due to theirs alpha channel, the resulting image will be the user cropped from the background with a shiny effect on the edges, over the background color defined by the user. We draw the regular depth image as well.

See this example in the apps folder, ViiM_OF_Samples and choose your OS.

7. User Tracking 9. Simple Gestures 1 2  3  4  5  6  7  8  9  10  11  12  13  14  15  16

Back to Tutorials