OpenNI2 640x480 stream problem

Dear Team,
we are developing an application using OpenNI2 to interface with Structure sensor. The code is compiled with VS2010 C++ express and works properly, we can get the stream types list from the sensor:

0: 320x240, 30 fps, 100
1: 320x240, 30 fps, 101
2: 320x240, 60 fps, 101
3: 320x240, 30 fps, 100
4: 640x480, 30 fps, 100
5: 640x480, 30 fps, 101
6: 160x120, 30 fps, 100
7: 160x120, 30 fps, 101

We can open correctly video stream 0,1 ,2 and 3 (320x240 resolution) while we have timeout error if we use video modes 4 or 5 (640x480) and I do not understand what we are missing.
Here is the code:

const openni::SensorInfo* sinfo = device.getSensorInfo(openni::SENSOR_DEPTH);
const openni::Array< openni::VideoMode>& modesDepth = sinfo->getSupportedVideoModes();
for (int i = 0; i<modesDepth.getSize(); i++) {
printf("%i: %ix%i, %i fps, %i format\n", i, modesDepth[i].getResolutionX(), modesDepth[i].getResolutionY(),
modesDepth[i].getFps(), modesDepth[i].getPixelFormat());
rc = depth.setVideoMode(modesDepth[5]);
DIMX = modesDepth[5].getResolutionX();
DIMY = modesDepth[5].getResolutionY();
printf(“Start loop\n”);
//these values are correct
int minval = depth.getMinPixelValue();
int maxval = depth.getMaxPixelValue();
float angleX = depth.getHorizontalFieldOfView();
float angleY = depth.getVerticalFieldOfView();
int UPDATE = 0;
while (!TestDestroy()){
VideoStream* pStream = &depth;
int changedStreamDummy;
Status rc = OpenNI::waitForAnyStream(&pStream, 1, &changedStreamDummy, SAMPLE_READ_WAIT_TIMEOUT);
if (rc != STATUS_OK)
printf(“Wait failed! (timeout is %d ms)\n%s\n”, SAMPLE_READ_WAIT_TIMEOUT, OpenNI::getExtendedError());

    rc = depth.readFrame(&frame);
    if (rc != STATUS_OK)
        printf("Read failed!\n%s\n", OpenNI::getExtendedError());


Any help would be really appreciated.



I have the same problem. I’m also not being able to use the video modes 4 and 5 with the Structure Sensor and OpenNI2. In my case, the problem is a buffer overflow when reading the depth frames.

The cause for your problem may be the same. Try setting the value of the flag Verbosity, in the file OpenNI.ini, to 0, and run the code again. In my case, this leads to the error:

Read: Depth buffer is corrupt. Size is 151344 (!= 614400)
Depth Frame Buffer overflow! current size: 151344
Depth frame is corrupt!

I don’t know how to solve this. Does anyone have an ideia?


I found a solution to my problem. Try changing the video mode before depth.start() and after depth.create(device, SENSOR_DEPTH).

It works! Great!

Thank you Cesar.