Ask Your Question
0

Assertion failure durring defishing in initUndistortRectifyMap

asked 2016-08-26 07:32:21 -0500

salahuddin_12 gravatar image

updated 2016-08-26 07:36:05 -0500

I'm trying to do fish an image by providing "camera_matrix" and "distortion_coefficients" to cv::fisheye::undistortImage. problem is I'm getting Assertion error. Reason is the distortion coefficients which i'm getting through camera calibration are 5x1

<distortion_coefficients type_id="opencv-matrix"> <rows>5</rows> <cols>1</cols> <dt>d</dt> <data> -2.0834245161331000e-01 5.8179563841609050e-02 0. 0. -8.0440183287724919e-03</data></distortion_coefficients>

but undistortImage method accepts 4X1 distortion matrix. Any idea whats the way around to this problem

edit retag flag offensive close merge delete

Comments

Following is the error which I'm getting

'error: (-215) K.size() == Size(3, 3) && (D.empty() || D.total() == 4) in function initUndistortRectifyMap'

salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 07:36:41 -0500 )edit

how did you achieve those dist coeffs ?

(my guess is, you have to use a fisheye calibration as well, not the ordinary one.)

berak gravatar imageberak ( 2016-08-26 07:37:39 -0500 )edit

I used "opencv/samples/cpp/tutorial_code/calib3d/camera_calibration/camera_calibration.cpp" script.

salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 07:39:49 -0500 )edit
1
berak gravatar imageberak ( 2016-08-26 07:47:13 -0500 )edit

It worked like a charm. Can you write it as an answer so then i can mark it. One more thing. After applying the distortion I'm loosing some of the image (Is there a way to avoid that).

salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 07:59:40 -0500 )edit

"loosing some of the images" - means ?

berak gravatar imageberak ( 2016-08-26 08:30:16 -0500 )edit
salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 08:34:16 -0500 )edit
salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 08:34:45 -0500 )edit

I was acceding my comment limit so i had to divide it in two. If you see I'm loosing some of the image in undistorted version. Any idea how to avoid it.

salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 08:35:58 -0500 )edit

^^ url fail.

berak gravatar imageberak ( 2016-08-26 08:41:08 -0500 )edit

1 answer

Sort by ยป oldest newest most voted
1

answered 2016-08-26 08:29:35 -0500

berak gravatar image

you have to do a proper fisheye calibration, to get the appropriate distortion coeffs.

if you're using opencv's calibration sample, enable it here

then try again with the new distortion coeffs.

edit flag offensive delete link more

Question Tools

1 follower

Stats

Asked: 2016-08-26 07:32:21 -0500

Seen: 969 times

Last updated: Aug 26 '16