Ask Your Question
0

Convert pixel position to world direction?

asked 2015-07-11 10:25:21 -0600

TAXfromDK gravatar image

I have calibrated my camera with a checkerboard and achieved the distortion parameters and Intrinsic matrix of my camera.

Using these I have estimated the camera position and orientation using solvePnP against a known known set of reference points.

Now I want to find the world direction, from the camera toward a blob I am detecting inside my image. So I want to convert a pixel position to a 3D vector in that direction.

I want the direction so I can determine where in the world a ball is located. I have two cameras. If both of them can see the blob I will find the point nearest both lines and if only one can observe the ball I will just use the directions crossing with a the ground plane.

I am using blob detection in HSV colorspace to find the ball.

Any ideas on how to continue?

Kind regards

Jesper

edit retag flag offensive close merge delete

2 answers

Sort by ยป oldest newest most voted
0

answered 2015-07-11 11:16:32 -0600

If you have the ball position at (x,y) (after correcting the distortion), you can just write the projection equations:

x_px = f_x * X/Z + c_x
y_px = f_y * Y/Z + c_x

Where (X,Y,Z) are possible 3d coordinates in the world. As you have only two equations for three unknowns (X,Y,Z), this will give you the possible positions of the ball along a line. This line goes through the optical center of your camera and e.g. the point [(x_px-c_x)/f_x,(y_px-c_y)/f_y,1]. As you have the 6D transformation between both cameras, you can bring the two rays into one coordinate system and find a point with minimal distance to both of them. (don't try to intersect them, as they probably never have an intersection point)

edit flag offensive delete link more
0

answered 2018-07-24 20:49:42 -0600

mannyglover gravatar image

You could use cv::triangulatePoints().

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2015-07-11 10:25:21 -0600

Seen: 1,599 times

Last updated: Jul 24 '18