Ask Your Question

Kyp's profile - activity

2018-10-17 11:48:27 -0600 received badge  Popular Question (source)
2016-04-17 18:55:11 -0600 commented answer solvePNP inconsistency when rotating markers on a plane

I simulated the process with 4x larger image resolution (2x in each axis) and the error got smaller (about 4 times smaller for single-marker and 4-marker and 2 times smaller for all-marker). The charts can be seen here.

Still, the general dependency of the rotation angle of the markers on the Z-position is there, and I would like to find it's reason and compensate for it.

It seems to either depend on the corner detection algorithm working differently depending on the angle of the corner, or on solvePNP working differently depending on the distribution of the points.

2016-04-17 16:01:37 -0600 commented question solvePNP inconsistency when rotating markers on a plane

@Eduardo I had corner refinement enabled for my experiments. Disabling it retains the same tendency, only makes the computed camera positions more spaced out.

Do you think corner detection could be biased based on the angle of the corner?

2016-04-17 15:49:19 -0600 commented answer solvePNP inconsistency when rotating markers on a plane

Actually, a scale error was there! The physical printed marker board was streched by 0.4% in one dimension. The remaining problem, however, is not related to the scale error - I have re-run all the experiments with marker board generated synthetically to confirm that the problem is not related to any physical-world phenomena. I have also updated the original question with the new (synthetic) images.

2016-04-14 09:15:34 -0600 commented answer solvePNP inconsistency when rotating markers on a plane

Actually that's almost exactly what I was doing, only in a less direct way.

I've updated the question's pseudocode to make it more clear.

2016-04-14 09:13:37 -0600 commented question solvePNP inconsistency when rotating markers on a plane

Thanks for the suggestions, Eduardo!

I've updated the original question with some of them (and will continue to should I reach further conclusions).

As for the distance, the camera is located about 35cm from the middle of the roundtable. The pattern of found positions is regular enough for me to believe it to have a reason that can be understood, and through it, compensated for.

The reprojection error for the camera calibration (standard opencv with chessboard pattern) used for the position estimation is 0.44.

2016-04-14 09:01:42 -0600 received badge  Editor (source)
2016-04-11 05:06:44 -0600 received badge  Good Question (source)
2016-04-07 23:50:39 -0600 received badge  Nice Question (source)
2016-04-07 17:04:34 -0600 received badge  Student (source)
2016-04-07 12:58:48 -0600 asked a question solvePNP inconsistency when rotating markers on a plane

I'm implementing a 3d laser scanner based on a rotating table with aruco markers on it for camera pose estimation.

Here is a sample captured camera frame, with the aruco markers detected:

image description

The basic pose estimation flow (for one frame) can be summarized as follows:

camera_matrix, distortion_coefficients = readCalibrationParameters()
board_configuration = readBoardConfiguration()
frame = captureCameraFrame()

found_marker_corners = aruco::detectMarkers(frame, board_configuration)

rvec, tvec = cv::solvePNP(found_marker_corners, board_configuration, 
                                      camera_matrix, distortion_coefficients)

R = cv::Rodrigues(rvec)
R = R.t();

camera_position = (-R * tvec);

As the scanner's turntable is flat, the computed camera's Z position (height) should be consistent when rotating the turntable around.

However, this is not the case.

There is a direct relationship between the perceived angle of marker's rotation and the computed camera's Z position, with extremes when the marker is seen straight on and when it's rotated by 45 degrees.

The following charts illustrate this relationship.

EDIT: The charts have been replaced with ones based on synthetic images, so as to make sure the problem is not related to some physical-world phenomena and constrain the problem domain to purely algorithmic. The previous images may be still viewed here.

Single marker results

Effects of finding the camera position based on just one marker (4 points to solvePNP)

Straight view:

image description

View from 45 degrees rotation:

image description

4 middle markers results

Effects of finding the camera position based on the 4 middle markers (16 points to solvePNP)

Straight view:

image description

View from 45 degrees rotation:

image description

All markers results

Effects of finding the camera position based on all the markers (~200 points to solvePNP)

Straight view:

image description

View from 45 degrees rotation:

image description

Already checked

Some of the things I tried which had no effect on the problem (the relationship was still there):

  • using low-resolution camera frames (320x240)
  • detecting 4 extra-large markers instead of 52 small ones
  • using a different camera
  • using different camera calibration / using zero distortion
  • changing corner detection parameters
  • using the two other solvePNP methods, CV_EPNP and CV_P3P (the relationship was still there, but the precision was much worse)

Are the results a limitation of solvePNP, or am I doing something wrong?

Edit:

  • updated the pseudocode to clarify the used methods, according to suggestions
  • added separate charts for 1-marker, 4-marker and all-marker position calculation
  • added reprojection error for the detected points

Edit 2:

It turned out that the printed markers were not exactly square (1mm difference across the entire table), which made some results worse than they should be. After correcting for that, the main problem still remains, however.

I have replaced the images with ones generated synthetically so as to ensure that the problem is algorithm-related (and not related to, say camera calibration or physical dimensions mismatch).