Commit 3b79ea59 authored by Leigh Stoller's avatar Leigh Stoller

Some quickie hacks for Dave's Demo. Allow specification of a specific

camera, as well as its width, height, and fps. Tack these params onto
the robotrack URL:

	&camwidth=640&camheight=480&fps=2&camera=1

where camera is 0, 1, or 2 ... Dave can figure out which one he needs.
The allowed camera sizes are:

  640x480, 640x360, 480x360, 384x288, 352x288, 352x240, 320x240, 240x180

as defined by the axis HTTP API.
parent dd5b7e5e
......@@ -78,6 +78,13 @@ public class RoboTrack extends JApplet {
if (this.getParameter("WebCamCount") != null) {
int count =
Integer.parseInt(this.getParameter("WebCamCount").trim());
int height =
Integer.parseInt(this.getParameter("WebCamHeight").trim());
int width =
Integer.parseInt(this.getParameter("WebCamWidth").trim());
int fps =
Integer.parseInt(this.getParameter("WebCamFPS").trim());
WebCamWorkers = new WebCam[count];
System.out.println("There are " + count + " webcams");
......@@ -92,6 +99,9 @@ public class RoboTrack extends JApplet {
camurl = new URL(urlServer,
this.getParameter(camname)
+ "&camheight=" + height
+ "&camwidth=" + width
+ "&camfps=" + fps
+ "&nocookieuid="
+ URLEncoder.encode(uid)
+ "&nocookieauth="
......@@ -104,7 +114,7 @@ public class RoboTrack extends JApplet {
y = Integer.parseInt(tokens.nextToken().trim());
WebCamWorkers[WebCamCount] =
new WebCam(WebCamCount, camurl, x, y);
new WebCam(WebCamCount, camurl, width, height, x, y);
WebCamCount++;
}
}
......@@ -2169,13 +2179,14 @@ public class RoboTrack extends JApplet {
private InputStream is = null;
public int X, Y, W, H;
public WebCam(int id, URL webcamurl, int x, int y) {
public WebCam(int id, URL webcamurl,
int width, int height, int x, int y) {
myid = id;
myurl = webcamurl;
X = x;
Y = y;
W = 240;
H = 180;
W = width;
H = height;
System.out.println("Creating a WebCam class: " +
id + "," + X + "," + Y);
......
......@@ -85,19 +85,37 @@ else {
USERERROR("No such building/floor $building/$floor", 1);
}
#
# Some stuff to control the camera.
#
if (! isset($camheight) || !TBvalid_integer($camheight)) {
$camheight = 180;
}
if (! isset($camwidth) || !TBvalid_integer($camwidth)) {
$camwidth = 240;
}
if (! isset($camfps) || !TBvalid_integer($camfps)) {
$camfps = 2;
}
#
# If adding in the webcams, get that stuff too.
#
$webcams = array();
if ($withwebcams) {
$query_result = DBQueryFatal("select * from webcams");
if (isset($camera) && TBvalid_integer($camera)) {
$query_result = DBQueryFatal("select * from webcams ".
"where id='$camera'");
}
else
$query_result = DBQueryFatal("select * from webcams");
while ($row = mysql_fetch_array($query_result)) {
$id = $row["id"];
$camurl = "../webcamimg.php3?webcamid=${id}&applet=1&fromtracker=1";
$webcams[] = $camurl;
}
while ($row = mysql_fetch_array($query_result)) {
$id = $row["id"];
$camurl = "../webcamimg.php3?webcamid=${id}&applet=1&fromtracker=1";
$webcams[] = $camurl;
}
}
#
......@@ -184,6 +202,10 @@ echo "<applet name='tracker' code='RoboTrack.class'
<param name='building' value='$building'>
<param name='floor' value='$floor'>";
if (count($webcams)) {
echo "<param name='WebCamHeight' value=$camheight>
<param name='WebCamWidth' value=$camwidth>
<param name='WebCamFPS' value=$camfps>\n";
$camcount = count($webcams);
$x = 400;
$y = 460;
......@@ -196,11 +218,11 @@ if (count($webcams)) {
echo "<param name='WebCam${i}' value='$camurl'>
<param name='WebCam${i}XY' value='$x,$y'>";
$x += 260;
$x += ($camwidth + 20);
if ($x > 700) {
$x = 400;
$y = $y + 200;
$y = $y + ($camheight + 20);
}
}
}
......
......@@ -52,13 +52,25 @@ if (!$query_result || !mysql_num_rows($query_result)) {
$row = mysql_fetch_array($query_result);
$URL = (isset($applet) ? $row["URL"] : $row["stillimage_URL"]);
if (isset($fromtracker)) {
$URL .= "&resolution=240x180";
#
# Some stuff to control the camera.
#
if (! isset($camheight) || !TBvalid_integer($camheight)) {
$camheight = 180;
}
if (! isset($camwidth) || !TBvalid_integer($camwidth)) {
$camwidth = 240;
}
if (! isset($camfps) || !TBvalid_integer($camfps)) {
$camfps = 2;
}
$URL .= "&resolution=${camwidth}x${camheight}";
if (preg_match("/fps=\d*/", $URL)) {
$URL = preg_replace("/fps=\d*/", "fps=2", $URL);
$URL = preg_replace("/fps=\d*/", "fps=${camfps}", $URL);
}
else {
$URL .= "&fps=2";
$URL .= "&fps=${camfps}";
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment