Hardware Reference
In-Depth Information
Now add a global variable at the
top of your sketch for a filename, and
add a method at the end of the sketch
to save the window image to a JPEG
file when you hit any key (new lines are
shown in blue).
8
import processing.video.*; // import the video library
Capture myCam; // the camera
String fileName = "catcam.jpg";
// setup and draw methods go here
void keyReleased() {
PImage img = get();
img.save(fileName);
}
Save this sketch before you run it.
When you run it, hit any key. Then
check the sketch folder, and you should
see a JPEG image generated by the
sketch, like Figure 3-13.
Figure 3-13
The output of the Cat Cam Pro-
cessing sketch.
Next, it's time to add a method
that can make an HTTP POST
request. For that, you'll need the Pro-
cessing network library . Like the serial
library, it adds some functions to the
core of Processing. The serial library
allowed you to access the serial ports;
the network library allows you to make
network connections and a few more
global variables. Add these before the
setup() method.
8
import processing.net.*;
String pictureScriptUrl = "/save2web.php";
String boundary = "----H4rkNrF";
Client thisClient;
 
Search WWH ::




Custom Search