Tracking nearest object with kinect


I think you guys now familiar with Kinect depth image and how it’s behave. Next I will explain some basic 

example  so that it will help you to do some basic stuff with Kinect. 

Before that, If not go to my first blog post from here.

Installation: http://techgeekon.blogspot.com/2016/07/installingopenni-in-ubuntu-14.html

Introduction: http://techgeekon.blogspot.com/2016/07/hello-world-in-kinect-processing.html

As I mention before Kinect keep track of depth values of  all most all the pixels related to pixel position 

which are corresponding to the real world instances.

If we can access to that depth value pixels using an array ,using simple algorithm we can track which pixel 

have least depth, then our goal is complete. Actually SimpleOpenNI have pretty-match all the necessary 

data structure  to achieve this  very  easily.

This method of keep tracking nearest or specific place which have specific characteristic like width range 

,height range, depth range or a RGB value rang can be adapted to many application like robotic, 

Automation and etc.

Now I will explain to you how I achieved it.

Before that  this is the Processing Code and  the results.


Results


At the time observation taken, Nearest point was red dot in left hand. You can verify your code 

working correctly by the tracked point which should have in brightest position of  gray scale depth 

image.



Now I will summarize how code work . If you find any difficulty to understand any of 

above code feel free to ask.

  • First, setup() part is same as before it allow access to Depth value by  enableDepth() method

  • In draw(), first interesting thing is at the beginning it initiate it nearest value as far value  so that it consider all the pixels at the beginning 

  • Then it access depth value array (which is a 1 D array representing all the pixel values considering as one line)   by depthMap() method.

  • Next part is accessing this array using nested  for loop,representing X and Y coordinate, initiating left upper corner of the image  as  (0,0) point.

  • Basically in this nested loop compare every depth value in the depthMap array with the current closest value ,if comparing value is smaller than the current closest it will set as current closest and it's  coordinate as closest point coordinate.

  • At the end of the nested loops , program has the closest point corresponded to the current depth image.

  • Finally , Program draws a ellipse around that current closest point .



Comments

Popular posts from this blog

Measuring 3D Distances between points using Kinect

Implementation - Robot Navigation

Full stack development of Robot navigation