0

I am currently using Kinect V2 to transfer depth image data from one location to another remote location. I am able to extract the depth image from the Kinect V2 using C#. Now I want to be able to send this data to the remote user so that the remote user can view the 3D View of the remote user. Do anyone have any tutorials or any helpful pointer?

Thank you

learner1988
  • 141
  • 3
  • 11
  • Do you want to send point cloud of 3D enviroinment? – MIRMIX Jun 21 '17 at 12:51
  • I want to send the 3D Video (with the depth data) of people in the environment. So that the remote user can see this 3D Video (with the depth data) of people – learner1988 Jun 21 '17 at 14:19

1 Answers1

0

You can use OpenKinect-for-Processing library for managing and creating the live streaming . You can keep frames (or directly generate) video from Kinectv2 . By using OpenCV library methods you can generate video file from Kinectv2 output frames. OpenKinect-for-Processing is user-friendly and easy-to-use library which runs on your browser. For quick tutorial you can check this link and look through this small youtube tutorial.

For now you can start editing this code sample:

// Daniel Shiffman
// Kinect Point Cloud example

// https://github.com/shiffman/OpenKinect-for-Processing
// http://shiffman.net/p5/kinect/

import org.openkinect.freenect.*;
import org.openkinect.processing.*;

// Kinect Library object
Kinect kinect;

// Angle for rotation
float a = 0;

// We'll use a lookup table so that we don't have to repeat the math over and over
float[] depthLookUp = new float[2048];

void setup() {
  // Rendering in P3D
  size(800, 600, P3D);
  kinect = new Kinect(this);
  kinect.initDepth();

  // Lookup table for all possible depth values (0 - 2047)
  for (int i = 0; i < depthLookUp.length; i++) {
    depthLookUp[i] = rawDepthToMeters(i);
  }
}

void draw() {

  background(0);

  // Get the raw depth as array of integers
  int[] depth = kinect.getRawDepth();

  // We're just going to calculate and draw every 4th pixel (equivalent of 160x120)
  int skip = 4;

  // Translate and rotate
  translate(width/2, height/2, -50);
  //rotateY(a);

  // Nested for loop that initializes x and y pixels and, for those less than the
  // maximum threshold and at every skiping point, the offset is caculated to map
  // them on a plane instead of just a line
  for (int x = 0; x < kinect.width; x += skip) {
    for (int y = 0; y < kinect.height; y += skip) {
      int offset = x + y*kinect.width;

      // Convert kinect data to world xyz coordinate
      int rawDepth = depth[offset];
      PVector v = depthToWorld(x, y, rawDepth);

      stroke(255);
      pushMatrix();
      // Scale up by 200
      float factor = 200;
      translate(v.x*factor, v.y*factor, factor-v.z*factor);
      // Draw a point
      point(0, 0);
      popMatrix();
    }
  }

  // Rotate
  a += 0.015f;
}

// These functions come from: http://graphics.stanford.edu/~mdfisher/Kinect.html
float rawDepthToMeters(int depthValue) {
  if (depthValue < 2047) {
    return (float)(1.0 / ((double)(depthValue) * -0.0030711016 + 3.3309495161));
  }
  return 0.0f;
}

// Only needed to make sense of the ouput depth values from the kinect
PVector depthToWorld(int x, int y, int depthValue) {

  final double fx_d = 1.0 / 5.9421434211923247e+02;
  final double fy_d = 1.0 / 5.9104053696870778e+02;
  final double cx_d = 3.3930780975300314e+02;
  final double cy_d = 2.4273913761751615e+02;

// Drawing the result vector to give each point its three-dimensional space
  PVector result = new PVector();
  double depth =  depthLookUp[depthValue];//rawDepthToMeters(depthValue);
  result.x = (float)((x - cx_d) * depth * fx_d);
  result.y = (float)((y - cy_d) * depth * fy_d);
  result.z = (float)(depth);
  return result;
}
MIRMIX
  • 1,052
  • 2
  • 14
  • 40
  • Thanks. Processing is a Java Based Environment. I am currently working on Unity3D which uses C#. I think I won't be able to integrate it with the Unity3D. What do you think? – learner1988 Jun 22 '17 at 14:43
  • You can keep output of Processing code in some place and then process it as input to your C# code. – MIRMIX Jun 22 '17 at 14:47