Kinect无法正确执行NuiCameraElevationSetAngle

时间:2014-06-09 12:42:16

标签: kinect kinect-sdk

我用C ++创建了一个Kinect DLL,它可以用作插件,使用手势在3D环境中导航。工作良好。但是,当我尝试执行

NuiCameraElevationSetAngle(10);

Kinect系统在返回错误代码之前会挂起约15秒:

E_NUI_DEVICE_NOT_READY

我应该执行任何其他初始化步骤吗?可能有什么不对?

我真的不明白这是怎么可能的,因为我可以愉快地获取骨架数据,例如。

我的代码是:

// Locate a working kinect sensor

int numSensors;

// we need to instantiate the skeleton vector
m_skeletons = new std::vector<Skeleton *>();

if (NuiGetSensorCount(&numSensors) < 0 || numSensors < 1)
{
    cout << "No Kinect devices found." << endl;
    return false;
}

cout << "Found " << numSensors << " Kinect device(s); first available was initialized." << endl;

if (NuiCreateSensorByIndex(0, &sensor) < 0)
{
    cout << "Could not establish connection with Kinect device." << endl;
    return false;
}

cout << "Connected." << endl;

// Initialize sensor

if(!SUCCEEDED(sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR
                                                                   | NUI_INITIALIZE_FLAG_USES_SKELETON)))
{
    cout << "Error initialising Kinect device." << endl;
    return false;
}

cout << "Initialized." << endl;

sensor->NuiImageStreamOpen(NUI_IMAGE_TYPE_COLOR,                // Depth camera or rgb camera?
                           NUI_IMAGE_RESOLUTION_640x480,        // Image resolution
                           0,                                   // Image stream flags, e.g. near mode
                           2,                                   // Number of frames to buffer
                           NULL,                                // Event handle
                           &rgbStream);

// Create an event that will be signaled when skeleton data is available
m_hNextSkeletonEvent = CreateEventW(NULL, TRUE, FALSE, NULL);

// Open a skeleton stream to receive skeleton data
m_hSkeletonStream = sensor->NuiSkeletonTrackingEnable(m_hNextSkeletonEvent, 0);

cout << "Skeleton stream initialised." << endl;



    NuiCameraElevationSetAngle(10);    // cause E_NUI_DEVICE_NOT_READY error code... ???



     return true;
}

0 个答案:

没有答案