How sync a Camera from a new pop-up window with the one from the main window?

edited April 2015 in Library Questions

Hi, im just making a interface that a camera from a new pop-up window with the one from the main window can make sync. I just got show the camera in new window, but it is a static frame, and meanwhile ,the main window´s camera is showing a dynamic frames. If anybody can tell me where is error, thanks!

here is the code:



import processing.video.*;

import javax.swing.JFrame;

PFrame f = null;
SecondApplet s;

Capture cam1;
 

void setup(){
  
  size(670, 400);

  
   f = new PFrame(); 
   
   String[] cameras = Capture.list();

  if (cameras == null) 
 {
    println("Failed to retrieve the list of available cameras, will try the default...");

    cam1 = new Capture(this, 720, 576);
  } 

 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():

    cam1 = new Capture(this, cameras[3]);

    // Start capturing the images from the camera
    cam1.start();

  }

}

void draw() 
{
  
  background(255, 0, 0);
   fill(255);
  
  image(cam1,340, 20, 300,300);
  s.image(cam1, 450,10, 300,300);
  
  if ((cam1.available() == true) ) 
 { 
    cam1.read();
  }

}     

public class SecondApplet extends PApplet 
 {
  public void setup() {
    
    background(0);
    
  }
  public void draw() {
   
  }

}

public class PFrame extends JFrame {
  
  public PFrame() {

    setBounds(0, 0, 800, 400);
    s = new SecondApplet();
    add(s);
    s.init();
    println("birh");
    show();
  }
  
}


Answers

Sign In or Register to comment.