OpenCV Q&A Forum - RSS feedhttp://answers.opencv.org/questions/OpenCV answersenCopyright <a href="http://www.opencv.org">OpenCV foundation</a>, 2012-2018.Tue, 26 Nov 2019 21:16:22 -0600Is there a solvePnP function for the fisheye Camera model?http://answers.opencv.org/question/67356/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
Wed, 29 Jul 2015 14:06:25 -0500http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/Comment by Soarez for <p>I did an exercise recently where I used solvePnp to estimate the position of a camera. That used the normal camera model.</p>
<p>Does there exist a solvePnP() function for the fisheye model as well?</p>
<p>Kind regards</p>
<p>Jesper</p>
http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?comment=190270#post-id-190270Hi, you manage to get it working? I had the some problem .Thu, 26 Apr 2018 14:05:19 -0500http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?comment=190270#post-id-190270Answer by Soarez for <p>I did an exercise recently where I used solvePnp to estimate the position of a camera. That used the normal camera model.</p>
<p>Does there exist a solvePnP() function for the fisheye model as well?</p>
<p>Kind regards</p>
<p>Jesper</p>
http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?answer=191149#post-id-191149Hi 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.
![image description](/upfiles/1525864733320361.png)
=)
Wed, 09 May 2018 06:19:59 -0500http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?answer=191149#post-id-191149Comment by off99555 for <p>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:</p>
<p>im working with a chessboard , and findchessboard function.</p>
<pre><code>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);
</code></pre>
<p>after i have the corrected chessboard corners, i create a fake_distorcion vector, and use solvepnp with that distorcion vector.</p>
<pre><code> Mat fake_distCoeffs = (Mat_<double>(4,1) << 0, 0, 0, 0);
solvePnP(points, corners, cameraMatrix, fake_distCoeffs, rvec, tvec,false,CV_EPNP);
</code></pre>
<p>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.</p>
<p>here is a screenshot of the chessboard corners on the camera frame.
<img alt="image description" src="/upfiles/1525864733320361.png"></p>
<p>=)</p>
http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?comment=222305#post-id-222305This answer is slightly wrong. You need to provide np.eye(3) as cameraMatrix argument to solvePnP.Tue, 26 Nov 2019 21:16:22 -0600http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?comment=222305#post-id-222305Comment by V for <p>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:</p>
<p>im working with a chessboard , and findchessboard function.</p>
<pre><code>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);
</code></pre>
<p>after i have the corrected chessboard corners, i create a fake_distorcion vector, and use solvepnp with that distorcion vector.</p>
<pre><code> Mat fake_distCoeffs = (Mat_<double>(4,1) << 0, 0, 0, 0);
solvePnP(points, corners, cameraMatrix, fake_distCoeffs, rvec, tvec,false,CV_EPNP);
</code></pre>
<p>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.</p>
<p>here is a screenshot of the chessboard corners on the camera frame.
<img alt="image description" src="/upfiles/1525864733320361.png"></p>
<p>=)</p>
http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?comment=216920#post-id-216920I can confirm this answer is correct and is caused by solvePnP using cv::undistortPoints rather than cv::fisheye::undistortPoints.Wed, 14 Aug 2019 01:16:14 -0500http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?comment=216920#post-id-216920Comment by sverma for <p>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:</p>
<p>im working with a chessboard , and findchessboard function.</p>
<pre><code>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);
</code></pre>
<p>after i have the corrected chessboard corners, i create a fake_distorcion vector, and use solvepnp with that distorcion vector.</p>
<pre><code> Mat fake_distCoeffs = (Mat_<double>(4,1) << 0, 0, 0, 0);
solvePnP(points, corners, cameraMatrix, fake_distCoeffs, rvec, tvec,false,CV_EPNP);
</code></pre>
<p>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.</p>
<p>here is a screenshot of the chessboard corners on the camera frame.
<img alt="image description" src="/upfiles/1525864733320361.png"></p>
<p>=)</p>
http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?comment=208500#post-id-208500@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?Thu, 07 Feb 2019 03:16:33 -0600http://answers.opencv.org/question/67356/is-there-a-solvepnp-function-for-the-fisheye-camera-model/?comment=208500#post-id-208500