How can I properly align cube over the marker in OpenGL?
up vote
0
down vote
favorite
I am trying to render a cube over a detect marker in openGL. I am doing it like this.
rmtx = cv2.Rodrigues(rvec)[0]
m1 = np.array([[rmtx[0][0],rmtx[0][1],rmtx[0][2],tvec[0][0][0]],
[rmtx[1][0],rmtx[1][1],rmtx[1][2],tvec[0][0][1]],
[rmtx[2][0],rmtx[2][1],rmtx[2][2],tvec[0][0][2]],
[0.0 ,0.0 ,0.0 ,1.0 ]])
Inverse_mat = np.array([[ 1.0, 1.0, 1.0, 1.0],
[-1.0,-1.0,-1.0,-1.0],
[-1.0,-1.0,-1.0,-1.0],
[ 1.0, 1.0, 1.0, 1.0]])
m1 = m1 * Inverse_mat
m1 = np.transpose(m1)
After loading the matrix m1 there is glutSolidCube() statement. The problem is that the cube is not in the viewable screen of openGL. I even scaled and shifted the tvec parameters of m1.
X = np.array([[1,0,0,x shift],
[0,1,0,y shift],
[0,0,1,z shift],
[0,0,0,1]])
Y = np.array([[tvec[0][0][0]],
[tvec[0][0][1]],
[tvec[0][0][2]],
[1]])
tvec = np.array([[sum(a*b for a,b in zip(X_row,Y_col)) for Y_col in zip(*Y)] for X_row in X])
m1 = np.array([[rmtx[0][0],rmtx[0][1],rmtx[0][2],tvec[0]/scale x],
[rmtx[1][0],rmtx[1][1],rmtx[1][2],tvec[1]/scale y],
[rmtx[2][0],rmtx[2][1],rmtx[2][2],tvec[2]/scale z],
[0.0 ,0.0 ,0.0 ,1.0 ]])
This brings the cube over the marker but it is not aligned properly.
Moreover the values used for scaling and shifting is as per view on my screen and I want a general solution. What should I do?
python-3.x opengl
add a comment |
up vote
0
down vote
favorite
I am trying to render a cube over a detect marker in openGL. I am doing it like this.
rmtx = cv2.Rodrigues(rvec)[0]
m1 = np.array([[rmtx[0][0],rmtx[0][1],rmtx[0][2],tvec[0][0][0]],
[rmtx[1][0],rmtx[1][1],rmtx[1][2],tvec[0][0][1]],
[rmtx[2][0],rmtx[2][1],rmtx[2][2],tvec[0][0][2]],
[0.0 ,0.0 ,0.0 ,1.0 ]])
Inverse_mat = np.array([[ 1.0, 1.0, 1.0, 1.0],
[-1.0,-1.0,-1.0,-1.0],
[-1.0,-1.0,-1.0,-1.0],
[ 1.0, 1.0, 1.0, 1.0]])
m1 = m1 * Inverse_mat
m1 = np.transpose(m1)
After loading the matrix m1 there is glutSolidCube() statement. The problem is that the cube is not in the viewable screen of openGL. I even scaled and shifted the tvec parameters of m1.
X = np.array([[1,0,0,x shift],
[0,1,0,y shift],
[0,0,1,z shift],
[0,0,0,1]])
Y = np.array([[tvec[0][0][0]],
[tvec[0][0][1]],
[tvec[0][0][2]],
[1]])
tvec = np.array([[sum(a*b for a,b in zip(X_row,Y_col)) for Y_col in zip(*Y)] for X_row in X])
m1 = np.array([[rmtx[0][0],rmtx[0][1],rmtx[0][2],tvec[0]/scale x],
[rmtx[1][0],rmtx[1][1],rmtx[1][2],tvec[1]/scale y],
[rmtx[2][0],rmtx[2][1],rmtx[2][2],tvec[2]/scale z],
[0.0 ,0.0 ,0.0 ,1.0 ]])
This brings the cube over the marker but it is not aligned properly.
Moreover the values used for scaling and shifting is as per view on my screen and I want a general solution. What should I do?
python-3.x opengl
Have you properly calibrated your camera and got extrinsic values? That will form proper projection matrix for your rendering.
– Paritosh Kulkarni
Nov 23 at 15:40
Yes camera is well calibrated and the extrinsic values are pretty much correct.
– mastersad
Nov 25 at 5:09
I did not get the step you are building inverse matrix . Can you explain steps.
– Paritosh Kulkarni
Nov 25 at 22:40
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to render a cube over a detect marker in openGL. I am doing it like this.
rmtx = cv2.Rodrigues(rvec)[0]
m1 = np.array([[rmtx[0][0],rmtx[0][1],rmtx[0][2],tvec[0][0][0]],
[rmtx[1][0],rmtx[1][1],rmtx[1][2],tvec[0][0][1]],
[rmtx[2][0],rmtx[2][1],rmtx[2][2],tvec[0][0][2]],
[0.0 ,0.0 ,0.0 ,1.0 ]])
Inverse_mat = np.array([[ 1.0, 1.0, 1.0, 1.0],
[-1.0,-1.0,-1.0,-1.0],
[-1.0,-1.0,-1.0,-1.0],
[ 1.0, 1.0, 1.0, 1.0]])
m1 = m1 * Inverse_mat
m1 = np.transpose(m1)
After loading the matrix m1 there is glutSolidCube() statement. The problem is that the cube is not in the viewable screen of openGL. I even scaled and shifted the tvec parameters of m1.
X = np.array([[1,0,0,x shift],
[0,1,0,y shift],
[0,0,1,z shift],
[0,0,0,1]])
Y = np.array([[tvec[0][0][0]],
[tvec[0][0][1]],
[tvec[0][0][2]],
[1]])
tvec = np.array([[sum(a*b for a,b in zip(X_row,Y_col)) for Y_col in zip(*Y)] for X_row in X])
m1 = np.array([[rmtx[0][0],rmtx[0][1],rmtx[0][2],tvec[0]/scale x],
[rmtx[1][0],rmtx[1][1],rmtx[1][2],tvec[1]/scale y],
[rmtx[2][0],rmtx[2][1],rmtx[2][2],tvec[2]/scale z],
[0.0 ,0.0 ,0.0 ,1.0 ]])
This brings the cube over the marker but it is not aligned properly.
Moreover the values used for scaling and shifting is as per view on my screen and I want a general solution. What should I do?
python-3.x opengl
I am trying to render a cube over a detect marker in openGL. I am doing it like this.
rmtx = cv2.Rodrigues(rvec)[0]
m1 = np.array([[rmtx[0][0],rmtx[0][1],rmtx[0][2],tvec[0][0][0]],
[rmtx[1][0],rmtx[1][1],rmtx[1][2],tvec[0][0][1]],
[rmtx[2][0],rmtx[2][1],rmtx[2][2],tvec[0][0][2]],
[0.0 ,0.0 ,0.0 ,1.0 ]])
Inverse_mat = np.array([[ 1.0, 1.0, 1.0, 1.0],
[-1.0,-1.0,-1.0,-1.0],
[-1.0,-1.0,-1.0,-1.0],
[ 1.0, 1.0, 1.0, 1.0]])
m1 = m1 * Inverse_mat
m1 = np.transpose(m1)
After loading the matrix m1 there is glutSolidCube() statement. The problem is that the cube is not in the viewable screen of openGL. I even scaled and shifted the tvec parameters of m1.
X = np.array([[1,0,0,x shift],
[0,1,0,y shift],
[0,0,1,z shift],
[0,0,0,1]])
Y = np.array([[tvec[0][0][0]],
[tvec[0][0][1]],
[tvec[0][0][2]],
[1]])
tvec = np.array([[sum(a*b for a,b in zip(X_row,Y_col)) for Y_col in zip(*Y)] for X_row in X])
m1 = np.array([[rmtx[0][0],rmtx[0][1],rmtx[0][2],tvec[0]/scale x],
[rmtx[1][0],rmtx[1][1],rmtx[1][2],tvec[1]/scale y],
[rmtx[2][0],rmtx[2][1],rmtx[2][2],tvec[2]/scale z],
[0.0 ,0.0 ,0.0 ,1.0 ]])
This brings the cube over the marker but it is not aligned properly.
Moreover the values used for scaling and shifting is as per view on my screen and I want a general solution. What should I do?
python-3.x opengl
python-3.x opengl
asked Nov 22 at 7:54
mastersad
15
15
Have you properly calibrated your camera and got extrinsic values? That will form proper projection matrix for your rendering.
– Paritosh Kulkarni
Nov 23 at 15:40
Yes camera is well calibrated and the extrinsic values are pretty much correct.
– mastersad
Nov 25 at 5:09
I did not get the step you are building inverse matrix . Can you explain steps.
– Paritosh Kulkarni
Nov 25 at 22:40
add a comment |
Have you properly calibrated your camera and got extrinsic values? That will form proper projection matrix for your rendering.
– Paritosh Kulkarni
Nov 23 at 15:40
Yes camera is well calibrated and the extrinsic values are pretty much correct.
– mastersad
Nov 25 at 5:09
I did not get the step you are building inverse matrix . Can you explain steps.
– Paritosh Kulkarni
Nov 25 at 22:40
Have you properly calibrated your camera and got extrinsic values? That will form proper projection matrix for your rendering.
– Paritosh Kulkarni
Nov 23 at 15:40
Have you properly calibrated your camera and got extrinsic values? That will form proper projection matrix for your rendering.
– Paritosh Kulkarni
Nov 23 at 15:40
Yes camera is well calibrated and the extrinsic values are pretty much correct.
– mastersad
Nov 25 at 5:09
Yes camera is well calibrated and the extrinsic values are pretty much correct.
– mastersad
Nov 25 at 5:09
I did not get the step you are building inverse matrix . Can you explain steps.
– Paritosh Kulkarni
Nov 25 at 22:40
I did not get the step you are building inverse matrix . Can you explain steps.
– Paritosh Kulkarni
Nov 25 at 22:40
add a comment |
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
active
oldest
votes
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53426198%2fhow-can-i-properly-align-cube-over-the-marker-in-opengl%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Have you properly calibrated your camera and got extrinsic values? That will form proper projection matrix for your rendering.
– Paritosh Kulkarni
Nov 23 at 15:40
Yes camera is well calibrated and the extrinsic values are pretty much correct.
– mastersad
Nov 25 at 5:09
I did not get the step you are building inverse matrix . Can you explain steps.
– Paritosh Kulkarni
Nov 25 at 22:40