Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Apply infinite homography to image

Hi,
I want to apply a infinite homography to an image, but I dont know how to do it.
I'm working with the openCV api for java.
I have the below code, but I dont get good results.
From image A, I get image B
Do someone know how to apply this homography ?

image description


Calib3d.stereoCalibrate(objectPoints_1, imagePoints_1, imagePoints_2, 
    cameraMatrix_1, distCoeffs_1, cameraMatrix_2, distCoeffs_2, imageSize_1, R, T, E, F, 
    new TermCriteria( TermCriteria.MAX_ITER + TermCriteria.EPS , 30, 0.1), 
    Calib3d.CALIB_FIX_INTRINSIC );

Imgproc.initUndistortRectifyMap(cameraMatrix_1, distCoeffs_1, new Mat(), new Mat(), newImageSize_1, CvType.CV_32FC1, mapx_1, mapy_1);
Imgproc.initUndistortRectifyMap(cameraMatrix_2, distCoeffs_2, new Mat(), new Mat(), newImageSize_2, CvType.CV_32FC1, mapx_2, mapy_2);

Imgproc.remap(image_1, undistorted_1, mapx_1, mapy_1, Imgproc.INTER_LINEAR);
Imgproc.remap(image_2, undistorted_2, mapx_2, mapy_2, Imgproc.INTER_LINEAR);

Mat cameraMatrix_2_inv = new Mat(cameraMatrix_2.size(),cameraMatrix_2.type());
Core.invert(cameraMatrix_2, cameraMatrix_2_inv);
Core.invert(R, R_inv);

// inverse Homography: H_inf = k1*R*k2_inv
Mat H_inf = new Mat(3,3,CvType.CV_64FC1);
Core.gemm(cameraMatrix_1, R, 1, cameraMatrix_2_inv, 1, H_inf);

Mat outputImage_3 = new Mat();
Imgproc.warpPerspective(undistorted_2, outputImage_3, H_inf, undistorted_2.size());

Apply infinite homography to image

Hi,
I want to apply a infinite homography to an image, but I dont know how to do it.
I'm working with the openCV api for java.
I have the below code, but I dont get good results.
From image A, I get image B
Do someone know how to apply this homography ?

image description


Calib3d.stereoCalibrate(objectPoints_1, imagePoints_1, imagePoints_2, 
    cameraMatrix_1, distCoeffs_1, cameraMatrix_2, distCoeffs_2, imageSize_1, R, T, E, F, 
    new TermCriteria( TermCriteria.MAX_ITER + TermCriteria.EPS , 30, 0.1), 
    Calib3d.CALIB_FIX_INTRINSIC );

Imgproc.initUndistortRectifyMap(cameraMatrix_1, distCoeffs_1, new Mat(), new Mat(), newImageSize_1, CvType.CV_32FC1, mapx_1, mapy_1);
Imgproc.initUndistortRectifyMap(cameraMatrix_2, distCoeffs_2, new Mat(), new Mat(), newImageSize_2, CvType.CV_32FC1, mapx_2, mapy_2);

Imgproc.remap(image_1, undistorted_1, mapx_1, mapy_1, Imgproc.INTER_LINEAR);
Imgproc.remap(image_2, undistorted_2, mapx_2, mapy_2, Imgproc.INTER_LINEAR);

Mat cameraMatrix_2_inv = new Mat(cameraMatrix_2.size(),cameraMatrix_2.type());
Core.invert(cameraMatrix_2, cameraMatrix_2_inv);
Core.invert(R, R_inv);

// inverse Homography: H_inf = k1*R*k2_inv
Mat H_inf = new Mat(3,3,CvType.CV_64FC1);
Core.gemm(cameraMatrix_1, R, 1, cameraMatrix_2_inv, 1, H_inf);

Mat outputImage_3 = new Mat();
Imgproc.warpPerspective(undistorted_2, outputImage_3, H_inf, undistorted_2.size());