1
votes

I'm new to the OpenNI and I'm trying to create a simple ImageGenerator that just display a pure color image, say white, I modified the “SampleModule” and in the UpdateData() method I assign the *pPixel value with 255. The UpdateData() method is as following

XnStatus SampleImage::UpdateData()
{
    XnStatus nRetVal = XN_STATUS_OK;

    XnUInt8* pPixel = m_pImageMap;

    for (XnUInt y = 0; y < 300; ++y)
    {
        for (XnUInt x = 0; x < 400; ++x, ++pPixel)
        {           
            *pPixel = (XnUInt8)255;
        }
    }

    m_nFrameID++;
    m_nTimestamp += 1000000 / SUPPORTED_FPS;

    // mark that data is old
    m_bDataAvailable = FALSE;

    return (XN_STATUS_OK);
}

The code compile fine, and I could register it with nireg, but when I try to read the image pixel value from the data generated by the module I got some strange value (not 255 as I expected), I use the following code to read the pixel value.

const XnUInt8*    pImageMap = mImageGenerator.GetImageMap();

for (XnUInt y = 0; y < 300; ++y)
{
        for (XnUInt x = 0; x < 400; ++x, ++pImageMap)
        {
            cout << (int)*pImageMap << endl;
        }
}

and also when I run the “NiViewer” the program still say it can't find the image node, but the “SampleModule” can be find as a depth.

Any advice would be appreciate.

Thanks a million, Haolin Wei

1
so when u run NiViewer, and press 1 or 2 or 3 or 4... do you see images? or not?blueskin
Hi blueskin, I have tried the niviewer but it said it can't find the device, I think it might because the configure file, but I don't know why the "SampleModule" that comes with the openni runs fine in the niviewer after register. Any suggestions? Thanks a lot.Haolin Wei
I am using a older version of OpenNI so not sure what the SampleModule is. if you open your device manager, do you see anything like Xbox NUI Camera or something along those lines.?blueskin

1 Answers

0
votes

Check if you did following things: 1. set color format, i.e, rgb (or YUV) 2. set correct value for each pixel in the updataData(), i.e. r=255,g=255,b=255