0

I'm working on an Augmented Reality marker detection program, using OpenCV and I'm getting two different rotation and translation values for the same marker.

The 3D model switches between these states automatically without my control, when the camera is slightly moved. Screenshots of the above two situations are added below. I want the Image#1 to be the correct one. How to and where to correct this?

I have followed How to use an OpenCV rotation and translation vector with OpenGL ES in Android? to create the Projection Matrix for OpenGL. ex:

// code to convert rotation, translation vector
glLoadMatrixf(ConvertedProjMatrix);
glColor3f(0,1,1) ;
glutSolidTeapot(50.0f);

Image #1 enter image description here

Image #2 enter image description here

Additional

I'd be glad if someone suggests me a way to make the Teapot sit on the marker plane. I know I have to edit the Rotation matrix. But what's the best way of doing that?

Community
  • 1
  • 1
coder9
  • 1,571
  • 1
  • 27
  • 52

2 Answers2

0

Have you tried swapping the pose algorithm (ITERATIVE, EPNP, P3P)? Or possibly use the values from the previous calculation - remember that it's just giving you its 'best guess'.

Kevin
  • 53,822
  • 15
  • 101
  • 132
Josh
  • 13
  • 2
  • 4
0

To rotate the teapot you can use glRotatef(). If you want to rotate your current matrix for example by 125° around the y-axis you can call:

glRotate(125,0,1,0);

I can't make out the current orientation of your teapot, but I guess you would need to rotate it by 90° around the x-axis.

I have no idea about your first problem, OpenCV seems unable to decide which of the shown positions is the "correct" one. It depends on what kind of features OpenCV is looking for (edges, high contrast, unique points...) and how you implemented it.

Lennart
  • 9,657
  • 16
  • 68
  • 84