Skip to content

Commit

Permalink
tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
[email protected] committed Jan 19, 2012
1 parent 22665b2 commit 6c5f319
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 15 deletions.
26 changes: 20 additions & 6 deletions oculus/WEB-INF/src/developer/OpenNIRead.java
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public class OpenNIRead implements IObserver<ErrorStateEventArgs>{
private static Context context;
private static DepthGenerator depth;
private static DepthMetaData depthMD;
public boolean depthCamInit = false;

@Override
public void update(IObservable<ErrorStateEventArgs> arg0,
Expand All @@ -24,16 +25,29 @@ public void startDepthCam(Application app) {

try
{
OutArg<ScriptNode> scriptNodeArg = new OutArg<ScriptNode>();
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<ScriptNode> scriptNodeArg = new OutArg<ScriptNode>();
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();
Expand Down
6 changes: 5 additions & 1 deletion oculus/WEB-INF/src/oculus/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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;
}
}

Expand Down
3 changes: 3 additions & 0 deletions oculus/WEB-INF/src/oculus/FrameGrabHTTP.java
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion oculus/WEB-INF/src/oculus/PlayerCommands.java
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
5 changes: 3 additions & 2 deletions oculus/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -866,8 +866,9 @@
<table><tr><td style="height: 10px"></td></tr></table>
Developer menu:<br>
<table><tr><td style="height: 7px"></td></tr></table>

radar <a class="blackbg" href="javascript: radar('on');">on</a> /
primesense sensor <a class="blackbg" href="javascript: radar('init');">on</a> /
<a class="blackbg" href="javascript: radar('shutdown');">off</a><br>
radar view <a class="blackbg" href="javascript: radar('on');">on</a> /
<a class="blackbg" href="javascript: radar('off');">off</a><br>

</div>
Expand Down
22 changes: 17 additions & 5 deletions oculus/javascript/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 ="<img id='radarimg' src='frameGrabHTTP' alt='' onload='radarrepeat();' width='240' height='320'>"
popupmenu("context", "show", x, y, str, null, 1, 0);
// var str ="<img id='radarimg' src='frameGrabHTTP' alt='' onload='radarrepeat();' width='240' height='320'>"
var str ="<img id='radarimg' src='frameGrabHTTP?"+new Date().getTime()+"' alt='' onload='radarrepeat();' width='240' height='320'>"

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);
}


Expand Down

0 comments on commit 6c5f319

Please sign in to comment.