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
putting Capture into a Class (Read 478 times)
putting Capture into a Class
Jul 28th, 2006, 9:37pm
 
As a OOP newbie, I'm not able to get the video capture function working when called from within a class. I'm sure I'm having some basic syntax issues and I'm hoping someone who knows OOP might help me.

Here is working plain vanilla 'procedural' webcam display code:


import processing.video.*;

Capture theCamera;

void setup()
{
 size(200, 200);
 theCamera = new Capture(this, 320, 240, 30);
}

void captureEvent(Capture camera)
{
 theCamera.read();
}

void draw()
{
 image(thisCamera, 0, 0,)
}



Here is an attempt to put that into a class called Digitizer:

import processing.video.*;

Digitizer digi;

void setup()
{
 size(200, 200);  
 digi = new Digitizer();
}


void draw()
{
digi.read();
}

public class Digitizer
{

Capture theCamera;

// constructor
Digitizer () {
 theCamera = new Capture(processing.core.PApplet, 320, 240, 12);
 }

void read() {
 image(theCamera, 0, 0);
 }
}


The error I get reads: 'Semantic Error: A type "PApplet" was found where a field name or method call was expected.'

Any ideas?
Re: putting Capture into a Class
Reply #1 - Jul 28th, 2006, 10:33pm
 
This is the class:

Code:

public class Digitizer
{

Capture theCamera;
PApplet p;
// constructor
Digitizer (PApplet p) {
this.p=p;
theCamera = new Capture(p, 320, 240, 12);
}

void read() {
image(theCamera, 0, 0);
}
}


and this is how you call the class:
Code:

theCamera = new Capture(this, 320, 240, 30);
Page Index Toggle Pages: 1