OpenNI 1.5.7
Sample Programs for the OpenNI API
This OpenNI installation comes with a number of sample programs. All samples are placed under the 'Samples' folder, and their binaries
can be found under:
Samples\\Bin\\Debug
- or -
Samples\\Bin\\Release

Most samples use an XML file to configure OpenNI. This file can be found at:

%OPEN_NI_INSTALL_DIR\%\\Data\\SamplesConfig.xml</code>

There are samples for the C++, C#/.NET and Java interfaces.

This help document describes the sample programs showing how to program with the OpenNI API. Follow the links below for a detailed description of each sample programs.

Summary of Sample Programs

Following are brief descriptions of the basic purpose of some of the main sample programs above. 

NiSimpleRead for C++

    NiSimpleRead is very basic. It configures OpenNI using the SamplesConfig XML file, and then takes the depth
    generator node (it assumes there is one. If not, the sample will exit with an error).
    It then loops, reading new frames from the depth generator, and prints out the depth value of the middle pixel.
    The sample exists when the user presses 'ESC'.

NiSimpleCreate for C++

    NiSimpleCreate is an example of creating a production node programmatically in code, rather than using the 
    SamplesConfig XML file. After creating a depth node, it reads from it like NiSimpleRead does.

SimpleViewer for C#/.NET

    NiSimpleViewer is a small OpenGL application which draws the depth maps and the image maps to the screen.
    It configures OpenNI using the SamplesConfig XML, but requires both a DepthGenerator node and an ImageGenerator node to be present, both with
    the same resolution, and the ImageGenerator node at RGB24 format.
    The application creates a histogram of the depth map and draws the frame using it to allow better visibility
    of the depth map.

    The following keys can be used to control the application:
    <table>
            <tr>
                <th>Key</th>    <th>Description</th>
            </tr>
            <tr>
                <td>1</td>
                <td>
                    Converts to OVERLAY mode, drawing a depth map on top of the image map. It also sets the depth viewpoint
                    to the image viewpoint (using the AlternativeViewPoint capability).
                </td>
            </tr>
            <tr>
                <td>2</td>
                <td>Draws only the depth map. It also turns off AlternativeViewPoint operation.</td>
            </tr>
            <tr>
                <td>3</td>
                <td>Draws only the image map. It also turns off AlternativeViewPoint operation.</td>
            </tr>
            <tr>
                <td>Esc</td>
                <td>Closes the application</td>
            </tr>
    </table>

NiConvertXToONI for C++

    NiConvertXToONI opens any recording, takes every node in the recording, and records it to a new ONI recording.
    It takes both the input file name and the output file name from the command line.

NiRecordSynthetic for C++

    NiRecordSynthetic shows how to open a recording, perform some transformation on the data in it,
    and then re-record this data.

NiBackRecorder for C++

    niBackRecorder is a command line tool, which stores frames in memory in a cyclic buffer,
    and when requested (clicking 'd') dumps that cyclic buffer to an ONI file.
    In effect, it saves the most recent x seconds (configurable).

Usage

niBackRecorder time <seconds> [depth [qvga|vga]] [image [qvga|vga]] [verbose] [mirror <on|off>] [registration] [framesync] [outdir <directory>]

The following options are mandatory:

The following options can be used:

Note: When designing your application it is important to consider the amount of memory used to store the frames.

Configuration Size
1 second, QVGA depth 30*320*240*2B = 4500KB
1 second, QVGA image 30*320*240*3B = 6750KB
1 second, VGA depth 30*640*480*2B = 18000KB
1 second, VGA image 30*640*480*3B = 27000KB

NiRecordRaw for C++

    NiRecordRaw is an OpenNI sample program for recording raw data, and then playing it back. Recording raw data may be useful for middleware developers who produce a custom type of data that isn't defined by OpenNI. In addition, recording raw data may also be useful for middleware developers who save additional debugging information in the ONI file. This additional data may be used in conjunction with the standard OpenNI data types such as depth output data stored in the file. In this case, each frame of debugging information will match a depth frame. 

    In this sample, the raw data is artificial data that the application itself synthesizes.

NiAudioSample for C++

    NiAudioSample is an OpenNI sample program for using the Audio interface. 

    It demonstrates an OpenNI production graph using an AudioGenerator node to play audio, reading the audio data from an audio input device. This sample also demonstrates recording the audio data to a PCM file.

SimpleRead for C#/.NET

    See NiSimpleRead for C++.

SimpleRead for C#/.NET

    See NiSimpleRead for C++.

SimpleViewer for C#/.NET

    See NiSimpleViewer for C++.

SimpleViewer for C#/.NET

    See NiSimpleViewer for C++.