Ask Your Question
0

Assertion failure durring defishing in initUndistortRectifyMap

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

salahuddin_12 gravatar image

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

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 -0600 )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 -0600 )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 -0600 )edit
1
berak gravatar imageberak ( 2016-08-26 07:47:13 -0600 )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 -0600 )edit

"loosing some of the images" - means ?

berak gravatar imageberak ( 2016-08-26 08:30:16 -0600 )edit
salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 08:34:16 -0600 )edit
salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 08:34:45 -0600 )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 -0600 )edit

^^ url fail.

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

do you mean, that undistorting removes part of the image ? that's kinda unavoidable. all you can do is try the best calibration possible (least rms)

(iirc, undistort also returns the regions, which are still valid in the image.)

berak gravatar imageberak ( 2016-08-26 08:44:38 -0600 )edit

origionalundistorted Can you check again

salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 08:46:02 -0600 )edit

yes, links work now. but seee comment above.

berak gravatar imageberak ( 2016-08-26 08:49:12 -0600 )edit

I will try to improve calibration. Thanks for helping me out

salahuddin_12 gravatar imagesalahuddin_12 ( 2016-08-26 08:50:44 -0600 )edit

1 answer

Sort by ยป oldest newest most voted
1

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

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 -0600

Seen: 1,237 times

Last updated: Aug 26 '16