I'm up to the neck in projective transforms and I'm losing my mind. So here's the problem:
I've taken a photo of a scene. I need to work out the projection transformation matrix that distorts the image so that it approximates how the scene would look from another camera position. I'm guessing I need to calculate the camera transform from the original to the new position, then use the equations on the wiki page
http://en.wikipedia.org/wiki/3D_projection to calculate the matrix.
Has anyone found this, and worked out how to solve it? There was a post in the old forums but it never got resolved. I'm using export to executable jar.
Hi, I'm having transformation matrix woes. So I have 2 line segments and I'm trying construct with scale(), translate() and rotate() the matrix that maps one onto the other. I'm almost there but I'm having issues with the operator order. At the moment I have (partially pseudo):
Hallo, I'm trying do a basic zoom-centered-on-mouse sketch (as part of a larger project) but I've been puzzling over this for days and I need a bit of help. So I'm trying to get my head round the matrix stuff for coordinate system transformations but I don't get it. Try the code - the zoom centered on mouse doesn't work if you're zooming when the image is zoomed already. I feel like I need to transform the center point of the zoom into the image coords but that doesn't work either. Any ideas?
Cheers,
Rob
Viewport viewport;
float zoomFactor = 1;
boolean dragging = false;
void setup() {
size(400, 400);
smooth();
textFont(createFont("Courier New", 12), 12);
viewport = new Viewport(50, 50, 50, 50);
}
void draw() {
background(0);
if(dragging){
viewport.pan(mouseX, mouseY);
}
g.setMatrix(viewport.mat);
noFill();
stroke(150);
for(int j = 0; j < 10; j++)
for(int i = 0; i < 10; i++)
ellipse(50+i*20, 50+j*20, 20, 20);
g.resetMatrix();
PVector p = viewport.screenToImageCoords(new PVector(mouseX, mouseY));
text(p.x + " " + p.y, mouseX, mouseY);
}
void mousePressed(){
if(mouseButton == RIGHT) dragging = true;
}
void mouseReleased(){
dragging = false;
}
void keyPressed() {
if(keyCode == UP || keyCode == DOWN) {
if(keyCode == UP) zoomFactor *= 1.1;
if(keyCode == DOWN) zoomFactor *= 0.9;
viewport.zoomOnPoint(mouseX, mouseY, zoomFactor);
}
}
class Viewport {
float x, y, w, h, iw, ih;
PMatrix2D mat, inverseMat;
Viewport(float x, float y, float w, float h) {
this.x = x;
this.y = y;
this.w = iw = w;
this.h = ih = h;
mat = new PMatrix2D();
inverseMat = new PMatrix2D();
}
void pan(float ox, float oy){
mat.translate(ox, oy);
}
void zoomOnPoint(float ox, float oy, float zoomFactor) {