Kinect C++ Color Data Retrieval

0

I have altered a Kinect example written in C++ such that the new code will retrieve both the skeleton and the color data, while the original was getting solely skeleton data. I realized that the code was not able to call ProcessColor method, which I implemented in order to process color data. When I scrutinized the problem, I saw that the indicated line of following part (Which belongs to the init function) fails. During the debug process, when I come to that line, program bounces to ProcessColor method, and subsequently gives an error.

if(NULL!=kinectSensor)
{
    // line that fails is the following
    hr = kinectSensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_COLOR);
     if (SUCCEEDED(hr))
    {
        // Create an event that will be signaled when color data is available
        m_hNextColorFrameEvent = CreateEvent(NULL, TRUE, FALSE, NULL);

        // Open a color image stream to receive color frames
        hr = kinectSensor->NuiImageStreamOpen(
            NUI_IMAGE_TYPE_COLOR,
            NUI_IMAGE_RESOLUTION_640x480,
            0,
            2,
            m_hNextColorFrameEvent,
            &m_pColorStreamHandle);
    }
}

Below I indicated the line that it jumps:

 HRESULT hr;
NUI_IMAGE_FRAME imageFrame;
HANDLE m_hNextColorFrameEvent(INVALID_HANDLE_VALUE), m_pColorStreamHandle(INVALID_HANDLE_VALUE);
// Line that it jumps
hr = kinectSensor->NuiImageStreamGetNextFrame(m_pColorStreamHandle, 0, &imageFrame);

And the error message is following:

Unhandled exception at 0x5ca5b4a6 in KinectSample.exe: 0xC0000005: Access violation reading location 0x00000047.

If it helps, I want to indicate that I added the part shown above from an official Kinect Example (ColorBasics-D2D), and it is likely that there is a clash or something, although I was very careful during the process.

How can I solve it? Any thoughts?

c++
kinect
asked on Stack Overflow Oct 19, 2012 by rooter • edited Oct 19, 2012 by rooter

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0