Ask Your Question
0

Transform 3D object to Aruco marker center

asked 2017-09-01 15:57:30 -0600

Hello,

I'm developing new features in my C++ custom engine working with OpenGL and OpenCV / Aruco and I'm trying to render in a simple quad a video or scene with aruco markers, and set 3D objects, e.g. cubes, over the markers. I'm having troubles with this last step because I don't know how can I calculate the transform matrix (projection, view and model) to set the cube in the Aruco marker. Could anyone give me any idea about how to access to this data and form the model-view-matrix to do this? "glGetModelViewMatrix()" didn't give me the output that I wanted.

This is the shader where I render the scene (without any kind of problems):

 vertex = [[
  #version 330
  layout (location = 0) in vec3 a_position;
  layout (location = 1) in vec2 a_uv;
  out vec2 uv;

  void main() {
    uv = a_uv;
    gl_Position = vec4(a_position, 1.0); 
  }
  ]] ,


  fragment = [[
  #version 330
  in vec2 uv;
  uniform sampler2D u_sample;
  out vec4 fragColor;

  void main() {
    fragColor = texture(u_sample, uv);
  } 
  ]],

And this one is the shader that I wanted to use to render the geometric 3D object over the Aruco marker:

vertex = [[
  #version 330
  layout (location = 0) in vec3 a_position;
  layout (location = 1) in vec3 a_normal;
  layout (location = 2) in vec2 a_uv;
  layout (location = 3) in vec4 a_color;
  uniform mat4 u_mv_matrix;
  uniform mat4 u_p_matrix;
  out vec2 uv;

  void main() {
    uv = a_uv;
    gl_Position = u_p_matrix * u_mv_matrix * vec4(a_position, 1.0);
  }
  ]] ,

  fragment = [[
  #version 330
  in vec2 uv;
  uniform sampler2D u_sample;
  out vec4 fragColor;

  void main() {
        fragColor = texture(u_sample, uv);
      } 
  ]],

Thanks in advance!

PD: I have thought also in do the transform, get the data in another framebuffer, and draw the cubes over the quad which renders the scene in a different quad as a postprocess. But the problem is the same :( the transform matrix and how to get the data :(((

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
-1

answered 2017-09-20 05:02:15 -0600

edit flag offensive delete link more

Comments

Can you please share the solution? :)

dakom gravatar imagedakom ( 2018-11-15 12:27:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2017-09-01 15:57:30 -0600

Seen: 2,028 times

Last updated: Sep 20 '17