Video Exporter

Back to Tutorials

14. Stickman 16. Create your own processing units 1 2  3  4  5  6  7  8  9  10  11  12  13  14  15  16



ViiM has lots of wonderful features and we think this one will be a joy to lots of people, specially Matlab fans.

We created a video exporter method in ViiM and a script to load the videos in Matlab. First we'll see how to record videos in different modes. In the end we'll explain how to get the script working in Matlab.

This application shows two images. On the left we will always have the raw depth image and the right image will start with the RGB and then change according to the kind of image set to be recorded. You can record the raw depth image, the smoothed depth image, the RGB image, and the cropped image by simply pressing the corresponding key as we'll see afterwards.

Since this is our last tutorial, you should rock ViiM by now, so we'll just stick to the new stuff (but if you still have any doubts, maybe you should check the tutorial about the ViiM engine, the tutorial about registering a unit, the tutorial about ViiM's events or the gestures interaction tutorial and the cropping unit tutorial).

Now to the good stuff. In the .cpp we'll start by the end of the code:

Let's start with this method. You should already know it by heart :) this method allows the use of key presses to trigger events. In this case each letter corresponds to recording a different image. The recording is done with the methods starting with export and ending with the type of image you want to export. The fields of the methods are the same though, for instance:

The first field is the name of the file you want to record and the second is the number of frames you want in to record. In this switch there are 4 flags: _framesExported tells the program that the file has been exported and that it is possible to record a new one; _exportingColor and _exportingSmooth tell the draw function what image to be drawn on the right.

Let's see then how you can interact with the application: Press d - Get the raw depth image from the engine. Press s - Get the smoothed depth image from the engine. Press h - Get the hand image from the gesture unit. Press c - Get the RGB image from the engine.

On the update method we simply update the smoothed depth image and raw depth and color images. On to the draw function The draw function draws two images. As aforementioned, the left side image will always be the raw depth image. On the right side the two flags _exportingColor and _exportingSmooth will set which image to show on the right. If none is selected (because either d or h were pressed) the right image will stay the previous. And if you show your hand to the camera, a hand graphic will show on top of the hand on the left image.

Lots of options, and really easy, right? :)

Now, as promised, ViiM has a Matlab importer (.m script) that you can use to open our binary videos in Matlab. You just have to call

where pathRead is the path to look for the filename file and toSave and toPlot are boolean flags to save or plot the data if true.

14. Stickman 16. Create your own processing units 1 2  3  4  5  6  7  8  9  10  11  12  13  14  15  16

Back to Tutorials