Keystone warp issue.
in
Contributed Library Questions
•
16 days ago
I'm trying to create a program that will straighten a trapezium into a square (as you do). The program is supposed to use it's knowledge of the shape of the trapezium to then apply a transformation to the cornerPins to straighten the shape out. I can roughly do it by mouse manually but this is unacceptable as a final result due to many issues: mainly accuracy and speed. These images should help demonstrate what I'm trying to do.
*
*First image is original shape before the warp, in the second image the green trapezium has become a square from the warp.**
Ultimately I'm looking for either a formula or function that will allow me to find how much to raise/lower the cornerpins to straighten the square.
Current code:
- import deadpixel.keystone.*;
- Keystone ks;
- CornerPinSurface surface;
- MeshPoint pnt;
- PGraphics offscreen;
- void setup() {
- size(1280, 720, P3D);
- smooth();
- ks = new Keystone(this);
- surface = ks.createCornerPinSurface(400, 400, 20);
- offscreen = createGraphics(400, 400, P3D);
- }
- void draw() {
- offscreen.beginDraw();
- offscreen.background(255);
- offscreen.fill(#67cd47);
- offscreen.strokeWeight(2);
- offscreen.beginShape();
- offscreen.vertex(0, 50);
- offscreen.vertex(400, 0);
- offscreen.vertex(400, 400);
- offscreen.vertex(0, 400-150);
- offscreen.endShape(CLOSE);
- offscreen.endDraw();
- background(80);
- surface.render(offscreen);
- }
- void keyPressed() {
- switch (key) {
- case 'c':
- ks.toggleCalibration();
- break;
- case 't':
- println(CornerPinSurface.BR);
- surface.moveMeshPointBy(surface.BL, 0.0, 10.0); //The amout '10.0' needs to be replaced by the amount to move down.
- break;
- }
- }
1