Exemplo n.º 1
0
  public synchronized void paint(Graphics g) {
    if (mLastFrame == null) {
      return;
    }

    int framePosX = 0;
    int framePosY = 0;

    VideoFrameRef depthFrame = mLastFrame.getDepthFrame();
    if (depthFrame != null) {
      int width = depthFrame.getWidth();
      int height = depthFrame.getHeight();

      // make sure we have enough room
      if (mBufferedImage == null
          || mBufferedImage.getWidth() != width
          || mBufferedImage.getHeight() != height) {
        mBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      }

      mBufferedImage.setRGB(0, 0, width, height, mDepthPixels, 0, width);

      framePosX = (getWidth() - width) / 2;
      framePosY = (getHeight() - height) / 2;

      g.drawImage(mBufferedImage, framePosX, framePosY, null);
    }

    for (UserData user : mLastFrame.getUsers()) {
      if (user.getSkeleton().getState() == SkeletonState.TRACKED) {
        drawLimb(g, framePosX, framePosY, user, JointType.HEAD, JointType.NECK);

        drawLimb(g, framePosX, framePosY, user, JointType.LEFT_SHOULDER, JointType.LEFT_ELBOW);
        drawLimb(g, framePosX, framePosY, user, JointType.LEFT_ELBOW, JointType.LEFT_HAND);

        drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_SHOULDER, JointType.RIGHT_ELBOW);
        drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_ELBOW, JointType.RIGHT_HAND);

        drawLimb(g, framePosX, framePosY, user, JointType.LEFT_SHOULDER, JointType.RIGHT_SHOULDER);

        drawLimb(g, framePosX, framePosY, user, JointType.LEFT_SHOULDER, JointType.TORSO);
        drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_SHOULDER, JointType.TORSO);

        drawLimb(g, framePosX, framePosY, user, JointType.LEFT_HIP, JointType.TORSO);
        drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_HIP, JointType.TORSO);
        drawLimb(g, framePosX, framePosY, user, JointType.LEFT_HIP, JointType.RIGHT_HIP);

        drawLimb(g, framePosX, framePosY, user, JointType.LEFT_HIP, JointType.LEFT_KNEE);
        drawLimb(g, framePosX, framePosY, user, JointType.LEFT_KNEE, JointType.LEFT_FOOT);

        drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_HIP, JointType.RIGHT_KNEE);
        drawLimb(g, framePosX, framePosY, user, JointType.RIGHT_KNEE, JointType.RIGHT_FOOT);
      }
    }
  }
  public synchronized void paint(Graphics g) {
    if (mLastFrame == null) {
      return;
    }

    int framePosX = 0;
    int framePosY = 0;

    VideoFrameRef depthFrame = mLastFrame.getDepthFrame();
    if (depthFrame != null) {
      int width = depthFrame.getWidth();
      int height = depthFrame.getHeight();

      // make sure we have enough room
      if (mBufferedImage == null
          || mBufferedImage.getWidth() != width
          || mBufferedImage.getHeight() != height) {
        mBufferedImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
      }

      mBufferedImage.setRGB(0, 0, width, height, mDepthPixels, 0, width);

      framePosX = (getWidth() - width) / 2;
      framePosY = (getHeight() - height) / 2;

      g.drawImage(mBufferedImage, framePosX, framePosY, null);
    }

    for (UserData user : mLastFrame.getUsers()) {
      if (user.getSkeleton().getState() == SkeletonState.TRACKED) {
        drawSkeleton(g, framePosX, framePosY, user);

        // spatial joint's coordinates
        //				giveMeSpatialCoordinateJoints(user);

        try {
          createSkeletonInstances(user);
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
      }

      if (user.getSkeleton().getState() == SkeletonState.TRACKED && startedTest) {
        try {
          createSkeletonInstances(user);
        } catch (Exception e) {
          // TODO Auto-generated catch block
          e.printStackTrace();
        }
        // System.out.println("send");
      }
    }
  }