profilen
YaBB Newbies
Offline
Posts: 5
Sweden
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..