@Override
  public Object execute(ExecutionEvent event) throws ExecutionException {
    if (KinectManager.INSTANCE.isSkeletonTrackingStarted()) {

      try {
        Notifier km = KinectManager.INSTANCE.getSkeletonModel();
        IncQueryEngine e = IncQueryEngine.on(km);
        // ymca demo
        new IncQueryMatcherHelper(YMatcher.on(e));
        new IncQueryMatcherHelper(MMatcher.on(e));
        new IncQueryMatcherHelper(CMatcher.on(e));
        new IncQueryMatcherHelper(AMatcher.on(e));
        new IncQueryMatcherHelper(IMatcher.on(e));
        new IncQueryMatcherHelper(QMatcher.on(e));
        // robot demo
        new IncQueryMatcherHelper(FSMatcher.on(e));
        new IncQueryMatcherHelper(FEMatcher.on(e));
        new IncQueryMatcherHelper(BSMatcher.on(e));
        new IncQueryMatcherHelper(BEMatcher.on(e));
        // sheldon demo
        new IncQueryMatcherHelper(SEMatcher.on(e));
        new IncQueryMatcherHelper(SMMatcher.on(e));
        new IncQueryMatcherHelper(SEMatcher.on(e));

      } catch (IncQueryException e) {
        e.printStackTrace();
      }

    } else {
      System.out.println("Start skeleton simulator first!");
    }
    return null;
  }
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   if (KinectManager.INSTANCE.isSkeletonTrackingStarted()) {
     //			try {
     //				Notifier km = KinectManager.INSTANCE.getSkeletonModel();
     //
     //				// adapters for the YMCA demo
     //				new EsperAdapter(YMatcher.factory().getMatcher(km));
     //				new EsperAdapter(MMatcher.factory().getMatcher(km));
     //				new EsperAdapter(CMatcher.factory().getMatcher(km));
     //				new EsperAdapter(AMatcher.factory().getMatcher(km));
     //				new EsperAdapter(IMatcher.factory().getMatcher(km));
     //				new EsperAdapter(QMatcher.factory().getMatcher(km));
     //
     //
     //			} catch (IncQueryException e) {
     //				e.printStackTrace();
     //			}
     EsperManager.getInstance().registerYMCAListeners();
   } else {
     System.out.println("Start skeleton simulator first!");
   }
   return null;
 }
예제 #3
0
  public void printLeftHandPosition() throws InterruptedException {
    KinectManager.INSTANCE.startKinect();
    KinectManager.INSTANCE.startSkeletonTracking();
    // System.out.println("avant boucle") ;

    float Aarbis = 400; // au delà de 360 pour etre sur que Aarbis différent
    // de AAr au départ

    while (isAlive) { // en attendant que l'on trouve une solution pour
      // changer isALive en false. A priori bouton
      // eclipse.

      Body body = KinectManager.INSTANCE.getSkeletonModel();

      float Xrh = (float) body.getRightHand().getX();
      float Yrh = (float) body.getRightHand().getY();
      float Xlh = (float) body.getLeftHand().getX();
      float Ylh = (float) body.getLeftHand().getY();
      float Xch = (float) body.getCenterHip().getX();
      float Ych = (float) body.getCenterHip().getY();
      float Xrs = (float) body.getRightShoulder().getX();
      float Yrs = (float) body.getRightShoulder().getY();
      float Xls = (float) body.getLeftShoulder().getX();
      float Yls = (float) body.getRightShoulder().getY();

      /*
       * if (body.getHead().getX()==0){ i++;} else { i=0;} if (i==2000){
       * isAlive=false; }
       */

      float produitScalaire = (Xrh - Xrs) * (Xlh - Xls) + (Yrh - Yrs) * (Ylh - Yls);
      float normeR = (float) Math.sqrt((Xrh - Xrs) * (Xrh - Xrs) + (Yrh - Yrs) * (Yrh - Yrs));
      float normeL = (float) Math.sqrt((Xlh - Xls) * (Xlh - Xls) + (Ylh - Yls) * (Ylh - Yls));
      float produitNorme = normeR * normeL;
      float Aar = (float) (Math.acos(produitScalaire / produitNorme) * 180 / Math.PI);

      if (Aar != Aarbis && Ych != 0) {
        Aarbis = Aar;

        System.out.println(
            "leftHand x: "
                + body.getLeftHand().getX()
                + "|leftHand y: "
                + body.getLeftHand().getY()
                + "|leftHand z: "
                + body.getLeftHand().getZ()
                + "|rightHand x: "
                + body.getRightHand().getX()
                + "|rightHand y: "
                + body.getRightHand().getY()
                + "|rightHand z: "
                + body.getRightHand().getZ()
                + "|centerHip x: "
                + body.getCenterHip().getX()
                + "|centerHip y: "
                + body.getCenterHip().getY()
                + "|centerHip z: "
                + body.getCenterHip().getZ()
                + "|head x: "
                + body.getHead().getX()
                + "|Head y: "
                + body.getHead().getY()
                + "|head z: "
                + body.getHead().getZ()
                + "angle "
                + Aar);
        System.out.println();

        try {

          pw.append(
              "leftHand x: "
                  + body.getLeftHand().getX()
                  + " leftHand y: "
                  + body.getLeftHand().getY()
                  + " leftHand z: "
                  + body.getLeftHand().getZ()
                  + System.getProperty("line.separator")
                  + "rightHand x: "
                  + body.getRightHand().getX()
                  + " rightHand y: "
                  + body.getRightHand().getY()
                  + " rightHand z: "
                  + body.getRightHand().getZ()
                  + System.getProperty("line.separator")
                  + "centerHip x: "
                  + body.getCenterHip().getX()
                  + " centerHip y: "
                  + body.getCenterHip().getY()
                  + " centerHip z: "
                  + body.getCenterHip().getZ()
                  + System.getProperty("line.separator")
                  + "head x: "
                  + body.getHead().getX()
                  + " Head y: "
                  + body.getHead().getY()
                  + " head z: "
                  + body.getHead().getZ()
                  + System.getProperty("line.separator")
                  + "angle "
                  + Aar
                  + System.getProperty("line.separator")
                  + System.getProperty("line.separator"));
          pw.flush();

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

          // Thread.sleep(100);
        }
      }
    }

    KinectManager.INSTANCE.stopKinect();
  }
예제 #4
0
 @Override
 public Object execute(ExecutionEvent event) throws ExecutionException {
   KinectManager.INSTANCE.startKinect();
   return null;
 }