Ask Your Question

# Is there a solvePnP function for the fisheye Camera model?

I did an exercise recently where I used solvePnp to estimate the position of a camera. That used the normal camera model.

Does there exist a solvePnP() function for the fisheye model as well?

Kind regards

Jesper

edit retag close merge delete

## Comments

Hi, you manage to get it working? I had the some problem .

( 2018-04-26 14:05:19 -0600 )edit

## 1 answer

Sort by » oldest newest most voted

Hi i got it to work for me, u can try the same =). Since ther is no function to compute pose on fisheye lens, and the solvePnP performes the lens correction internaly, what i did was this:

im working with a chessboard , and findchessboard function.

bool patternfound = findChessboardCorners(gray, patternsize, corners_distorted,
//CALIB_CB_ADAPTIVE_THRESH +
//CALIB_CB_NORMALIZE_IMAGE +
CALIB_CB_FAST_CHECK);
cornerSubPix(corners_distorted,corners,....);
fisheye::undistortPoints ( corners_distorted, corners, cameraMatrix, distCoeffs , cameraMatrix);


after i have the corrected chessboard corners, i create a fake_distorcion vector, and use solvepnp with that distorcion vector.

 Mat fake_distCoeffs = (Mat_<double>(4,1) << 0, 0, 0, 0);
solvePnP(points, corners, cameraMatrix, fake_distCoeffs, rvec, tvec,false,CV_EPNP);


And this got it working. my camera lens is 110º FOV, and i also got it to work with the normal model, but in both solvepnp as lot of error , i will try to improve the intrinsic parameters and other methods on solvpnp.

here is a screenshot of the chessboard corners on the camera frame.

=)

more

## Comments

@Soarez I tried the method but rvec and tvec appear to vary with different snapshots of the board (board and camera position are fixed in all these samples). do you have any idea why this is happening?

( 2019-02-07 03:16:33 -0600 )edit

I can confirm this answer is correct and is caused by solvePnP using cv::undistortPoints rather than cv::fisheye::undistortPoints.

( 2019-08-14 01:16:14 -0600 )edit

This answer is slightly wrong. You need to provide np.eye(3) as cameraMatrix argument to solvePnP.

( 2019-11-26 21:16:22 -0600 )edit

Official site

GitHub

Wiki

Documentation

## Stats

Asked: 2015-07-29 14:06:25 -0600

Seen: 1,986 times

Last updated: May 09 '18