non-updating objects in front of updating background?
in
Contributed Library Questions
•
8 months ago
Hi, I'm trying to make the ability to doodle in front of a constantly updating SimpleOpenNi camera feed. The fact that the feed needs to update every loop has me stumped, as I need to have the miniature ellipses successively created by the drawing function stay visible, instead of being overridden by the feed's next frame. I tried putting the draw function in its own void loop and calling it first thing in void draw, didn't work.
Also, a kinect is needed to run the sketch properly, but if anyone can find a problem in the code anyway, that'd be amazing. Thanks in advance
I also tried using this
Layers library, but for some reason it doesn't work when combined with the SimpleOpenNi library in one sketch. It leaves the whole applet window white, except for a top-left 100*100 square portion which functions properly. Both libraries and all the code I'm using with them work individually, but just not together for some weird reason...
I don't expect to be able to solve this problem myself, as it seems like an issue with the source code, or that they're simply incompatible with each other, so I'm wondering if anyone else knows of any other options to achieve this? Any tips/ideas would be awesome.
This is my main sketch:
- /OPENNI
- import SimpleOpenNI.*;
- SimpleOpenNI context;
- //LAYERS
- import com.nootropic.processing.layers.*;
- AppletLayers layers;
- void setup() {
- //LAYERS
- layers = new AppletLayers(this);
- drawing m = new drawing(this);
- layers.addLayer(m);
- //CAM PARAMS
- // instantiate a new context
- context = new SimpleOpenNI(this);
- // enable depth image generation
- context.enableDepth();
- // context.enableRGB(640,480,30);
- // create a window the size of the depth information
- size(context.depthWidth(), context.depthHeight());
- // size(context.rgbWidth(),context.rgbHeight());
- //DRAW PARAMS
- // size(displayWidth,displayHeight);
- fill(0, 0, 255);
- noStroke();
- smooth();
- noCursor();
- frameRate(50);
- background(0);
- }
- //THIS VOID PAINT IS NECESSARY FOR THE LAYERS LIBRARY TO WORK PROPERLY
- void paint(java.awt.Graphics g) {
- // This method MUST be present in your sketch for layers to be rendered!
- if (layers != null) {
- layers.paint(this);
- } else {
- super.paint(g);
- }
- }
- void draw() {
- //CAM
- // update the camera
- context.update();
- // draw depth image
- image(context.depthImage(), 0, 0);
- }
- class drawing extends Layer {
- drawing(PApplet parent) {
- super(parent); // This is necessary!
- }
- void draw() {
- fill(0, 0, 255);
- noStroke();
- smooth();
- noCursor();
- // frameRate(50);
- // background(0, 0); // clear the background every time, but be transparent
- //DRAW
- ellipse(mouseX, mouseY, 10, 10);
- if (mousePressed == true) {
- ellipse(mouseX, mouseY, 10, 10);
- }
- }
- }
I have checked the libraries' forums already, figured this would be the best place to post.
1