Fisheye un-distort on Android

asked 2020-03-30 08:54:27 -0600

4ndre gravatar image


Working with a fisheye lens and want to undistort the picture. Did this plenty in Python before so I thought I just transfer the code. Turned out Matrix definition is not as simple, but I found a work-around. However, now all I get is an about half the size image (which comes from the halfed new matrix), but no correction for distortion. Maybe my matrices weren't correct after all. Here my code ("this" is a camera class that contains a frame):

double[] Kval=new double[]{369.8206061505334, 0.0, 653.979059378939, 0.0, 369.4813834030355, 375.6647592958235, 0.0, 0.0, 1.0};
            double[] Dval=new double[]{-0.020327154188024447, -0.0034195654392881036, -2.6653078505195146e-05, -0.00010493184049784981};
            Mat K=new Mat(new Size(3,3),0);
            Mat nk=K.clone();
            Mat D=new Mat(new Size(4,1),0);
            Mat map1=new Mat();
            Mat map2=new Mat();
            Imgproc.initUndistortRectifyMap(K,D,Mat.eye(3,3,0), nk, new Size(frame.cols(),frame.rows()),CV_16SC2, map1,map2);
edit retag flag offensive close merge delete