diff --git a/oculus/WEB-INF/src/developer/OpenNIRead.java b/oculus/WEB-INF/src/developer/OpenNIRead.java index 9b7e033..c8bdda2 100644 --- a/oculus/WEB-INF/src/developer/OpenNIRead.java +++ b/oculus/WEB-INF/src/developer/OpenNIRead.java @@ -9,6 +9,7 @@ public class OpenNIRead implements IObserver{ private static Context context; private static DepthGenerator depth; private static DepthMetaData depthMD; + public boolean depthCamInit = false; @Override public void update(IObservable arg0, @@ -24,16 +25,29 @@ public void startDepthCam(Application app) { try { - OutArg scriptNodeArg = new OutArg(); - context = Context.createFromXmlFile(SAMPLES_XML, scriptNodeArg); - OpenNIRead pThis = new OpenNIRead(); - context.getErrorStateChangedEvent().addObserver(pThis); - depth = (DepthGenerator)context.findExistingNode(NodeType.DEPTH); - depthMD = new DepthMetaData(); + if (depthCamInit == false) { + OutArg scriptNodeArg = new OutArg(); + context = Context.createFromXmlFile(SAMPLES_XML, scriptNodeArg); + OpenNIRead pThis = new OpenNIRead(); + context.getErrorStateChangedEvent().addObserver(pThis); + depth = (DepthGenerator)context.findExistingNode(NodeType.DEPTH); + depthMD = new DepthMetaData(); + depthCamInit =true; + } + else { depth.startGenerating(); } } catch (Throwable e) { e.printStackTrace(); } } + public void stopDepthCam() { + try { + depth.stopGenerating(); + } catch (StatusException e) { + // TODO Auto-generated catch block + e.printStackTrace(); + } + } + public int[] readHorizDepth() { try { context.waitAnyUpdateAll(); diff --git a/oculus/WEB-INF/src/oculus/Application.java b/oculus/WEB-INF/src/oculus/Application.java index 5597575..f50042b 100755 --- a/oculus/WEB-INF/src/oculus/Application.java +++ b/oculus/WEB-INF/src/oculus/Application.java @@ -244,7 +244,6 @@ public void initialize() { // moves.open(Settings.movesfile); // new developer.EmailAlerts(this); openNIRead = new developer.OpenNIRead(); - openNIRead.startDepthCam(this); } // open socket last @@ -663,6 +662,11 @@ public void playerCallServer(final PlayerCommands fn, final String str) { } messageplayer("holdservo " + str, null, null); break; + case opennisensor: + if(str.equals("on")) { openNIRead.startDepthCam(this); } + else { openNIRead.stopDepthCam(); } + messageplayer("openNI camera "+str, null, null); + break; } } diff --git a/oculus/WEB-INF/src/oculus/FrameGrabHTTP.java b/oculus/WEB-INF/src/oculus/FrameGrabHTTP.java index fd40ef6..535b2e4 100644 --- a/oculus/WEB-INF/src/oculus/FrameGrabHTTP.java +++ b/oculus/WEB-INF/src/oculus/FrameGrabHTTP.java @@ -75,6 +75,9 @@ private void frameGrab(HttpServletRequest req, HttpServletResponse res) private void radarGrab(HttpServletRequest req, HttpServletResponse res) throws ServletException, IOException { + + if (app.openNIRead.depthCamInit == false) { return; } + //Util.log("getting frame depth info", this); int[] xdepth = app.openNIRead.readHorizDepth(); //Util.log("depth map width = "+Integer.toString(horizDepthDistances.length)); diff --git a/oculus/WEB-INF/src/oculus/PlayerCommands.java b/oculus/WEB-INF/src/oculus/PlayerCommands.java index 04d4968..8c63232 100644 --- a/oculus/WEB-INF/src/oculus/PlayerCommands.java +++ b/oculus/WEB-INF/src/oculus/PlayerCommands.java @@ -10,7 +10,7 @@ public enum PlayerCommands { new_user_add, user_list, delete_user, extrauser_password_update, username_update, disconnectotherconnections, showlog, monitor, assumecontrol, softwareupdate, arduinoecho, arduinoreset, setsystemvolume, beapassenger, muterovmiconmovetoggle, spotlightsetbrightness, - floodlight, writesetting, holdservo; + floodlight, writesetting, holdservo, opennisensor; // sub-set that are restricted to "user0" public enum AdminCommands { diff --git a/oculus/index.html b/oculus/index.html index a079f2d..262ca3e 100755 --- a/oculus/index.html +++ b/oculus/index.html @@ -866,8 +866,9 @@
Developer menu:
- -radar on / +primesense sensor on / +off
+radar view on / off
diff --git a/oculus/javascript/client.js b/oculus/javascript/client.js index 4cfcce3..d6e9504 100755 --- a/oculus/javascript/client.js +++ b/oculus/javascript/client.js @@ -2160,24 +2160,36 @@ function displaymessages() { var radartimer = null; function radar(mode) { - if (mode=="on") { + if (mode=="init") { + callServer("opennisensor", "on"); + message("sending opennisensor on " + str, sentcmdcolor); + lagtimer = new Date().getTime(); // has to be *after* message() + } + if (mode=="on") { var v = document.getElementById("video"); var xy = findpos(v); var x = xy[0]+v.offsetWidth; var y=xy[1]; - var str ="" - popupmenu("context", "show", x, y, str, null, 1, 0); +// var str ="" + var str ="" + + popupmenu('context', 'show', x, y, str, null, 1, 0); } if (mode=="off") { - clearTimeout(radartimer); + lagtimer = new Date().getTime(); // has to be *after* message() document.getElementById("radarimg").src=""; popupmenu("context", "close"); } + if (mode=="shutdown") { // unused + clearTimeout(radartimer); + callServer("opennisensor", "off"); + message("sending opennisensor off " + str, sentcmdcolor); + } } function radarrepeat() { clearTimeout(radartimer); - radartimer = setTimeout("document.getElementById('radarimg').src='frameGrabHTTP'; radarrepeat();", 100); + radartimer = setTimeout("document.getElementById('radarimg').src='frameGrabHTTP?"+new Date().getTime()+"'; radarrepeat();", 250); }