-
-
Save TheVisualG/1a06ecc6da3741a61256b493709741e4 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import processing.video.*; | |
Capture cam; | |
void setup() { | |
size(1280, 960); | |
String[] cameras = Capture.list(); | |
if (cameras == null) { | |
println("Failed to retrieve the list of available cameras, will try the default..."); | |
cam = new Capture(this, 640, 480); | |
} if (cameras.length == 0) { | |
println("There are no cameras available for capture."); | |
exit(); | |
} else { | |
println("Available cameras:"); | |
printArray(cameras); | |
// The camera can be initialized directly using an element | |
// from the array returned by list(): | |
cam = new Capture(this, cameras[80]); | |
// Or, the settings can be defined based on the text in the list | |
//cam = new Capture(this, 640, 480, "Built-in iSight", 30); | |
// Start capturing the images from the camera | |
cam.start(); | |
} | |
} | |
void draw() { | |
if (cam.available() == true) { | |
cam.read(); | |
} | |
image(cam, 0, 0, width, height); | |
// The following does the same as the above image() line, but | |
// is faster when just drawing the image without any additional | |
// resizing, transformations, or tint. | |
//set(0, 0, cam); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment