0

I have this AR project that I need to transform the screen coordinate to world coordinate. I follow this tutorial and I almost made it.

The only problem when I try to transform from homogeneous clip space to eye space, I use the wrong projection matrix. The reason why the projection matrix is wrong because I cannot get the right width and height of the camera space. I used this library called Kudan, when i move the camera phone forward and backward, I expect the camera width and height to change since the camera space size should be getting smaller when it moves forward and vice versa.

For the last resort, currently i try to find the camera space size by myself, How do I implement this?

This is my projection matrix

Matrix4f projectionMatrix = new Matrix4f(-0.5f* currentCamWidth, 0.5f * currentCamWidth, -0.5f * currentCamHeight, 0.5f * currentCamHeight, -1f, node.getFullPosition().getZ());

Current cam width and current cam height are always constant. the coordinates are opengl coordinates

Robert Limanto
  • 2,068
  • 4
  • 17
  • 27

1 Answers1

0

when i move the camera phone forward and backward, I expect the camera width and height to change since the camera space size

Why? Just because you move around the point of view that doesn't mean that the properties of the "virtual lens" change.

should be getting smaller when it moves forward and vice versa.

Why? That's not how cameras work.


It's really hard to give a helpful answer here, without seeing the code you've written so far. At the moment it's guesswork at best.

datenwolf
  • 159,371
  • 13
  • 185
  • 298
  • i am just looking for theory, are you famiiliar with kudan? – Robert Limanto Jul 03 '17 at 07:46
  • for now, i know the position of the object in the camera space, when i adjust my camera space so that the object in the corner of my camera screen. the coordinate of the object is not the same with my screen size. – Robert Limanto Jul 03 '17 at 07:47
  • basically, i am trying to convert my screen coordinate to camera space coordinate. but without knowing the size of the camera coordinate, it is not possible. – Robert Limanto Jul 03 '17 at 07:49
  • when you move the camera closer to floor, the observable view will be smaller, therefore the camera space will be smaller too. – Robert Limanto Jul 03 '17 at 07:51
  • @RobertLimanto: When you move the camera closer nothing becomes "smaller" what's changes is the cross section of the projection volume with the object. This "getting smaller" is just caused by the movement of the camera in space. The camera itself doesn't change at all. – datenwolf Jul 03 '17 at 07:54
  • hi, i have updated my projection matrix, is that correct? also, what should be the value for near plane? – Robert Limanto Jul 03 '17 at 07:57
  • 1
    @RobertLimanto: No. For one `Matrix4f` reads like a constructor for a 4×4 matrix and thereby would either take 16 floats or 4 vectors of 4 floats. Not what you're passing there. I can see that you were thinking in parameters that construct a frustum, but even then it's not correct. Why? Because the parameters of a camera do no changes when it's position is altered, to that very last parameter that takes the result of a function call is surely not right. Here's a very thorough tutorial: http://www.songho.ca/opengl/gl_transform.html – datenwolf Jul 03 '17 at 08:30
  • this is the problem, the library does not use opengl fully, they only use the glsurfaceview. But for the camera, they use native camera of android. Therefore, i have to create my own projection matrix. You just said that "the parameters of the camera do not changes", Therefore, which parameter should I use? How to get the parameter in Android Camera? Thanks so much for the help – Robert Limanto Jul 03 '17 at 10:01