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
Capture in class (Read 470 times)
Capture in class
Nov 24th, 2006, 9:37am
 
Hi..

Trying to use a web-camera to capture video by defining it in a class. But cant get it to work? Im getting a Null Pointer Exception.

---------------------the class ------------------------

import processing.video.*;

class CameraComponent /*extends GUIComponent for later use */
{
 
 private Capture myCamera;
 private PApplet p;
 private String cameraBrand;
 private int cameraFrameRate;
 private int resolutionWidth;
 private int resolutionHeight;
 


 /* testing */
 private float xPos;
 private float yPos;
 private float componentWidth;
 private float componentHeight;
 private color backgroundColor;
 private PImage backgroundImage;
 
 
 //Constructor
 CameraComponent(float theXPos, float theYPos, String theIdentifier, float theWidth, float theHeight, String theCameraBrand, int theResolutionWidth,
 int theResolutionHeight, int theFrameRate)
 {
   xPos = theXPos;
   yPos = theYPos;
   componentWidth = theWidth;
   componentHeight = theHeight;
   cameraBrand = theCameraBrand;
   resolutionWidth = theResolutionWidth;
   resolutionHeight = theResolutionHeight;
   cameraFrameRate = theFrameRate;
   cameraSetup();
 
 }

 //methods

 public void cameraSetup()
 {
 myCamera = new Capture(p,cameraBrand,100,100,10);  
 }

 public void componentDraw(){
 myCamera.read();    
 image(myCamera,0,0);  
 }

--------------------END CLASS -----------------------------


--------------------Test Program---------------------------

CameraComponent c;

void setup()
{
size(600,600,P3D);
c =  new CameraComponent(0.0, 0.0, "camera", 100.0, 100.0,"Philips SPC 900NC PC Camera-WDM", 100,100,30);
}

void draw()
{
c.componentDraw();
}  

Plz help..

Re: Capture in class
Reply #1 - Nov 24th, 2006, 10:01am
 
Solved it me self...Forgott the PApplet pointer (this);

in test:
c =  new CameraComponent(this,0.0, 0.0, "camera", 100.0, 100.0,"Philips SPC 900NC PC Camera-WDM", 100,100,30);

in constructor:

CameraComponent(PApplet theP,float theXPos, float theYPos, String theIdentifier, float theWidth, float theHeight, String theCameraBrand, int theResolutionWidth,
 int theResolutionHeight, int theFrameRate)
 {
   p = theP;


where p is a PApplet.
Page Index Toggle Pages: 1