Quantcast
Channel: Processing Forum
Viewing all articles
Browse latest Browse all 1768

Capture 2 pictures of users and display both of the picture on screen

$
0
0
Hi, I am trying write a program to take pictures of the user then show the pictures on the screen. 
  1. import processing.video.*;

  2. Capture cam;
  3. Capture cam1;
  4. int count=0;
  5. PImage img;
  6. void setup() {
  7.   size(1000, 480);
  8.   img = loadImage("background.jpg");

  9.   String[] cameras = Capture.list();
  10.   
  11.   if (cameras.length == 0) {
  12.     println("There are no cameras available for capture.");
  13.     exit();
  14.   } else {
  15.     println("Available cameras:");
  16.     for (int i = 0; i < cameras.length; i++) {
  17.       println(cameras[i]);
  18.     }
  19.     
  20.     // The camera can be initialized directly using an 
  21.     // element from the array returned by list():
  22.     cam = new Capture(this, cameras[0]);
  23.     cam.start();  
  24.      cam1 = new Capture(this, cameras[0]);
  25.     cam1.start();     
  26.   }      
  27. }

  28. void draw() {
  29.  background(255);
  30.   if (count==1){
  31.       if (cam.available() == true) {
  32.     cam.read();
  33.       }

  34.   }else{
  35.        image(img, 0, 0);
  36.   }
  37.   if (key=='7'){
  38.      if (cam.available() == true) {
  39.     cam.read();
  40.     image(cam, 100, 300, 160,120); 
  41.   }
  42.   
  43.   }
  44.     if (key=='9'){
  45.      if (cam.available() == true) {
  46.     cam.read(); 
  47.     image(cam, 400, 300, 160,120);
  48.   }
  49.   // The following does the same, and is faster when just drawing the image
  50.   // without any additional resizing, transformations, or tint.
  51.   //set(0, 0, cam);
  52. }
  53. }
  54. void keyPressed(){  
  55.   
  56.   if (key==1){
  57.   if (count==1){
  58.     
  59.    count=0; 
  60.   }
  61.   }
  62.   
  63. }
How can I do it?

Viewing all articles
Browse latest Browse all 1768

Trending Articles