Exemplo n.º 1
0
  public void setup() {
    kinect = new KinectPV2(this);
    kinect.enableColorImg(true);
    kinect.enableInfraredImg(true);
    kinect.enableFaceDetection(true);

    kinect.init();
  }
Exemplo n.º 2
0
  public void draw() {
    background(0);

    kinect.generateFaceData();

    pushMatrix();
    scale(0.5f);
    image(kinect.getColorImage(), 0, 0);
    getFaceMapColorData();
    popMatrix();

    pushMatrix();
    translate(1920 * 0.5f, 0.0f);
    image(kinect.getInfraredImage(), 0, 0);
    getFaceMapInfraredData();
    popMatrix();

    fill(255);
    text("frameRate " + frameRate, 50, 50);
  }
Exemplo n.º 3
0
  public void getFaceMapInfraredData() {
    ArrayList<FaceData> faceData = kinect.getFaceData();

    for (int i = 0; i < faceData.size(); i++) {
      FaceData faceD = faceData.get(i);
      if (faceD.isFaceTracked()) {
        PVector[] facePointsInfrared = faceD.getFacePointsInfraredMap();

        KRectangle rectFace = faceD.getBoundingRectInfrared();

        FaceFeatures[] faceFeatures = faceD.getFaceFeatures();

        PVector nosePos = new PVector();
        noStroke();

        int col = getIndexColor(i);

        fill(col);
        for (int j = 0; j < facePointsInfrared.length; j++) {
          if (j == KinectPV2.Face_Nose)
            nosePos.set(facePointsInfrared[j].x, facePointsInfrared[j].y);

          ellipse(facePointsInfrared[j].x, facePointsInfrared[j].y, 15, 15);
        }

        if (nosePos.x != 0 && nosePos.y != 0)
          for (int j = 0; j < 8; j++) {
            int st = faceFeatures[j].getState();
            int type = faceFeatures[j].getFeatureType();

            String str = getStateTypeAsString(st, type);

            fill(255);
            text(str, nosePos.x + 150, nosePos.y - 70 + j * 25);
          }
        stroke(255, 0, 0);
        noFill();
        rect(rectFace.getX(), rectFace.getY(), rectFace.getWidth(), rectFace.getHeight());
      }
    }
  }