FAQ
Cover
This is the archive Discourse for the Processing (ALPHA) software.
Please visit the new Processing forum for current information.

   Processing 1.0 _ALPHA_
   Topics & Contributions
   Video, Camera
(Moderator: REAS)
   video in jar
« Previous topic | Next topic »

Pages: 1 
   Author  Topic: video in jar  (Read 557 times)
lars


video in jar
« on: Sep 15th, 2004, 8:17pm »

I have been trying to make a full screen video application following the instructions on
 
http://processing.org/discourse/yabb/board_Tools_action_display__num_1074127030_start_15.html
 
I include the BVideo.class, BVideo$Handler.class and the comm.jar in my mirrorCam2.jar
 
I have made a batch file containing:
start javaw -cp mirrorCam2.jar mirrorCam2
 
but when I start it, I get the following error:
"Fatal exception occured. Program will exit."
 
Do you know how I can get this to work - here is my code:
 
// mirrorCam2
// by lars <http://www.larsjessen.dk>
 
// Compares the frame captures from the camera to a reference image. For a new reference image press the mouse
 
// Created 15 Sep 2004
 
// full-screen main function edit by Tom Carden  
// originally provided by michael05  
static public void main(String args[]) {  
  try {  
    Frame frame = new Frame();  
   
    // !!!  
    // change this to your sketch name...  
    Class c = Class.forName("mirrorCam2");  
    BApplet applet = (BApplet) c.newInstance();  
    applet.init();  
    applet.start();  
   
    // get default screendevice and configuration  
    GraphicsDevice gd = GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice   ();  
    GraphicsConfiguration gc = gd.getDefaultConfiguration();  
   
    frame.setUndecorated(true);  
    frame.setBackground(Color.black);  
    frame.setLayout(new GridBagLayout());  
    frame.add(applet);  
    frame.pack();  
   
    // test if fullscreen mode is available (jvm 1.4+) and activate it  
    if (gd.isFullScreenSupported()) {  
 gd.setFullScreenWindow(frame);  
    }  
    // test if display mode is available (jvm 1.4+) and set it to the  
    // size of the applet  
    if (gd.isDisplayChangeSupported()) {  
 gd.setDisplayMode(new DisplayMode(applet.g.width, applet.g.height, 32, 0));  
    }  
   
    frame.setLocation(0, 0);  
    frame.show();  
    applet.requestFocus();  
   
    frame.addWindowListener(new WindowAdapter() {  
 public void windowClosing(WindowEvent e) {  
   System.exit(0);  
 }  
    });  
   
  } catch (Exception e) {  
    e.printStackTrace();  
    System.exit(1);  
  }  
}  
//end of full screen code
 
int xpos = 0;
int ypos = 0;
int captureWidth = 640;
int captureHeight = 480;
color[] pixelArray;
boolean newFrame = false;
int motionCounter = 0;
 
void setup()
{
  size(640, 480);
  beginVideo(captureWidth, captureHeight, 20);
  pixelArray = new int[captureWidth*captureHeight];
  framerate(20);
  for(int i=0; i<(captureWidth*captureHeight); i++) {
    pixelArray[i] = video.pixels[i];
  }
}
 
void videoEvent()
{
  newFrame = true;
}
 
void loop()
{
  if(newFrame) {
    int index = 0;
    for(int i=0; i<captureHeight; i++) {
 for(int ii=0; ii<captureWidth; ii++) {
   
   color c;
   int pixelCompare;
   
   pixelCompare = (int) ( abs( red(pixelArray[index]) - red(video.pixels[index])) + abs( green(pixelArray[index]) - green(video.pixels[index])) + abs( blue(pixelArray[index]) - blue(video.pixels[index])) );
   if(pixelCompare > 75) {
     //motionCounter = motionCounter + 1;
     set(ii,i, video.pixels[index]);//c = color(255,255,255);
   } else {
     set(ii,i, color(0,0,0) );
   }
 
   index++;
 }
    }
    //println("motion: " + motionCounter);
    motionCounter = 0;
    newFrame = false;
  }  
 
}
 
void mousePressed() {
  for(int i=0; i<(captureWidth*captureHeight); i++) {
    pixelArray[i] = video.pixels[i];
  }
 
Pages: 1 

« Previous topic | Next topic »