title: Calculating essential matrix using OpenCV - what did I do wrong
body: <p>I'm currently trying to calculate the essential matrices of 3 cameras, based on a fourth camera which I use as the &quot;base camera&quot;. I am using OpenCV to calculate the essential matrix.</p>
  <p>Even though my points seem to be correct, when I reconstruct the pose of the camera it doesn't make any sense. For example two of the output translation vectors are (0, 0, -1).
  I suspect I am somehow messing up the enforcing of the internal constrains, but don't know how.</p>
  <p>I am not sure what I am doing wrong and hope somebody can help me :)</p>
  <pre><code>basePoints = np.loadtxt(&quot;data/calibration/fundamental_matrix/resulting_data/camera0/extracted_points/points.txt&quot;)
  
      for c in range(1, cameras):
          print(f&quot;caculating essential matrix for camera {c}&quot;)
          cameraPoints = np.loadtxt(f&quot;data/calibration/fundamental_matrix/resulting_data/camera{c}/extracted_points/points.txt&quot;)
          cm = np.loadtxt(f&quot;data/calibration/camera_matrix/resulting_data/camera{c}/cmatrix.txt&quot;)
          em, mask = cv.findEssentialMat(basePoints, cameraPoints, cm, cv.RANSAC, 0.9999, 1)
          print(f&quot;essential matrix {c} 1:&quot;)
          print(em)
          print(f&quot;enforcing internal constrain of essential matrix for camera {c}&quot;)
          u, s, v = np.linalg.svd(em)
          em = u.T * np.diag([1, 1, 0]) * v
          print(f&quot;enforced essential matrix {c} :&quot;)
          print(em)
          np.savetxt(f&quot;data/calibration/essential_matrix_and_pose/resulting_data/camera{c}/ematrix.txt&quot;, em)
  </code></pre>
  <p><a href="https://i.stack.imgur.com/zI2cA.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zI2cA.jpg" alt="view from &quot;base camera&quot;" /></a></p>
  <p><a href="https://i.stack.imgur.com/Ky0fy.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Ky0fy.jpg" alt="view from first camera" /></a></p>
  <p><a href="https://i.stack.imgur.com/Wlljv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Wlljv.png" alt="extracted points from &quot;base cam&quot;" /></a></p>
  <p>Here are some normalized sample points of my data:</p>
  <p>base camera:</p>
  <pre><code>6.899999999999999467e-01 4.066666666666666347e-02
  6.899999999999999467e-01 4.066666666666666347e-02
  6.913333333333333552e-01 4.066666666666666347e-02
  6.919999999999999485e-01 4.066666666666666347e-02
  6.946666666666666545e-01 4.066666666666666347e-02
  6.986666666666666581e-01 4.133333333333333304e-02
  7.026666666666666616e-01 4.133333333333333304e-02
  7.073333333333332584e-01 4.199999999999999567e-02
  7.119999999999999662e-01 4.266666666666666524e-02
  7.173333333333332673e-01 4.466666666666666702e-02
  </code></pre>
  <p>first camera:</p>
  <pre><code>3.893333333333333091e-01 6.600000000000000311e-02
  3.900000000000000133e-01 6.600000000000000311e-02
  3.906666666666666621e-01 6.533333333333332660e-02
  3.913333333333333108e-01 6.466666666666666397e-02
  3.939999999999999614e-01 6.333333333333332482e-02
  3.979999999999999649e-01 6.066666666666666735e-02
  4.019999999999999685e-01 5.799999999999999600e-02
  4.066666666666666763e-01 5.600000000000000117e-02
  4.119999999999999774e-01 5.333333333333332982e-02
  4.186666666666666314e-01 5.133333333333333498e-02
  </code></pre>
  <p>camera matrix:</p>
  <pre><code>8.830992819912107734e+02 0.000000000000000000e+00 8.279597017259351333e+02
  0.000000000000000000e+00 8.678798953432041117e+02 5.529431146654350187e+02
  0.000000000000000000e+00 0.000000000000000000e+00 1.000000000000000000e+00
  </code></pre>