boolean computeRectifyH ( double f1 , double f2 , DMatrixRMaj P2 , DMatrixRMaj H ) { estimatePlaneInf . setCamera1 ( f1 , f1 , 0 , 0 , 0 ) ; estimatePlaneInf . setCamera2 ( f2 , f2 , 0 , 0 , 0 ) ; if ( ! estimatePlaneInf . estimatePlaneAtInfinity ( P2 , planeInf ) ) return false ; // TODO add a cost for distance from nominal and scale other cost by focal length fx for each view // RefineDualQuadraticConstraint refine = new RefineDualQuadraticConstraint(); // refine.setZeroSkew(true); // refine.setAspectRatio(true); // refine.setZeroPrinciplePoint(true); // refine.setKnownIntrinsic1(true); // refine.setFixedCamera(false); // // CameraPinhole intrinsic = new CameraPinhole(f1,f1,0,0,0,0,0); // if( !refine.refine(normalizedP.toList(),intrinsic,planeInf)) // return false; K1 . zero ( ) ; K1 . set ( 0 , 0 , f1 ) ; K1 . set ( 1 , 1 , f1 ) ; K1 . set ( 2 , 2 , 1 ) ; MultiViewOps . createProjectiveToMetric ( K1 , planeInf . x , planeInf . y , planeInf . z , 1 , H ) ; return true ; }
Given the focal lengths for the first two views compute homography H