How to export Video in good quality in Point Cloud mode?

edited October 2015 in Kinect

Hi, I am fresh in Processing and Kinect, but I played little bit with Point Cloud sketch. I would like to export this point cloud preview as video. I tried to find tutorial on youtube and google but I coudn't find solution for that. What code I should write to export that preview? The oryginal Sketch is:

        /*
        Copyright (C) 2014  Thomas Sanchez Lengeling.
         KinectPV2, Kinect for Windows v2 library for processing
        */

        import java.nio.FloatBuffer;

        import KinectPV2.*;
        import javax.media.opengl.GL2;

        private KinectPV2 kinect;

        float a = 0;
        int zval = 50;
        float scaleVal = 260;

        //Distance Threashold
        float maxD = 4.0f; //meters
        float minD = 1.0f;

        public void setup() {
          size(1366, 768, P3D);

          kinect = new KinectPV2(this);
          kinect.enableDepthImg(true);
          kinect.enablePointCloud(true);
          kinect.activateRawDepth(true);

          kinect.setLowThresholdPC(minD);
          kinect.setHighThresholdPC(maxD);

          kinect.init();
        }

        public void draw() {
          background(0);

          //image(kinect.getDepthImage(), 0, 0, 320, 240);

          //Threahold of the point Cloud.
          kinect.setLowThresholdPC(minD);
          kinect.setHighThresholdPC(maxD);

          FloatBuffer pointCloudBuffer = kinect.getPointCloudDepthPos();

          PJOGL pgl = (PJOGL)beginPGL();
          GL2 gl2 = pgl.gl.getGL2();

          gl2.glEnable( GL2.GL_BLEND );
          gl2.glEnable(GL2.GL_POINT_SMOOTH);      

          gl2.glEnableClientState(GL2.GL_VERTEX_ARRAY);
          gl2.glVertexPointer(3, GL2.GL_FLOAT, 0, pointCloudBuffer);

          gl2.glTranslatef(width/2, height/2, zval);
          gl2.glScalef(scaleVal, -1*scaleVal, scaleVal);
          gl2.glRotatef(a, 0.0f, 1.0f, 0.0f);

          gl2.glDrawArrays(GL2.GL_POINTS, 0, kinect.WIDTHDepth * kinect.HEIGHTDepth);
          gl2.glDisableClientState(GL2.GL_VERTEX_ARRAY);
          gl2.glDisable(GL2.GL_BLEND);
          endPGL();

          stroke(255, 0, 0);
          text(frameRate, 50, height- 50);
        }

        public void mousePressed() {

          println(frameRate);
         // saveFrame();
        }

        public void keyPressed() {
          if (key == 'a') {
            zval +=1;
            println(zval);
          }
          if (key == 's') {
            zval -= 1;
            println(zval);
          }

          if (key == 'z') {
            scaleVal += 0.1;
            println(scaleVal);
          }
          if (key == 'x') {
            scaleVal -= 0.1;
            println(scaleVal);
          }

          if (key == 'q') {
            a += 1;
            println(a);
          }
          if (key == 'w') {
            a -= 1;
            println(a);
          }

          if (key == '1') {
            minD += 0.01;
            println("Change min: "+minD);
          }

          if (key == '2') {
            minD -= 0.01;
            println("Change min: "+minD);
          }

          if (key == '3') {
            maxD += 0.01;
            println("Change max: "+maxD);
          }

          if (key == '4') {
            maxD -= 0.01;
            println("Change max: "+maxD);
          }

          if (key == '2') {
            minD -= 0.01;
            println("Change min: "+minD);
          }

          if (key == '3') {
            maxD += 0.01;
            println("Change max: "+maxD);
          }

          if (key == '4') {
            maxD -= 0.01;
            println("Change max: "+maxD);
          }
        }

Answers

Sign In or Register to comment.