user5671855
user5671855

Reputation:

triangulate points using epipolar geometry

I'm using in OpenCV the method

triangulatePoints(P1,P2,x1,x2)

to get the 3D coordinates of a point by its image points x1/x2 in the left/right image and the projection matrices P1/P2.

I've already studied epipolar geometry and know most of the maths behind it. But what how does this algorithm get mathematically the 3D Coordinates?

Upvotes: 2

Views: 1162

Answers (1)

dhanushka
dhanushka

Reputation: 10702

Here are just some ideas, to the best of my knowledge, should at least work theoretically.

Using the camera equation ax = PX, we can express the two image point correspondences as

ap = PX

bq = QX

where p = [p1 p2 1]' and q = [q1 q2 1]' are the matching image points to the 3D point X = [X Y Z 1]' and P and Q are the two projection matrices.

We can expand these two equations and rearrange the terms to form an Ax = b system as shown below

p11.X + p12.Y + p13.Z - a.p1 + b.0 = -p14

p21.X + p22.Y + p23.Z - a.p2 + b.0 = -p24

p31.X + p32.Y + p33.Z - a.1 + b.0 = -p34

q11.X + q12.Y + q13.Z + a.0 - b.q1 = -q14

q21.X + q22.Y + q23.Z + a.0 - b.q2 = -q24

q31.X + q32.Y + q33.Z + a.0 - b.1 = -q34

from which we get

A = [p11 p12 p13 -p1 0; p21 p22 p23 -p2 0; p31 p32 p33 -1 0; q11 q12 q13 0 -q1; q21 q22 q23 0 -q2; q31 q32 q33 0 -1], x = [X Y Z a b]' and b = -[p14 p24 p34 q14 q24 q34]'. Now we can solve for x to find the 3D coordinates.

Another approach is to use the fact, from camera equation ax = PX, that x and PX are parallel. Therefore, their cross product must be a 0 vector. So using,

p x PX = 0

q x QX = 0

we can construct a system of the form Ax = 0 and solve for x.

Upvotes: 1

Related Questions