0

I'm in big trouble: My program (Java) successfully recognised a square drawn on a paper (by its 4 edges). Now I need to calculate, under which angle the webcam is facing this square. So I get the 4 coordinates of the shape, and I already had an idea: You could have a look on the proportions of the area of this shape to the maximum area possible by this square (when you would look direktly on it from the top). The first one is easy (Vectors, angles), but I have no clue on how to calculate the maximum area of this quadrangle, when it would be a square.... Is it possible to understand, what I mean?

Or do you have any clue on how to claculate this in an other way?

I'm thankful for every help/idea/everything

Erik Brendel
  • 683
  • 9
  • 23
  • 1
    You might be better off posting this on http://math.stackexchange.com/ – Martin G Dec 16 '14 at 19:53
  • Just an approach: Draw lines between opposite corners, then the look-down angle of the camera will be related to both the ratio of the those line lengths, and to to angle between them. – PaulQ Dec 16 '14 at 21:13
  • To both? How should I combine them? Until now, I'm using the ratio of diagonal-lengths to get the Viewing-angle (approximately). Please explain your thoughts a bit more, that sounds like it could work. :D – Erik Brendel Dec 16 '14 at 21:36

1 Answers1

0

The angle between the web cam and the square can be calculated easily from the dot product of two unit vectors:

  1. the vector from the web cam (x1, y1, z1) and the centroid of the square,
  2. The normal vector of the square, which can be calculated using the cross product of two adjacent sides.
duffymo
  • 305,152
  • 44
  • 369
  • 561
  • The problem is, that I have no clue about the webcam-vector. All the program knows are the coordinates of the 4 base-points like seen here: [link](http://imgur.com/LtNAySs). – Erik Brendel Dec 16 '14 at 20:29
  • If you know the coordinates of the web cam, the first vector is (x[cam]-x[centroid])i + (y[cam]-y[centroid])j + (z[cam]-z[centroid])k – duffymo Dec 16 '14 at 20:48
  • The program has also no clue about the cameras position. As I said, there is only that picture (see above) and the 4 coords as input. – Erik Brendel Dec 16 '14 at 21:05
  • For sure? I mean, I'm close to it. But currently it's just approximately – Erik Brendel Dec 16 '14 at 21:37