Hardware Reference
In-Depth Information
Now when you load this script in a
browser and upload a file, you'll be able
to see the file in the directory after-
wards. Try uploading a new JPEG of the
cat, then reload the browser window of
the index.html page you made earlier.
You should see the same page with the
new image.
8
Continued from previous page.
// if there's no file error, print some HTML about the file:
else {
echo "Upload: " . $fileName . "<br />";
echo "Type: " . $fileType . "<br />";
echo "Size: " . ($fileSize / 1024) . " Kb<br />";
echo "Temp file: " . $fileTempName . "<br />";
// if the file already exists,
// delete the previous version:
if (file_exists($fileName)) {
unlink($fileName);
}
// move the file from the temp location to
// this directory:
move_uploaded_file($fileTempName, $fileName);
echo "Uploaded file stored as: ".$fileName;
}
}
// if the file's not a JPEG or too big, say so:
else {
echo "File is not a JPEG or too big.";
}
}
?>
For Windows 7 users, you'll need to install QuickTime, if
you don't have it already. Download it from http://www.
apple.com/quicktime and follow the installer directions.
You'll also need a VDIG, which is a software library that
allows Processing to connect to the webcam through
QuickTime. You can download WinVDIG from http://
www.eden.net.nz/7/20071008/ . Use version 1.0.1, as it's
the most stable as of this writing. Finally, you'll need to
change the Compatibility settings for Processing. Open
the Processing application directory, right-click on the
Processing application icon, and choose Properties. In
the application's Properties window, choose the Compat-
ibility tab. In that tab, click the checkbox marked “Run this
program in compatibility mode for:”, and from the associ-
ated drop-down menu, choose “Windows XP (service pack
3)”. Then click Apply, and you're ready to move on. The
Processing team hopes to change this soon, so it may be
much simpler by the time you read this.
Capturing an Image and
Uploading It Using Processing
Now that you've got an uploader script on the server,
you need a program on your local computer to capture a
picture of the cat and to call the script. There are several
automated webcam applications on the market, but it's
fun to do it on your own. This section will describe how
you can do it in Processing using two external libraries: the
Processing video library and the Processing net library.
Before you get going, there are a few things you'll need
to do. First, make sure your webcam can be read by both
your computer and by Processing.
If you're using Mac OS X, you're all set. The Process-
ing video library works with QuickTime, which comes
with your computer. Open a video applicatio,n like Photo
Booth, just to make sure it's working, then you're ready to
program.
For Ubuntu Linux users, you're out of luck this time. The
Processing video library is not currently supported under
Linux, though the developers welcome patches for this.
 
Search WWH ::




Custom Search