[bar chart PIC] Chapter 2.1.   Charting the Depth Map

 

This chapter does NOT appear in the book.

 

This chapter revisits the depth map example of Chapter 2 to illustrate a more numerical way of viewing the information. The first two versions of the ViewerPanel class in Chapter 2 convert the depth measurements into grayscale images. It's quite easy to insert a few lines of code to also display the bar chart shown on the right.

The graph's x-axis show the Kinect's depth measurements, which typically range from 500 to 3500 mm. The y-axis is for the number of measurements returned for a particular depth.

The corresponding grayscale depth image is shown in the picture below. Recall that darker means further away, although black also means "too close" for a depth value to be calculated, or that no depth data was returned (e.g. for the edges of the user's arm).

The chart above contains three main peaks, one at around 540 mm, another at 900 mm, and a wide spread of depths starting from 1900 mm and extending out to 3400 mm. A look at the depth image shows that the first peak is my raised hand and the spread is the back wall of my office.

The XY bar chart above is created using the JFreeChart library, which allows the user to zoom-in (and out) on a chart. For instance, I used the mouse to select a region around the first peak, and the chart was redrawn as on the right.

[depth image PIC] [xoomed chart PIC]

The necessary modifications to the ViewerPanel class to add this chart are quite modest since JFreeChart handles the complex details of chart updating and rendering.

One issue I had was chart update frequency: chart rendering takes over 0.5 seconds, and slows down OpenNIViewer by too much if done for every Kinect update. Instead, ViewerPanel imposes a 2 second delay between chart updates so the application isn't affected too often.

Before I describe the charting version of ViewerPanel, I'll briefly introduce JFreeChart with two short examples for drawing a 3D pie chart and a XY bar chart.

 

Downloads


Navigation:


Dr. Andrew Davison
E-mail: ad@fivedots.coe.psu.ac.th
Back to my home page