![](/img/trans.png)
[英]cannot access private member declared in class 'Windows::Devices::Sensors::Accelerometer'
[英]Cannot Initialize Kinect in Windows (0 sensors detected)
我無法在Windows PC中初始化Kinect v1。
這是我的代碼(成功構建):
#include <Windows.h>
#include <Ole2.h>
#include <gl/GL.h>
#include <gl/GLU.h>
#include <gl/glut.h>
#include <NuiApi.h>
#include <NuiImageCamera.h>
#include <NuiSensor.h>
#define width 640
#define height 480
// Kinect variables
HANDLE rgbStream; // The identifier of the Kinect's RGB Camera
INuiSensor* sensor; // The kinect sensor
int main(int argc, char* argv[]) {
// Get a working kinect sensor
int numSensors=1;
HRESULT reponse;
reponse = NuiGetSensorCount(&numSensors);
if (reponse < 0) return false;
if (numSensors < 1) return false;
if (NuiCreateSensorByIndex(0, &sensor) < 0) return false;
// Initialize sensor
sensor->NuiInitialize(NUI_INITIALIZE_FLAG_USES_DEPTH | NUI_INITIALIZE_FLAG_USES_COLOR);
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);
return sensor;
}
問題是函數“ NuiGetSensorCount”始終返回傳感器的數量為0。
Kinect 1是通過USB端口插入PC的(我嘗試過使用其他端口); 奇怪的是,如果我運行Skanect(1.8 Win64)之類的軟件,Skanect會識別該設備(它被檢測為OpenNI 2 Sensor),並且可以使用它。
我正在Windows 7 64位中使用Visual Studio 2013 Update 5。 我已經安裝了OpenNI 64位2驅動程序和Kinect for Windows SDK v1.8。
在我的項目屬性中,我正在調用Kinect10.lib庫,該庫位於:
(我在x86和x64配置中都嘗試過)
同樣,對於每種配置,我都嘗試使用位於以下位置的Kinect10.dll二進制文件:
任何意見/建議都將受到歡迎。 另外,如果我錯過了一些您認為相關的信息,請告訴我。
提前致謝。
編輯我只是看到您已經調用了Initializer函數。 也許您需要在NuiGetSensorCount(&numSensors)函數之前調用它。
我對NUI框架沒有太多經驗,但是我建議對kinect相機使用OpenNI框架。 盡管alreay停止了其相當穩定的工作,並且效果很好。 它甚至支持用於抓取圖像的回調函數,等等。
繼承人鏈接: http : //structure.io/openni
但是,從我在互聯網上發現的信息來看,您似乎正在遵循此教程: http : //www.cs.princeton.edu/~edwardz/tutorials/kinect/kinect1.html
我在這里找到了另一個
似乎在讀取傳感器數量之前調用了Initializer函數:
[...]
int main()
{
cout << "Hello world" << endl;
NuiInitialize(NUI_INITIALIZE_FLAG_USES_SKELETON); <-------- HERE
NUI_SKELETON_FRAME ourframe;
while (1)
{
NuiSkeletonGetNextFrame(0, &ourframe);
for (int i = 0; i < 6; i++)
{
if (ourframe.SkeletonData[i].eTrackingState == NUI_SKELETON_TRACKED)
cout << "Right Hand: " ;
cout << ourframe.SkeletonData[i].SkeletonPositions[NUI_SKELETON_POSITION_HAND_RIGHT].y << endl;
}
system("cls");
}
NuiShutdown();
return 0;
}
NuiInitialize指向msdn doc的位置
這說
指定要初始化的Kinect子系統
這似乎使Kinect子系統成為可能,這對於啟動設備是必不可少的。
讓我知道是否有效!
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.