使用OpenNI和avin SensorKinect获得奇怪的Kinect加速度值

时间:2016-03-01 11:33:21

标签: kinect openni

根据[1],我应该能够访问带有请求0x32的Kinect加速度计数据,提供一个10字节的缓冲区。加速度计矢量xyz值应该是字节3到8的短整数。如文中所述(和预期的一样),使用水平固定摄像机,我应该得到x和z都接近0的值,y的值约为981 。这将是g并且有意义。相反,虽然y值是预期的,但我得到x和z值接近0xffff。这是代码(我跳过错误检查以获得更好的可读性):

const unsigned short VENDOR_ID_MSFT = 0x045e;
const unsigned short PRODUCT_ID_KINECT360_MOTOR = 0x02b0;

XN_USB_DEV_HANDLE deviceHandle = NULL;
const XnUSBConnectionString *paths = NULL;
XnUInt32 count;

xnUSBInit();
xnUSBEnumerateDevices( VENDOR_ID_MSFT, PRODUCT_ID_KINECT360_MOTOR, &paths, &count );
xnUSBOpenDeviceByPath( paths[0], &this->deviceHandle );

//init motor
xnUSBSendControl( this->deviceHandle, (XnUSBControlType) 0xc0, 0x10, 0x00, 0x00, buf, sizeof( buf ), 0 );

XnStatus res;
XnUChar buf[10] = { 0 };
XnUInt32 size = 0;
//query motor data
xnUSBReceiveControl( this->deviceHandle, XN_USB_CONTROL_TYPE_VENDOR, 0x32, 0, 0, buf, sizeof( buf ), &size, 0 );

int accelCountX = (int) ( ( (short) buf[2] << 8 ) | buf[3] );
int accelCountY = (int) ( ( (short) buf[4] << 8 ) | buf[5] );
int accelCountZ = (int) ( ( (short) buf[6] << 8 ) | buf[7] );

std::cout << accelCountX << "/" << accelCountY << "/" << accelCountZ << std::endl;

输出显示的值类似:

  

65503/847/65516

任何想法,问题可能是什么?谢谢!

[1] http://fivedots.coe.psu.ac.th/~ad/jg/nui16/motorControl.pdf

0 个答案:

没有答案