NtKinectDLL and NtUnity: Tutorial:

Use Realtime Video Captured with Kinect V2 as Texture on Unity

2017.08.23: created by
Japanese English
To Table of Contents

Prerequisite knowledge

Use Realtime Video Captured with Kinect V2 as Texture on Unity

  1. I will use the Unity project created in "Using NtKinectDLL in Unity (Fundamental Settings)". Download UnityDLL01.zip and expand it. Also change the name of the expanded folder to "UnityDLL03/".
  2. Create a new scene and save it under "Assets/Scenes/" as "Sample03.unity".
  3. File -> New Scene
    File -> Save Scene as ... -> Sample03.unity
  4. Create new C# script under "Assets/Scripts/" in the Project window.
  5. from above menu -> "Assets" -> "Create" -> "C# Script" -> Rename as "Sample03"

    using System.Collections;
    using System.Collections.Generic;
    using UnityEngine;
    public class Sample03 : MonoBehaviour {
      public GameObject target;
      NtUnity.Kinect nt;
      Texture2D texture;
      void Start () {
        nt = new NtUnity.Kinect();
        texture = new Texture2D(NtUnity.Kinect.rgbCols,
      void Update () {
        target.GetComponent<Renderer>().material.mainTexture = texture;
        // rotate cube
        target.transform.rotation = Quaternion.AngleAxis(Mathf.Rad2Deg * Time.time,
      void OnApplicationQuit() {
  6. Place a new "Cube" object in Hierarchy. When it is selected in the Hierarchy window, reset its "Transform" to select "Reset" from the Transfrom Settings in the Inspector window.
  7. above Menu -> GameObject -> 3D Object -> Cube

  8. Place an "Empty Object" in Hierarchy and change the name to "GameController".
  9. above Menu -> GameObject -> Create Empty

  10. Add "Sample03.cs" as a Component of "GameController".

  11. When "GameController" is selected in the Hierarchy window, the "Sample 03 (Scripts)" Component is displayed in the Inspector window. Assign "Cube" in Hierarchy to the "Target" item of the component.

  12. In Hierarchy, select "Main Camera" and change Position of Transform to (x,y,z)=(0,0,-1.5).
  13. When executed, the realtime video captured by the Kinect V2 is displayed r on the rotating cube.
  14. The cycle at which the cube makes one rotation around the y-axis is about 6.3 seconds (= 2π seconds).

    Runtime Video UnityDLL03.mp4

  15. The sample project of Unity is UnityDLL03.zip.