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

Roque's profile - activity

2015-09-15 08:18:06 -0500 commented question solvePnP / solvePnPRansac axis references

UP - BUMP - UP

2015-09-13 17:18:39 -0500 asked a question solvePnP / solvePnPRansac axis references

Hello folks,

I am having problems getting a realiable pose estimation using solvePnPRansac. I am using the following parameters for the Ransac:

self.rvec = np.array([-1],dtype=np.float32)
self.tvec = np.array([-1],dtype=np.float32)
self.extrinsicGuess = False
self.RansacIterations = 2000
self.reprojectionError = 100
self.RansacMethod = cv2.CV_P3P

I have 4 World Points and I get 4 image points from the blobs detected. The blobs are well detected, as proved by the following image:

Blobs detection

Prolems arise when I project points on the body frame. The circle representes the projected points. Projecting the green blob coords, returns the following: green blob projection

Projecting the blue blob: image description

Projecting the left Red blob (upper red): image description

And finally, projecting the down red blob: image description

Projecting the center coords, returns this: image description

I do not have any world coords at the origin.

What can this be, or what can I do, to solve this problem?

Thank you in advance!

2015-09-11 18:06:28 -0500 answered a question solvePnPRansac CV_32F error

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?

2015-09-11 08:56:11 -0500 answered a question solvePnPRansac CV_32F error

UP - BUMP - UP

2015-09-09 08:49:53 -0500 received badge  Editor (source)
2015-09-09 08:21:17 -0500 asked a question solvePnPRansac CV_32F error

Hello folks,

First time here, so forgive me if I do something wrong. Of course, if you need more info on the problem, tell me!

I got the following error after running solvePnPRansac:

OpenCV Error: Assertion failed (opoints.depth() == CV_32F) in solvePnPRansac, file /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/solvepnp.cpp, line 284
[ERROR] [WallTime: 1441804199.566629] bad callback: <bound method image_converter.callback of <__main__.image_converter instance at 0x7fbe65cfd050>>
Traceback (most recent call last):
  File "/opt/ros/indigo/lib/python2.7/dist-packages/rospy/topics.py", line 702, in _invoke_callback
    cb(msg)
  File "./image_pos_processing.py", line 195, in callback
    self.rvec, self.tvec, inliers = cv2.solvePnPRansac(np.array(self.WorldPointCoords), self.ImageCoords, self.cameraMatrix, self.distCoeffs, self.rvec, self.tvec, self.extrinsicGuess, self.RansacIterations, self.reprojectionError,flags=self.RansacMethod)
error: /build/buildd/opencv-2.4.8+dfsg1/modules/calib3d/src/solvepnp.cpp:284: error: (-215) opoints.depth() == CV_32F in function solvePnPRansac

Here are the parameters I am sending to the algorithm, ordered:

[[ 0.26   0.01  -0.02 ]
 [ 0.025 -0.19   0.005]
 [ 0.015  0.215  0.01 ]
 [ 0.185 -0.015 -0.17 ]]
[[271 382]
 [566 194]
 [301 213]
 [157 158]]
[[ 829.411513    0.        317.462981]
 [   0.        828.855954  246.688352]
 [   0.          0.          1.      ]]
[-0.03096   0.126496  0.002959 -0.004002  0.      ]
-1
-1
False
500
10.0
1

Any tips on this?

Thank you in advance!

EDIT: If I cast the arrays to int type with .astype(int) it returns the same error.