We closed this forum 18 June 2010. It has served us well since 2005 as the ALPHA forum did before it from 2002 to 2005. New discussions are ongoing at the new URL http://forum.processing.org. You'll need to sign up and get a new user account. We're sorry about that inconvenience, but we think it's better in the long run. The content on this forum will remain online.
Page Index Toggle Pages: 1
video capture and embedded PApplet (Read 910 times)
video capture and embedded PApplet
May 23rd, 2010, 11:49pm
 
hi all,
I am trying to create some Java code that I can embed in another application I am writing. The capture code works fine when run from within processing, but outside of this environment I am seeing a black screen. It appears that captureEvent is never being called????? ANy help greatly appreciated. Code below:

import processing.core.* ;
import processing.video.*;
import java.awt.Frame ;
import java.awt.BorderLayout ;

public class ExampleFrame extends Frame {

    public static void main (String[] arrImAPirate) {
       ExampleFrame exF = new ExampleFrame();
       exF.pack();
       exF.setVisible(true);
   }
   
   public ExampleFrame() {
        super("Embedded PApplet");
        setLayout(new BorderLayout());
        PApplet embed = new Embedded();
        add(embed, BorderLayout.CENTER);
        embed.init();
    }
}

class Embedded extends PApplet {

    Capture myCapture;
      PImage p ;

     public void setup() {
           size(200, 200);
           println(Capture.list());
           myCapture = new Capture((PApplet)this, width, height, "DV Video", 30);
    }
     void captureEvent(Capture myCapture) {
       println("captureEvent .....");
       myCapture.read();
     }
    public void draw() {
        image(myCapture, 0, 0);
    }
    public void mousePressed() {
           ((PImage)myCapture).save("imgVideo.jpg");
         println("saved") ;
    }
}
Page Index Toggle Pages: 1