Unit Process

Back to Tutorials

4. Events 6. Optical Flow 1 2  3  4  5  6  7  8  9  10  11  12  13  14  15  16



In the Simple Viewer example we learnt how the ViiM engine was created. You can think of the ViiM engine as the heart of the SDK: without it it simply won't work. But the heart is not enough for more advanced tasks, and that's why we have the processing units.

The most basic unit is the generic ViiMUnitProcess which is what all the other more complex units have in common. This unit is responsible for all the interactions with the images acquisition process. With it we can define many settings, such as the size of the processed images and whether we want to use a smoothed depth. Notice that you can do this anywhere in the code, whenever you want and in real-time. In this application we will go through many optional settings one might be interested to use in future applications.

We'll learn about all the other units in the next tutorials, but it's important to clarify that since all those units descend from the ViiMUnitProcess, they can access all these methods!

Enough of introduction, let's get down to it! setFarThreshold(value) and setNearThreshold(value) These two methods can be quite useful. If you haven't figured it out already, don't worry we'll explain it :) the 3D sensors are based in infrared technology to create the depth image, alas a map with the distance from the points to the sensor. With these two methods imagine you put a curtain behind you (far threshold) and one on the front (near threshold). Now only the space between the two curtains is available to the sensor. Everything outside these curtains will be black. Imagine you want your application to follow your hand. After analyzing the distance to the hand, this feature can be quite useful to avoid interferences from external elements (objects, other people, etc..), limiting the depth space only from some centimeters in front and some centimeters behind your hand.   setProcessSize(width, height) Although the resolution of the raw images are set in the engine, the processed images can be of any size you want. Use this method to scale to the desired width and height (This method is currently only available for the ViiMUnitOpticalFlow). useCalibrationDepthAndColorImages(bool) 3D sensors are a great innovation, no doubt about it. But there are still some issues and one of them can become quite problematic. We're talking about the calibration between the RGB and depth cameras. Because the two cameras are some centimeters apart, there is always some offset when overlapping the two images. This method makes all the required calculus and removes the offset. This way the position (X,Y) in the RGB imagem will correspond to the same position in the depth image. Set the method true and the processed images will be automatically calibrated. useSmoothDepth(bool) There is always noise when we're dealing with sensors and 3D sensors are not an exception. There are a great number of ways a developer can remove or at least diminish noise, but ViiM provides an automatic smoothed depth image. Just set this method true and you'll notice the difference right away. The previous methods are setters, because you can change settings with them. But ViiMUnitProcess has getters as well so you can get some useful information. setLogLevel(level) ViiM's log notification system informs the user about error events, bad data access, non permitted operations, etc... There are four different levels for notification ( event.type ) and you can set the level with this metod. The levels are: NONE - You will not receive any errors or warnings WARNINGS - You will only receive warning messages ERRORS - You will only receive error messages ALL - You will receive all the errors and warning messages. getFarThreshold and getNearThreshold These methods return the far and near threshold values respectively. If you haven't changed them with the setters, these methods will return the default values of 7000 and 1 respectively, representing the millimeters to the camera. getColorImage and getDepthImage Finally the methods from which you get a vector of unsigned char of the RGB and depth images respectively. You might be thinking "yeah, i've already used these ones in the viewer example", well don't. ViiM's get images methods will get you the RAW images from the sensor, which means no changes whatsoever. These two methods will provide the processed images which will reflect all changes you make to the unit's settings with the all previous setters. distanceAt(x, y) This method returns the distance in mm from the sensor to whatever is placed in the pixel (x, y). There is also one last method we want to refer. exportDepthImage(fileName, nFrames) This method exports a number nFrames of frames to a file named fileName. This is pretty useful in case you want to analyze the sequences on matlab or other software alike. We won't explain this further, because there is a tutorial exclusive on this topic.

4. Events 6. Optical Flow 1 2  3  4  5  6  7  8  9  10  11  12  13  14  15  16

Back to Tutorials