A tree that grows. (branches grow organically from the root) This example is based on the 3D Fractal Tree Example by The Coding Train aka Daniel Shiffman.
A movement trigger. That activates i++ each time someone moves in front of the screen.
I’m trying to combine the two files so the movement trigger is what grows a new branch each time someone moves in front of the webcam. But the camera ‘this’ and the peasy cam ‘this’ i think are getting mixed up in the code.
I tried replacing the camera ‘this’ with the name of my webcam. but the platform just got super confused. see below.
video = new Capture(this, width, height, 30);
with
video = new Capture(this, "name=Integrated Webcam,size=320x240,fps=30");
Not quite sure what to do here. Can anyone help? This is a link to the two files
The keyword in this can certainly be confusing. In this context in referring to the PApplet (your current Processing application). Looking at the code you posted both the Capture and PeasyCam constructors are called from setup so chances are the this keyword isn’t your problem.
From what you said about the name of the webcam not working it might be that the Video library can’t find a webcam. Does the example on the Capture documentation page work?
Could you also post a screenshot of your error? I don’t have a webcam on this computer so I can’t run your sketch.
Looks like you might create prevFrame image before the Webcam finishes initializing so your video.width and video.height are set to 0. Not sure why this would suddenly show up with the same code as the trigger sketch, but I’ve run into this problem a couple times. Could try adding:
You’ll have to scroll up above the error to see the println in the console. If it reads out as videowidth: 0 videoheight: 0. Then try changing line 38 to:
prevFrame = createImage(width, height, RGB);
// This might not be the best practice, but since you are using the sketch
// size to define the Capture size it probably will work.
If you get something other than zero then it’s a different problem and I can look into it more I get home in an hour or two.
Hey,
I was trying to figure out the same issue. you were right. For some reason the first frame suddenly does NOT read, which is why the error shows up.
But with
println("videowidth: " + video.width + " videoheight: " + video.height);
it does not show 0. Not sure whats going on.
Anyway, I’ve got it working at 320.240. I just put in an if statement.
Now need to figure out how to work with it at higher resolutions. Haven’t quite solved that issue yet
Thank you for your help with this. Atleast I’ve got it started.