Attention! This forum will be made read-only by Dec-20. Please migrate to https://forum.opencv.org. Most of existing active users should've received invitation by e-mail.
Ask Your Question

Kathan's profile - activity

2017-11-08 11:29:06 -0500 received badge  Supporter (source)
2017-10-25 03:14:15 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

That makes sense, but how do you remove it?

2017-10-24 09:29:30 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-24 09:27:28 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

@Tetragramm Thanks for the insight! I managed to put it to work! I have one other question though. I have one point and

2017-10-24 09:27:09 -0500 marked best answer Get coordinates of the projection point depending of the angles do the Camera

So basically I have a Camera positioning coords (x1, y1, y1) as well as the angles of the direction the camera is facing, and a point in the same space that I want to show in screen (x2, y2, z3).

I have a camera Matrix (with the values of the future camera im going to use):

def get_camera_matrix(fovx, fovy, height, width):
## FOVX is the horizontal FOV angle of the camera
## FOVY is the vertical FOV angle of the camera
x = width / 2
y = height / 2
fx = x / math.tan(fovx)
fy = y / math.tan(fovy)
return np.array([[fx, 0, x],
                 [0, fy, y],
                 [0, 0, 1]])

I also have a rotationMatrix from the angles, given by:

def eulerAnglesToRotationMatrix(pitch, yaw, roll):
# Calculates Rotation Matrix given euler angles.
r_x = np.array([[1, 0, 0],
                [0, math.cos(roll), -math.sin(roll)],
                [0, math.sin(roll), math.cos(roll)]])
r_y = np.array([[math.cos(pitch), 0, math.sin(pitch)],
                [0, 1, 0],
                [-math.sin(pitch), 0, math.cos(pitch)]])
r_z = np.array([[math.cos(yaw), -math.sin(yaw), 0],
                [math.sin(yaw), math.cos(yaw), 0],
                [0, 0, 1]])
return np.dot(r_z, np.dot(r_y, r_x))

But now I dont seem to understand what Im missing to get the final (x, y) point on screen. I looked up: http://docs.opencv.org/2.4/modules/ca... But it I dont seem to understand where the angle of the camera enters. I want to move the angle of the camera and have it reflect on the position of the target.

This is what Im doing so far:

getPointInterestOnPixel(point_in_world,
       point_of_camera,
       eulerAnglesToRotationMatrix(roll, pitch, yaw),
       np.array([[0, 0, 0]]),
       eulerAnglesToRotationMatrix(-np.pi / 2, -np.pi / 2, -np.pi / 2),
       matrix)

def getPointInterestOnPixel(P_i_w, P_a_w, R_a_w, P_c_a, R_c_a, K):
       R_c_w = np.dot(R_a_w, R_c_a)
       #P_i_c = np.dot(R_c_w.T, (P_i_w.T - P_a_w.T - np.dot(R_a_w, P_c_a.T)))
       P_i_c = np.dot(R_c_w, (P_i_w.T - P_a_w.T))
       P_i_c_pixels = np.dot(K, P_i_c)
       P_i_c_pixels = np.divide(P_i_c_pixels, P_i_c_pixels[2])
       return P_i_c_pixels

Im going crazy, at this moment, I get the points in screen, they move, but if I do a 180 degree turn, the points turn upsidedown. I tried so many things its all getting so confused right now.

Please help? Thanks

EDIT: Used projectPoints as @Tetragramm sugested, but things got even wierder. All points are in the same place when they shouldnt, maybe Im missing something, kinda new to this. I just want to move my camera and have the points move as well in the correct place :(

points2d, jacobian = cv2.projectPoints(np.asarray(points3d),
    np.dot(hud.eulerAnglesToRotationMatrix(math.radians(pitch), math.radians(yaw), math.radians(roll)), hud.eulerAnglesToRotationMatrix(-np.pi / 2, -np.pi / 2,-np.pi / 2)),
    np.array([np.float32(0), np.float32(0), np.float32(0)]),
    hud.get_camera_matrix(self._fovx, self._fovy, height, width),
    None)

or if I use Rodrigues:

dst, jacobian = cv2.Rodrigues(np.array([np.float64(pitch),np.float64(yaw),np.float64(roll)]))

points2d, jacobian3 = cv2 ...
(more)
2017-10-24 09:27:09 -0500 received badge  Scholar (source)
2017-10-11 06:45:46 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

Ok, what do you mean subtract tvec from both it and world points? Whats it? So, its to always make the camera a central

2017-10-11 06:44:35 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

Ok, what do you mean subtract tvec from both it and world points? Whats it? So, its to always make the camera a central

2017-10-11 06:18:42 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

Ok, what do you mean subtract tvec from both it and world points? Whats it? So it to always make the camera a central po

2017-10-10 04:29:19 -0500 received badge  Enthusiast
2017-10-10 04:29:19 -0500 received badge  Enthusiast
2017-10-09 08:27:49 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-09 08:27:34 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

What do you mean with a constant rotation? and where would I put said constant? Check new Edit.

2017-10-09 08:27:14 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-09 08:24:58 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-09 07:27:34 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

What do you mean with a constant rotation? and where would I put said constant?

2017-10-09 03:34:51 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

What do you mean with a constant rotation? and where would I had said constant?

2017-10-09 03:30:40 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

What do you mean with a constant rotation?

2017-10-06 05:06:08 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-06 04:27:34 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-06 04:25:58 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-06 04:25:28 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-06 04:09:16 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-06 04:07:42 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-06 04:03:49 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

Thanks for the reply, check the edit. :)

2017-10-03 06:59:05 -0500 edited question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c

2017-10-03 06:44:45 -0500 commented answer Get coordinates of the projection point depending of the angles do the Camera

Check my edit, Thanks for the help, but the points Im getting are wierd :X

2017-10-02 11:04:05 -0500 asked a question Get coordinates of the projection point depending of the angles do the Camera

Get coordinates of the projection point depending of the angles do the Camera So basically I have a Camera positioning c