Hi, I am trying write a program to take pictures of the user then show the pictures on the screen.
- import processing.video.*;
- Capture cam;
- Capture cam1;
- int count=0;
- PImage img;
- void setup() {
- size(1000, 480);
- img = loadImage("background.jpg");
- String[] cameras = Capture.list();
- if (cameras.length == 0) {
- println("There are no cameras available for capture.");
- exit();
- } else {
- println("Available cameras:");
- for (int i = 0; i < cameras.length; i++) {
- println(cameras[i]);
- }
- // The camera can be initialized directly using an
- // element from the array returned by list():
- cam = new Capture(this, cameras[0]);
- cam.start();
- cam1 = new Capture(this, cameras[0]);
- cam1.start();
- }
- }
- void draw() {
- background(255);
- if (count==1){
- if (cam.available() == true) {
- cam.read();
- }
- }else{
- image(img, 0, 0);
- }
- if (key=='7'){
- if (cam.available() == true) {
- cam.read();
- image(cam, 100, 300, 160,120);
- }
- }
- if (key=='9'){
- if (cam.available() == true) {
- cam.read();
- image(cam, 400, 300, 160,120);
- }
- // The following does the same, and is faster when just drawing the image
- // without any additional resizing, transformations, or tint.
- //set(0, 0, cam);
- }
- }
- void keyPressed(){
- if (key==1){
- if (count==1){
- count=0;
- }
- }
- }