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.
IndexProcessing DevelopmentLibraries,  Tool Development › Keystone: a corner pin keystone library
Page Index Toggle Pages: 1
Keystone: a corner pin keystone library (Read 8476 times)
Keystone: a corner pin keystone library
Sep 8th, 2009, 8:03am
 
Hi everyone,

I just made this tiny library that makes it easy to do corner pin keystoning from within Processing.  Calibration is done by dragging and dropping surface corners until they look straight or map onto a surface you'd like to project on (flat surfaces only at the moment!). Used in conjunction with Andres Colubri's excellent GLGraphics, performance is pretty decent even with multiple surfaces.  

Finally, a neat little feature is that the library will also calculate the undistorted mouse position from inside a distorted surface. This is useful if you want to control things in the sketch from a laptop while projecting.

Hopefully this will be helpful to those of you working with video projectors! Feedback, suggestions or feature requests are welcome.

http://keystonep5.sourceforge.net

d.
Re: Keystone: a corner pin keystone library
Reply #1 - Sep 9th, 2009, 5:27am
 
Thats great. I was really having some problems to solve that in an upcoming installation. Thx!
Re: Keystone: a corner pin keystone library
Reply #2 - Nov 4th, 2009, 4:29am
 
Hello,

I'm very glad you're working on this library, great stuff!
It really simplifies my work...

I actually try this library in a new project
and I have a question about the load / save functions
When I save a configuration, the xml uses float values
then when I use the load function, it crashes the application with this message "NumberFormatException: For input string:"0,000000"
Is it waiting for an integer value?

Thx

P.
Re: Keystone: a corner pin keystone library
Reply #3 - Nov 4th, 2009, 4:59am
 
Patrice, I don't know this library, but given your name and look of error message, I can guess you are using a French locale... Smiley

I think the XML saving routine is using locale-dependent functions, hence the 0,000000 number, instead of 0.0000000, but for some reason the reading isn't following the same format.

Just wild guesses... Wink
Re: Keystone: a corner pin keystone library
Reply #4 - Nov 4th, 2009, 5:10am
 
Yes, that's it:
Keystone.java
fmt = "<point i=\"%d\" x=\"%f\" y=\"%f\" u=\"%f\" v=\"%f\"></point>";
fmted = String.format(fmt, i, s.mesh[i].x, s.mesh[i].y, s.mesh[i].u, s.mesh[i].v);
xml.addChild(new XMLElement(fmted));

String.format is locale sensitive.
And loading is done (in CornerPinSurface.java) with xml.getFloatAttribute()

You can try and do:
Locale locale = new Locale("EN");
Locale.setDefault(locale);

before doing the save.
Re: Keystone: a corner pin keystone library
Reply #5 - Nov 4th, 2009, 5:47am
 
Thx a lot Philho

It works fine now

Cool...


Re: Keystone: a corner pin keystone library
Reply #6 - Nov 6th, 2009, 4:21am
 
Hello

Another problem with this library...

I want to save configurations for 8 surfaces, associated with 8 GL textures, and then load this configurations when opening again the sketch
It seems that this operation doesn't keep the good order
It looks like surface [1] is no more associated with texture [1], but with another one.

Is there a way to resolve this problem?

P.


Re: Keystone: a corner pin keystone library
Reply #7 - Nov 6th, 2009, 11:47am
 
Hi Patrice,

Glad you're trying out the library.  (and thanks PhiLho for answering the first question Smiley

You're right about the ordering. I did a couple projects with the library but the load order didn't matter.  It looks like load() restores surfaces in reverse order.  Good call!

I fixed it and updated the library ZIP file online.  Can you try it out and let me know if it works for you?

d.
Re: Keystone: a corner pin keystone library
Reply #8 - Nov 10th, 2009, 12:36pm
 
Hello

New version is ok, it's working fine for me
Thx very much
This is a very usefull tool for the kind of stuff I do
I think the library will be very used with the developpement of GLgraphics / GLmovie, which makes processing one of the best solution for real time video

P.
Re: Keystone: a corner pin keystone library
Reply #9 - Nov 11th, 2009, 12:58pm
 
Great!  Let me know if you have ideas or feature requests on how to improve the library.  A link to your project would be nice as well Smiley

Best,
d.
Re: Keystone: a corner pin keystone library
Reply #10 - Feb 4th, 2010, 12:42am
 
First of, thanks for the library.

I have a question, it more has to do with drawing offscreen than keystone.

For some reason the center point of the 3D object is shifted once i draw everything into offscreen, can't figure out why. here is example where I added Keystone to Esfera:

Code:

import processing.opengl.*;
import codeanticode.glgraphics.*;
import deadpixel.keystone.*;

GLGraphicsOffScreen offscreen;

Keystone ks;
CornerPinSurface surface;

int cuantos = 8000;
pelo[] lista ;
float[] z = new float[cuantos];
float[] phi = new float[cuantos];
float[] largos = new float[cuantos];
float radio = 200;
float rx = 0;
float ry =0;

void setup() {
 size(1024, 768, GLConstants.GLGRAPHICS);
 radio = height/3.5;
 
 lista = new pelo[cuantos];
 for (int i=0; i<cuantos; i++){
   lista[i] = new pelo();
 }
 noiseDetail(3);
//--------------------------
 offscreen = new GLGraphicsOffScreen(this, width, height);

 ks = new Keystone(this);
 surface = ks.createCornerPinSurface(width, height, 1);
}

void draw() {
 PVector mouse = surface.getTransformedMouse();
 offscreen.beginDraw();
 offscreen.background(0);
 offscreen.translate(width/2,height/2,height);
 float rxp = ((mouse.x-(width/2))*0.005);
 float ryp = ((mouse.y-(height/2))*0.005);
 rx = (rx*0.9)+(rxp*0.1);
 ry = (ry*0.9)+(ryp*0.1);
 offscreen.rotateY(-rx);
 offscreen.rotateX(ry);
 offscreen.fill(0);
 offscreen.noStroke();

 offscreen.sphere(radio);

 for (int i=0;i<cuantos;i++){
   lista[i].dibujar();
 }
 printCamera();

 offscreen.endDraw();
 background(0);

 surface.render(offscreen.getTexture());

}

void keyPressed() {

 switch(key) {
 case 'c':
   // enter/leave calibration mode, where surfaces can be warped
   // & moved
   ks.toggleCalibration();
   break;

 case 'l':
   // loads the saved layout
   ks.load();
   break;

 case 's':
   // saves the layout
   ks.save();
   break;
 }
}

class pelo
{
 float z = random(-radio,radio);
 float phi = random(TWO_PI);
 float largo = random(1.15,1.2);
 float theta = asin(z/radio);

   void dibujar(){

   float off = (noise(millis() * 0.0005,sin(phi))-0.5) * 0.3;
   float offb = (noise(millis() * 0.0007,sin(z) * 0.01)-0.5) * 0.3;

   float thetaff = theta+off;
   float phff = phi+offb;
   float x = radio * cos(theta) * cos(phi);
   float y = radio * cos(theta) * sin(phi);
   float z = radio * sin(theta);
   float msx= screenX(x,y,z);
   float msy= screenY(x,y,z);

   float xo = radio * cos(thetaff) * cos(phff);
   float yo = radio * cos(thetaff) * sin(phff);
   float zo = radio * sin(thetaff);

   float xb = xo * largo;
   float yb = yo * largo;
   float zb = zo * largo;
   
   offscreen.beginShape(LINES);
   offscreen.stroke(0);
   offscreen.vertex(x,y,z);
   offscreen.stroke(200,150);
   offscreen.vertex(xb,yb,zb);
   offscreen.endShape();
 }
}
Re: Keystone: a corner pin keystone library
Reply #11 - Feb 20th, 2010, 8:04am
 
Thanks for making this lib. It was one of the inspirations that make me interested in projection mapping. Is it still under development?
Re: Keystone: a corner pin keystone library
Reply #12 - Mar 21st, 2010, 12:29am
 
thank for making this lib, it's very useful for me..
Re: Keystone: a corner pin keystone library
Reply #13 - Apr 10th, 2010, 12:51pm
 
Hi,

Thanks for making this really useful library. I've been testing it a bit, but can't seem to get video to work with it (assuming it could).

So my question is simple, is it even possible to use Video with the Keystone library (P2D or OpenGL)? I'm using JMCVideo now

Thanks
reza
Re: Keystone: a corner pin keystone library
Reply #14 - May 23rd, 2010, 2:21am
 
this works for me on windows
Code:
import processing.opengl.*;
import codeanticode.glgraphics.*;
import codeanticode.gsvideo.*;
import deadpixel.keystone.*;
GSMovie myMovie;
GLTexture tex;
Keystone ks;
CornerPinSurface surface;
int w=160,h=120;
void setup() {
 size(1024, 768, GLConstants.GLGRAPHICS);
 tex = new GLTexture(this,w,h);  
 ks = new Keystone(this);
 surface = ks.createCornerPinSurface(w, h, 20);
 myMovie = new GSMovie(this, "station.mov");
 myMovie.loop();
}

void movieEvent(GSMovie myMovie) {
 myMovie.read();
}

void draw() {
 background(0);
 tex.putPixelsIntoTexture(myMovie);
 surface.render(tex);
}


btw. great LIB!!! Thanks
Page Index Toggle Pages: 1