Kinect To Unity Using SDK

Hello Everyone,

I need a help ASAP … I want to connect the kinect to unity. So, i have seen some tutorials and then tried the OpenNI and the NITE.thing but that didn’t work then i tried Using the Kinect SDK then a error shows up that the plugin cannot be used as this is free version . Can anyone tell me the step by step procedure of doing this…

My Kinect is working perfectly when i opened the skeletal viewer …that’s fine …I need to connect this…that’s my problem…

anyone please…

thanks,
Kushal

Well, I know nothing about the OpenNI, but I think the following technique may help you to pass in the real-time data to/from the outside world of unity.

Step 1 - Create a static system array in Unity

private static var c32:Color32[];

Step 2 - Initialize it.

function setup_texture(m:int, n:int)
{
...
	c32 = new Color32[length];
	for(var i:int = 0;i<length;i++)
	{
		c32[i] = Color32(0,0,0,255);
	}
...
}

Step 3 - expose the pointer of the first element of that array to the plug-in

UCC_AR.color32_array(c32.length, c32[0]);

The plug-in should similar to this.

using System;
using System.Runtime.InteropServices;
using UnityEngine;

public class UCC_AR
{
	#if !UNITY_EDITOR
		[DllImport ("__Internal")]
		public static extern 	int color32_array(int n, ref Color32 c);		
	#else
		public static 	int color32_array(int n, ref Color32 c) 	{ return 0; }		
	#endif
	
}

Step 4 -In the outside world

typedef struct { unsigned char r, g, b, a; } 	U3d_Color32;

int color32_array(int n, U3d_Color32 *c)
{		
	if(!n)
		return -1;
...
	// so that, the array inside of unity are connected to the outside world
	// since, that is a pointer, the data could be read/writeable :)
	[buf2 getBytes:(void *)c  length:n*4];

...

	return 1;
}

I used the above technique to pass in the real-time camera (iOS) data for some optical flow process :stuck_out_tongue:

Edit, Ooooppss. sorry, I forget to see some line of your post… you do need a paid version of unity to do anything related to the plug-in :wink: