Intel RealSense

Hi, is someone experimenting now with the new camera Intel RealSense? I'm using it now, and the codes works well but when I generate the application it doesn't work :( Below an example, can someone help me to generate working application? Thanks M.

/** 
 **   This sample demonstrates how RealSense SDK Java interface work with Processing
 **   The sample traces hand positions with a Hand module. Red circle at the PXCMPointF32
 **/

import intel.rssdk.*;
import java.lang.System.*;
import java.util.*;
import javax.swing.*;
import java.awt.event.*;
import java.awt.image.*;
import java.awt.*;

int nframes = 0; 
PImage imgDepth = null; 
pxcmStatus sts = pxcmStatus.PXCM_STATUS_NO_ERROR;
PXCMSenseManager senseMgr = null;
PXCMHandData handData = null;

// *******************************************************************************
void setup() {
  size(640, 480, P2D);
 // registerDispose(this);

  //Create session
  PXCMSession session = PXCMSession.CreateInstance();
  if (session == null) {
    System.out.print("Failed to create a session instance\n");
    System.exit(3);
  }

  // Create SenseManager
  senseMgr = session.CreateSenseManager();
  if (senseMgr == null) {
    // print("Failed to create a SenseManager instance\n");
    return;
  }

  PXCMCaptureManager captureMgr = senseMgr.QueryCaptureManager();
  captureMgr.FilterByDeviceInfo("RealSense", null, 0);

  pxcmStatus sts = senseMgr.EnableHand(null);
  if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR)<0) {
    print("Failed to enable HandAnalysis\n");
    return;
  }

  sts = senseMgr.Init();
  if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR)>=0) {
    PXCMHandModule handModule = senseMgr.QueryHand(); 
    PXCMHandConfiguration handConfig = handModule.CreateActiveConfiguration(); 
    handConfig.EnableAllGestures();
    handConfig.EnableAllAlerts();
    handConfig.ApplyChanges();
    handConfig.Update();

    handData = handModule.CreateOutput();
  } else {
    // print("Failed to initial a RSSDK pipeline instance.\n");
    return;
  }

}
//***************************************************************************************************

void draw() { 

  // print ("Frame # " + nframes + "\n");
  sts = senseMgr.AcquireFrame(true);
  if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR)<0) return;

  nframes++;
  if (nframes==65535) nframes = 0;

  PXCMCapture.Sample sample = senseMgr.QueryHandSample();

  // Query and Display Joint of Hand or Palm
  handData.Update(); 

  PXCMHandData.IHand hand = new PXCMHandData.IHand(); 
  sts = handData.QueryHandData(PXCMHandData.AccessOrderType.ACCESS_ORDER_NEAR_TO_FAR, 0, hand);

  if (sts.compareTo(pxcmStatus.PXCM_STATUS_NO_ERROR) >= 0) {
    PXCMPointF32 image = hand.QueryMassCenterImage();

    // println("Palm Center at frame " + nframes + ": ");
    // print("   Image Position: (" + image.x + "," +image.y + ")");
    fill(255,0,0);
    ellipse(image.x,image.y,10,10);
  }

  senseMgr.ReleaseFrame();
}

void dispose() {
  if (senseMgr==null) return;
  senseMgr.close();
  senseMgr=null;
}

Comments

Sign In or Register to comment.