/**************************************************************************************************** estimateFundamentalMatrix(InputArray1,InputArray2,'method','RANSAC','param1',2,'param2',0.99); possible methods are 7POINT,8POINT,RANSAC,LMEDS param1- It indiacates maximum distance from a point to an epipolar line in pixels param2- It specifies a desirable level of confidence ********************************************************* ***********************************************/ #include #include "opencv2/core/core.hpp" #include "opencv2/highgui/highgui.hpp" #include "opencv2/opencv.hpp" #include "opencv2/imgproc/imgproc.hpp" #include "opencv2/calib3d/calib3d.hpp" #include using namespace cv; using namespace std; extern "C" { #include "api_scilab.h" #include "Scierror.h" #include "BOOL.h" #include #include #include "../common.h" int opencv_estimateFundamentalMat(char *fname, unsigned long fname_len) { SciErr sciErr; int intErr=0; int iComplex = 0; int iType = 0; int *piAddr = NULL; int *piLen = NULL; int iRows,iCols; int iA1Rows=0,iA1Cols=0,iA2Rows=0,iA2Cols=0; int method=FM_RANSAC; int nbInputArguments,iter,i,j; char **pstData = NULL; char *currentArg = NULL; bool *providedArgs = NULL; double* pdblReal = NULL; double *iArray1=NULL,*iArray2=NULL; double param1=3,param2=0.99; vector point1,point2; CheckInputArgument(pvApiCtx, 2, 8); CheckOutputArgument(pvApiCtx, 1, 1) ; nbInputArguments = *getNbInputArgument(pvApiCtx); providedArgs = (bool*) malloc(sizeof(bool) * 3); sciErr = getVarAddressFromPosition(pvApiCtx, 1, &piAddr); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } sciErr = getVarType(pvApiCtx, piAddr, &iType); if(sciErr.iErr || iType != sci_matrix) { printError(&sciErr, 0); return 0; } //Get complexity iComplex = isVarComplex(pvApiCtx, piAddr); //Check complexity if(iComplex) { Scierror(999, "%s: Wrong type for input argument: A complex number is not expected.\n"); return 0; } sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &iA1Rows, &iA1Cols, &iArray1); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } sciErr = getVarAddressFromPosition(pvApiCtx, 2, &piAddr); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } sciErr = getVarType(pvApiCtx, piAddr, &iType); if(sciErr.iErr || iType != sci_matrix) { printError(&sciErr, 0); return 0; } //Get complexity iComplex = isVarComplex(pvApiCtx, piAddr); //Check complexity if(iComplex) { Scierror(999, "%s: Wrong type for input argument: A complex number is not expected.\n"); return 0; } sciErr = getMatrixOfDouble(pvApiCtx, piAddr, &iA2Rows, &iA2Cols, &iArray2); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } if(iA1Rows != iA2Rows) { Scierror(999, "There must be the same number of points in both input arrays\n"); return 0; } for(i=0;i(i,j); } } sciErr = createMatrixOfDouble(pvApiCtx, nbInputArgument(pvApiCtx) + 1, fm.rows , 3, pdblReal); if(sciErr.iErr) { printError(&sciErr, 0); return 0; } AssignOutputVariable(pvApiCtx, 1) = nbInputArgument(pvApiCtx) + 1; ReturnArguments(pvApiCtx); return 0; } }