Export positions of joints in Skeleton Tracking function (in KinectPV2) to obj file?

ynoyno
edited October 2017 in Kinect

Hi everyone,

I am working on a project about hand tracking. I am trying to track down the trace of my moving hands and export the trace as an 3d file like .obj

I found the SkeletonColor example in KinectPV2 (https://github.com/ThomasLengeling/KinectPV2/tree/master/KinectPV2/examples/SkeletonColor),

which can help me to get the location of my hand

and RecordPointCloud example also in KinectPV2 (https://github.com/ThomasLengeling/KinectPV2/tree/master/KinectPV2/examples/RecordPointCloud),

which can help me record and export the PointCloud as an .obj file at each frame.

I am wondering is there any way to combine these two together?

I believe here is how the author start to export the location data to 3d files: (https://github.com/ThomasLengeling/KinectPV2/blob/master/KinectPV2/examples/RecordPointCloud/RecordPointCloud.pde))

void draw() {
   ...
  //get the points in 3d space
  FloatBuffer pointCloudBuffer = kinect.getPointCloudDepthPos();

  //allocate the current pointCloudBuffer into an array of FloatBuffers
  allocateFrame(pointCloudBuffer);

  //when the allocation is done write the obj frames
  writeFrames();
  ...
}

//allocate all the frame in a temporary array
void allocateFrame(FloatBuffer buffer) {
  if (recordFrame) {
    if ( frameCounter < numFrames) {
      FrameBuffer frameBuffer = new FrameBuffer(buffer);
      frameBuffer.setFrameId(frameCounter);
      mFrames.add(frameBuffer);
    } else {
      recordFrame = false;
      doneRecording = true;
    }
    frameCounter++;
  }
}

//Write all the frames recorded
void writeFrames() {
  if (doneRecording) {
    for (int i = 0; i < mFrames.size(); i++) {
      FrameBuffer fBuffer =  (FrameBuffer)mFrames.get(i);
      fBuffer.saveOBJFrame();
    }
    doneRecording = false;
    println("Done Recording frames: "+numFrames);
  }
}

I was trying to find any similar function for the skeleton class to try to transform

FloatBuffer pointCloudBuffer = kinect.getPointCloudDepthPos();

to something like:

FloatBuffer handPositionBuffer = kinect.getHandDepthPos();

but couldn't find any function like "getHandDepthPos"

and I couldn't find any function return type is FloatBuffer in the class

(where the author defines the "getPointCloudDepthPos()" function.) --> (https://github.com/ThomasLengeling/KinectPV2/blob/3bda24ba8b7c62155bf308c0d86c961ca89dbfa3/KinectPV2/src/KinectPV2/Device.java)

I also found that the specific joints I want to track are

    public final static int JointType_WristLeft     = 6;
    public final static int JointType_HandLeft      = 7;
    public final static int JointType_WristRight    = 10;
    public final static int JointType_HandRight     = 11;
    public final static int JointType_HandTipLeft   = 21;
    public final static int JointType_ThumbLeft     = 22;
    public final static int JointType_HandTipRight  = 23;
    public final static int JointType_ThumbRight    = 24;

from here (https://github.com/ThomasLengeling/KinectPV2/blob/master/KinectPV2/src/KinectPV2/SkeletonProperties.java)

Is anyone know to can I get these 8 specific joints I want to get and export them to 3d files? Or is there any other approach would be more simple to achieve my goal?

Many thanks!

Sign In or Register to comment.