I am just new to this I have installed Open NI and also the Xbox is successfully connected and also I have got some code which i am not able to upload to this message because it is not supporting… but the code i have is not working… I need to record something from my Xbox and test the recording of the stream from the Kinect using openNI recording functionality in the format .oni files. Can any one help me with this topic?
This is CLNUIDevice.h file:
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
#include <windows.h>
#define IMPORT(type) extern “C” __declspec(dllimport)## type __cdecl
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CLNUIMotor API
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Motor instance type
typedef void *CLNUIMotor;
// Library initialization
IMPORT(CLNUIMotor) CreateNUIMotor();
IMPORT(bool) DestroyNUIMotor(CLNUIMotor mot);
// Get device serial number
IMPORT(PCHAR) GetNUIMotorSerial(CLNUIMotor mot);
// Motor control
IMPORT(bool) SetNUIMotorPosition(CLNUIMotor mot, SHORT position);
// Get accelerometer data
IMPORT(bool) GetNUIMotorAccelerometer(CLNUIMotor mot, SHORT &x, SHORT &y, SHORT &z);
IMPORT(bool) SetNUIMotorLED(CLNUIMotor mot, BYTE value);
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// CLNUICamera API
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Camera instance type
typedef void *CLNUICamera;
// Library initialization
IMPORT(CLNUICamera) CreateNUICamera();
IMPORT(bool) DestroyNUICamera(CLNUICamera cam);
// Camera capture control
IMPORT(bool) StartNUICamera(CLNUICamera cam);
IMPORT(bool) StopNUICamera(CLNUICamera cam);
// Camera video frame image data retrieval
IMPORT(bool) GetNUICameraColorFrameRAW(CLNUICamera cam, PBYTE pData, int waitTimeout = 2000);
IMPORT(bool) GetNUICameraColorFrameRGB24(CLNUICamera cam, PBYTE pData, int waitTimeout = 2000);
IMPORT(bool) GetNUICameraColorFrameRGB32(CLNUICamera cam, PDWORD pData, int waitTimeout = 2000);
// Camera depth frame image data retrieval
IMPORT(bool) GetNUICameraDepthFrameRAW(CLNUICamera cam, PUSHORT pData, int waitTimeout = 2000);
IMPORT(bool) GetNUICameraDepthFrameRGB32(CLNUICamera cam, PDWORD pData, int waitTimeout = 2000);
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Here is KinectTest.cpp file:
/********************************************************/
// Displays the color and depth information using OpenCV
/********************************************************/
#include “stdafx.h”
#include <opencv/cv.h>
#include <opencv/cxcore.h>
#include <opencv/highgui.h>
#include <CLNUIDevice.h>
using namespace std;
void displayKinectImage();
int _tmain(int argc, _TCHAR* argv[])
{
displayKinectImage();
}
void displayKinectImage() {
PDWORD rgb32_data = (PDWORD) malloc(640*480*4);
PDWORD depth32_data = (PDWORD) malloc(640*480*4);
CLNUICamera cam = CreateNUICamera(GetNUIDeviceSerial(0));
CLNUIMotor motor = CreateNUIMotor(GetNUIDeviceSerial(0));
StartNUICamera(cam);
cvNamedWindow(“Image”, CV_WINDOW_AUTOSIZE);
cvNamedWindow(“Depth”, CV_WINDOW_AUTOSIZE);
cvNamedWindow(“Grey”, CV_WINDOW_AUTOSIZE);
IplImage *rgb32 = cvCreateImageHeader(cvSize(640, 480), 8, 4);
IplImage *grey;
IplImage *depth32 = cvCreateImageHeader(cvSize(640, 480), 8, 4);;
do {
GetNUICameraColorFrameRGB32(cam, rgb32_data);
GetNUICameraDepthFrameRGB32(cam, depth32_data);
rgb32 = cvCreateImageHeader(cvSize(640,480), 8, 4);
grey = cvCreateImage(cvSize(640, 480), 8, 1);
depth32 = cvCreateImageHeader(cvSize(640, 480), 8, 4);
cvSetData(rgb32, rgb32_data, rgb32->widthStep);
cvSetData(depth32, depth32_data, depth32->widthStep);
// Convert RGB32 to greyscale
cvCvtColor(depth32, grey, CV_RGB2GRAY);
cvShowImage(“Image”, rgb32);
cvShowImage(“Grey”, grey);
cvShowImage(“Depth”, depth32);
cvReleaseImageHeader(&rgb32;);
cvReleaseImage(&grey;);
cvReleaseImageHeader(&depth32;);
cvWaitKey(1);
} while (!GetAsyncKeyState(0x50));
free(rgb32_data);
free(depth32_data);
//StopNUICamera(cam);
//DestroyNUIMotor(motor);
//DestroyNUICamera(cam);
}
Thanks,
Vineela