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.
IndexProgramming Questions & HelpPrograms › Sketch settings in second window
Page Index Toggle Pages: 1
Sketch settings in second window (Read 1081 times)
Sketch settings in second window
Nov 21st, 2009, 3:57pm
 
I have made sketch, that will be run fullscreen on projector. I want second window on the pc display where will be displayed some info, control elements for that sketch (for example controlP5 library) and camera input. Which way is best to do than?
Re: Sketch settings in second window
Reply #1 - Nov 21st, 2009, 4:05pm
 
Just take a close look at the controlP5 Reference Page
http://www.sojamo.de/libraries/controlP5/examples/ControlP5window/ControlP5window.pde
Re: Sketch settings in second window
Reply #2 - Nov 21st, 2009, 5:20pm
 
Thanks!
But how can I draw Camera input there?
Re: Sketch settings in second window
Reply #3 - Nov 21st, 2009, 10:25pm
 
hi,
patching controlP5's controlP5canvas example and processing's GettingStartedCapture example together, i get the following result. maybe that gets you started with what you are looking for?

Quote:
// the following example shows how to display 
// a camera capture in a controlWindow 
// using a ControlWindowCanvas.

import controlP5.*;
import processing.video.*;  

ControlP5 controlP5;
ControlWindow controlWindow;
ControlWindowCanvas cc;

// camera input from e.g. webcam
Capture cam; 
// an image usded to buffer the latest 
// image captured by 'cam'
PImage camImage;
int camWidth = 160; // width of the camera input
int camHeight = 120; // height of the camera input


// the controlWindowCanvas class which will display the 
// captured image from a camera input in a controlWindow.

class MyCanvas extends ControlWindowCanvas {
  public void draw(PApplet theApplet) {
    theApplet.translate(100,100);
    // read camera input and update the buffer image
    // camImage accordingly.
    if (cam.available() == true) {
      cam.read();
      camImage.copy(cam,0,0,camWidth,camHeight,
      0,0,camWidth,camHeight);
    }
    // display camImage
    theApplet.image(camImage,0,0);
  }
}


void setup() {
  // setup main window
  size(400,400);
  frameRate(30);

  // init camera capture
  cam = new Capture(this, 160, 120);
  camImage = createImage(camWidth,camHeight,RGB);

  // setup controlP5 and an extra controlWindow
  controlP5 = new ControlP5(this);
  controlWindow = controlP5.addControlWindow("controlP5window",
  100,100,400,400,15);
  controlWindow.setUpdateMode(ControlWindow.NORMAL);

  // create a control window canvas and add it to
  // the control window from above.  
  cc = new MyCanvas();
  cc.pre();
  // (use cc.post(); to draw on top of the controllers.)
  // add the canvas to the controlWindow
  controlWindow.addCanvas(cc);

}

void draw() {
  background(0);
}



Re: Sketch settings in second window
Reply #4 - Nov 22nd, 2009, 3:30am
 
Thank you, Andreas!
ControlP5 is really great!
Page Index Toggle Pages: 1