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:
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.
- NiAudioSample.cpp - sample program
- NiBackRecorder.cpp - sample program
- NiConvertXToONI.cpp - sample program
- NiRecordRaw.cpp - sample program
- NiRecordSynthetic.cpp - sample program
- NiSimpleCreate.cpp - sample program
- NiSimpleRead.cpp - sample program
- NiSimpleViewer.cpp - sample program
- NiUserTracker - sample program
- NiViewer - sample program
- SimpleRead.java - sample program (Java)
- SimpleRead.net - sample program (C#/.NET)
- SimpleViewer.java - sample program (Java)
- SimpleViewer.net - sample program (C#/.NET)
- UserTracker.java - sample program (Java)
- UserTracker.net - sample program (C#)
- HandTracker.java - sample program (java)
Following are brief descriptions of the basic purpose of some of the main sample programs above.
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 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.
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:
|1||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).|
|2||Draws only the depth map. It also turns off AlternativeViewPoint operation.|
|3||Draws only the image map. It also turns off AlternativeViewPoint operation.|
|Esc||Closes the application|
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 shows how to open a recording, perform some transformation on the data in it, and then re-record this data.
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).
niBackRecorder time <seconds> [depth [qvga|vga]] [image [qvga|vga]] [verbose] [mirror <on|off>] [registration] [framesync] [outdir <directory>]
The following options are mandatory:
- time Number of seconds to dump each time.
The following options can be used:
- depth Sets the resolution of the depth, to either QVGA or VGA. If not mentioned, depth is off. If no resolution is mentioned, QVGA is used.
- image Sets the resolution of the image, to either QVGA or VGA. If not mentioned, image is off. If no resolution is mentioned, QVGA is used.
- verbose Turns on the log.
- mirror Set the mirror mode. If not mentioned, uses whatever was configured.
- registration Change depth to match image.
- framesync Syncronize between depth and image.
- outdir Where to create the oni files. Default is the execution directory.
Note: When designing your application it is important to consider the amount of memory used to store the frames.
|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 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 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.
See NiSimpleRead for C++.
See NiSimpleRead for C++.
See NiSimpleViewer for C++.
See NiSimpleViewer for C++.
Generated on Wed May 16 2012 10:16:06 for OpenNI 1.5.4 by 188.8.131.52