Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

I managed it by casting .astype(np.float32) , and it runs! But, I have a problem: The only think it gives back is the following:

Rotation Matrix:
[[ 1.  0.  0.]
 [ 0.  1.  0.]
 [ 0.  0.  1.]]
[R|t] Matrix:
[[ 1.  0.  0.  0.]
 [ 0.  1.  0.  0.]
 [ 0.  0.  1.  0.]]
Central Point:
[[ 0.]
 [ 0.]
 [ 0.]]

This is the points I grab from the image (imgp):

[[[ 136.]
  [ 270.]]

 [[  65.]
  [ 186.]]

 [[ 140.]
  [ 198.]]

 [[ 261.]
  [ 194.]]]

And these are the World Point Coords:

 [[[ 0.22      ]
  [ 0.005     ]
  [-0.018     ]]

 [[ 0.018     ]
  [ 0.215     ]
  [ 0.01      ]]

 [[ 0.028     ]
  [-0.20999999]
  [ 0.        ]]

 [[ 0.18000001]
  [-0.01      ]
  [-0.16      ]]]

For some reason, the algorithm is doing nothing, or at least it seems. I tried to step down the reprojection error (to as low as 1) and everything stayed the same. With this error, tried to increase the number of iterations, with no results. This is how I am calling the function now:

self.rvec, self.tvec, inliers = cv2.solvePnPRansac(worldp.astype(np.float32), imgp.astype(np.float32), self.cameraMatrix.astype(np.float32), self.distCoeffs.astype(np.float32), self.rvec, self.tvec, useExtrinsicGuess=self.extrinsicGuess, iterationsCount=self.RansacIterations, reprojectionError=self.reprojectionError,flags=self.RansacMethod)

Hope you can help me!

With my best regards,

Pedro

I managed it by casting .astype(np.float32) , and it runs! But, I have a problem: The only think it gives back is the following:

Rotation Matrix:
[[ 1.  0.  0.]
 [ 0.  1.  0.]
 [ 0.  0.  1.]]
[R|t] Matrix:
[[ 1.  0.  0.  0.]
 [ 0.  1.  0.  0.]
 [ 0.  0.  1.  0.]]
Central Point:
[[ 0.]
 [ 0.]
 [ 0.]]

This is the points I grab from the image (imgp):

[[[ 136.]
  [ 270.]]

 [[  65.]
  [ 186.]]

 [[ 140.]
  [ 198.]]

 [[ 261.]
  [ 194.]]]

And these are the World Point Coords:

 [[[ 0.22      ]
  [ 0.005     ]
  [-0.018     ]]

 [[ 0.018     ]
  [ 0.215     ]
  [ 0.01      ]]

 [[ 0.028     ]
  [-0.20999999]
  [ 0.        ]]

 [[ 0.18000001]
  [-0.01      ]
  [-0.16      ]]]

For some reason, the algorithm is doing nothing, or at least it seems. I tried to step down the reprojection error (to as low as 1) and everything stayed the same. With this error, tried to increase the number of iterations, with no results. This is how I am calling the function now:

self.rvec, self.tvec, inliers = cv2.solvePnPRansac(worldp.astype(np.float32), imgp.astype(np.float32), self.cameraMatrix.astype(np.float32), self.distCoeffs.astype(np.float32), self.rvec, self.tvec, useExtrinsicGuess=self.extrinsicGuess, iterationsCount=self.RansacIterations, reprojectionError=self.reprojectionError,flags=self.RansacMethod)

Hope you can help me!

With my best regards,

Pedro

EDIT: I noticed that if I increase reprojection error it works, but I am putting it at like 100. this is way too much I think. What can I do to increase the quality of the measurement?