]> rtime.felk.cvut.cz Git - opencv.git/blobdiff - opencv/src/cv/cvfundam.cpp
fixed output mask in cvFindHomography (thanks to robozyt, ticket #236)
[opencv.git] / opencv / src / cv / cvfundam.cpp
index bffed228819d4669269f901761f03085ad17186f..0b6f11ff5304694e21f0f25edea2ee3c2c6ca620 100644 (file)
@@ -42,6 +42,8 @@
 #include "_cv.h"
 #include "_cvmodelest.h"
 
+using namespace cv;
+
 template<typename T> int icvCompressPoints( T* ptr, const uchar* mask, int mstep, int count )
 {
     int i, j;
@@ -73,6 +75,7 @@ CvHomographyEstimator::CvHomographyEstimator(int _modelPoints)
     : CvModelEstimator2(_modelPoints, cvSize(3,3), 1)
 {
     assert( _modelPoints == 4 || _modelPoints == 5 );
+    checkPartialSubsets = false;
 }
 
 int CvHomographyEstimator::runKernel( const CvMat* m1, const CvMat* m2, CvMat* H )
@@ -83,8 +86,8 @@ int CvHomographyEstimator::runKernel( const CvMat* m1, const CvMat* m2, CvMat* H
 
     double LtL[9][9], W[9][9], V[9][9];
     CvMat _LtL = cvMat( 9, 9, CV_64F, LtL );
-    CvMat _W = cvMat( 9, 9, CV_64F, W );
-    CvMat _V = cvMat( 9, 9, CV_64F, V );
+    CvMat matW = cvMat( 9, 9, CV_64F, W );
+    CvMat matV = cvMat( 9, 9, CV_64F, V );
     CvMat _H0 = cvMat( 3, 3, CV_64F, V[8] );
     CvMat _Htemp = cvMat( 3, 3, CV_64F, V[7] );
     CvPoint2D64f cM={0,0}, cm={0,0}, sM={0,0}, sm={0,0};
@@ -106,6 +109,9 @@ int CvHomographyEstimator::runKernel( const CvMat* m1, const CvMat* m2, CvMat* H
         sM.y += fabs(M[i].y - cM.y);
     }
 
+    if( fabs(sm.x) < DBL_EPSILON || fabs(sm.y) < DBL_EPSILON ||
+        fabs(sM.x) < DBL_EPSILON || fabs(sM.y) < DBL_EPSILON )
+        return 0;
     sm.x = count/sm.x; sm.y = count/sm.y;
     sM.x = count/sM.x; sM.y = count/sM.y;
 
@@ -128,8 +134,8 @@ int CvHomographyEstimator::runKernel( const CvMat* m1, const CvMat* m2, CvMat* H
     }
     cvCompleteSymm( &_LtL );
 
-    //cvSVD( &_LtL, &_W, 0, &_V, CV_SVD_MODIFY_A + CV_SVD_V_T );
-    cvEigenVV( &_LtL, &_V, &_W );
+    //cvSVD( &_LtL, &matW, 0, &matV, CV_SVD_MODIFY_A + CV_SVD_V_T );
+    cvEigenVV( &_LtL, &matV, &matW );
     cvMatMul( &_invHnorm, &_H0, &_Htemp );
     cvMatMul( &_Htemp, &_Hnorm2, &_H0 );
     cvConvertScale( &_H0, H, 1./_H0.data.db[8] );
@@ -215,20 +221,16 @@ cvFindHomography( const CvMat* objectPoints, const CvMat* imagePoints,
     const double confidence = 0.995;
     const int maxIters = 2000;
     bool result = false;
-    CvMat *m = 0, *M = 0, *tempMask = 0;
-
-    CV_FUNCNAME( "cvFindHomography" );
-
-    __BEGIN__;
+    Ptr<CvMat> m, M, tempMask;
 
     double H[9];
-    CvMat _H = cvMat( 3, 3, CV_64FC1, H );
+    CvMat matH = cvMat( 3, 3, CV_64FC1, H );
     int count;
 
-    CV_ASSERT( CV_IS_MAT(imagePoints) && CV_IS_MAT(objectPoints) );
+    CV_Assert( CV_IS_MAT(imagePoints) && CV_IS_MAT(objectPoints) );
 
     count = MAX(imagePoints->cols, imagePoints->rows);
-    CV_ASSERT( count >= 4 );
+    CV_Assert( count >= 4 );
 
     m = cvCreateMat( 1, count, CV_64FC2 );
     cvConvertPointsHomogeneous( imagePoints, m );
@@ -238,45 +240,39 @@ cvFindHomography( const CvMat* objectPoints, const CvMat* imagePoints,
 
     if( mask )
     {
-        CV_ASSERT( CV_IS_MASK_ARR(mask) && CV_IS_MAT_CONT(mask->type) &&
+        CV_Assert( CV_IS_MASK_ARR(mask) && CV_IS_MAT_CONT(mask->type) &&
             (mask->rows == 1 || mask->cols == 1) &&
             mask->rows*mask->cols == count );
-        tempMask = mask;
+        tempMask = cvCloneMat(mask);
     }
     else if( count > 4 )
         tempMask = cvCreateMat( 1, count, CV_8U );
-    if( tempMask )
+    if( !tempMask.empty() )
         cvSet( tempMask, cvScalarAll(1.) );
 
-    {
-    CvHomographyEstimator estimator( MIN(count, 5) );
+    CvHomographyEstimator estimator( MIN(count, 4) );
     if( count == 4 )
         method = 0;
     if( method == CV_LMEDS )
-        result = estimator.runLMeDS( M, m, &_H, tempMask, confidence, maxIters );
+        result = estimator.runLMeDS( M, m, &matH, tempMask, confidence, maxIters );
     else if( method == CV_RANSAC )
-        result = estimator.runRANSAC( M, m, &_H, tempMask, ransacReprojThreshold, confidence, maxIters);
+        result = estimator.runRANSAC( M, m, &matH, tempMask, ransacReprojThreshold, confidence, maxIters);
     else
-        result = estimator.runKernel( M, m, &_H ) > 0;
+        result = estimator.runKernel( M, m, &matH ) > 0;
 
     if( result && count > 4 )
     {
         icvCompressPoints( (CvPoint2D64f*)M->data.ptr, tempMask->data.ptr, 1, count );
         count = icvCompressPoints( (CvPoint2D64f*)m->data.ptr, tempMask->data.ptr, 1, count );
         M->cols = m->cols = count;
-        estimator.refine( M, m, &_H, 10 );
-    }
+        estimator.refine( M, m, &matH, 10 );
     }
 
     if( result )
-        cvConvert( &_H, __H );
-
-    __END__;
-
-    cvReleaseMat( &m );
-    cvReleaseMat( &M );
-    if( tempMask != mask )
-        cvReleaseMat( &tempMask );
+        cvConvert( &matH, __H );
+    
+    if( mask && tempMask )
+        cvCopy( tempMask, mask );
 
     return (int)result;
 }
@@ -578,29 +574,24 @@ void CvFMEstimator::computeReprojError( const CvMat* _m1, const CvMat* _m2,
 }
 
 
-CV_IMPL int
-cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
-                      CvMat* fmatrix, int method,
-                      double param1, double param2, CvMat* mask )
+CV_IMPL int cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
+                                  CvMat* fmatrix, int method,
+                                  double param1, double param2, CvMat* mask )
 {
     int result = 0;
-    CvMat *m1 = 0, *m2 = 0, *tempMask = 0;
-
-    CV_FUNCNAME( "cvFindFundamentalMat" );
-
-    __BEGIN__;
+    Ptr<CvMat> m1, m2, tempMask;
 
     double F[3*9];
     CvMat _F3x3 = cvMat( 3, 3, CV_64FC1, F ), _F9x3 = cvMat( 9, 3, CV_64FC1, F );
     int count;
 
-    CV_ASSERT( CV_IS_MAT(points1) && CV_IS_MAT(points2) && CV_ARE_SIZES_EQ(points1, points2) );
-    CV_ASSERT( CV_IS_MAT(fmatrix) && fmatrix->cols == 3 &&
+    CV_Assert( CV_IS_MAT(points1) && CV_IS_MAT(points2) && CV_ARE_SIZES_EQ(points1, points2) );
+    CV_Assert( CV_IS_MAT(fmatrix) && fmatrix->cols == 3 &&
         (fmatrix->rows == 3 || (fmatrix->rows == 9 && method == CV_FM_7POINT)) );
 
     count = MAX(points1->cols, points1->rows);
     if( count < 7 )
-        EXIT;
+        return 0;
 
     m1 = cvCreateMat( 1, count, CV_64FC2 );
     cvConvertPointsHomogeneous( points1, m1 );
@@ -610,18 +601,16 @@ cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
 
     if( mask )
     {
-        CV_ASSERT( CV_IS_MASK_ARR(mask) && CV_IS_MAT_CONT(mask->type) &&
+        CV_Assert( CV_IS_MASK_ARR(mask) && CV_IS_MAT_CONT(mask->type) &&
             (mask->rows == 1 || mask->cols == 1) &&
             mask->rows*mask->cols == count );
-        tempMask = cvCreateMatHeader(1, count, CV_8U);
-        cvSetData(tempMask, mask->data.ptr, 0);
+        tempMask = cvCloneMat(mask);
     }
     else if( count > 8 )
         tempMask = cvCreateMat( 1, count, CV_8U );
-    if( tempMask )
+    if( !tempMask.empty() )
         cvSet( tempMask, cvScalarAll(1.) );
 
-    {
     CvFMEstimator estimator( MIN(count, (method & 3) == CV_FM_7POINT ? 7 : 8) );
     if( count == 7 )
         result = estimator.run7Point(m1, m2, &_F9x3);
@@ -639,37 +628,27 @@ cvFindFundamentalMat( const CvMat* points1, const CvMat* points2,
         else
             result = estimator.runLMeDS(m1, m2, &_F3x3, tempMask, param2 );
         if( result <= 0 )
-            EXIT;
+            return 0;
         /*icvCompressPoints( (CvPoint2D64f*)m1->data.ptr, tempMask->data.ptr, 1, count );
         count = icvCompressPoints( (CvPoint2D64f*)m2->data.ptr, tempMask->data.ptr, 1, count );
         assert( count >= 8 );
         m1->cols = m2->cols = count;
         estimator.run8Point(m1, m2, &_F3x3);*/
     }
-    }
 
     if( result )
         cvConvert( fmatrix->rows == 3 ? &_F3x3 : &_F9x3, fmatrix );
-
-    __END__;
-
-    cvReleaseMat( &m1 );
-    cvReleaseMat( &m2 );
-    if( tempMask != mask )
-        cvReleaseMat( &tempMask );
+    
+    if( mask && tempMask )
+        cvCopy( tempMask, mask );
 
     return result;
 }
 
 
-CV_IMPL void
-cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
-                             const CvMat* fmatrix, CvMat* lines )
+CV_IMPL void cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
+                                          const CvMat* fmatrix, CvMat* lines )
 {
-    CV_FUNCNAME( "cvComputeCorrespondEpilines" );
-
-    __BEGIN__;
-
     int abc_stride, abc_plane_stride, abc_elem_size;
     int plane_stride, stride, elem_size;
     int i, dims, count, depth, cn, abc_dims, abc_count, abc_depth, abc_cn;
@@ -679,12 +658,12 @@ cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
     CvMat F = cvMat( 3, 3, CV_64F, f );
 
     if( !CV_IS_MAT(points) )
-        CV_ERROR( !points ? CV_StsNullPtr : CV_StsBadArg, "points parameter is not a valid matrix" );
+        CV_Error( !points ? CV_StsNullPtr : CV_StsBadArg, "points parameter is not a valid matrix" );
 
     depth = CV_MAT_DEPTH(points->type);
     cn = CV_MAT_CN(points->type);
     if( (depth != CV_32F && depth != CV_64F) || (cn != 1 && cn != 2 && cn != 3) )
-        CV_ERROR( CV_StsUnsupportedFormat, "The format of point matrix is unsupported" );
+        CV_Error( CV_StsUnsupportedFormat, "The format of point matrix is unsupported" );
 
     if( points->rows > points->cols )
     {
@@ -694,30 +673,30 @@ cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
     else
     {
         if( (points->rows > 1 && cn > 1) || (points->rows == 1 && cn == 1) )
-            CV_ERROR( CV_StsBadSize, "The point matrix does not have a proper layout (2xn, 3xn, nx2 or nx3)" );
+            CV_Error( CV_StsBadSize, "The point matrix does not have a proper layout (2xn, 3xn, nx2 or nx3)" );
         dims = cn * points->rows;
         count = points->cols;
     }
 
     if( dims != 2 && dims != 3 )
-        CV_ERROR( CV_StsOutOfRange, "The dimensionality of points must be 2 or 3" );
+        CV_Error( CV_StsOutOfRange, "The dimensionality of points must be 2 or 3" );
 
     if( !CV_IS_MAT(fmatrix) )
-        CV_ERROR( !fmatrix ? CV_StsNullPtr : CV_StsBadArg, "fmatrix is not a valid matrix" );
+        CV_Error( !fmatrix ? CV_StsNullPtr : CV_StsBadArg, "fmatrix is not a valid matrix" );
 
     if( CV_MAT_TYPE(fmatrix->type) != CV_32FC1 && CV_MAT_TYPE(fmatrix->type) != CV_64FC1 )
-        CV_ERROR( CV_StsUnsupportedFormat, "fundamental matrix must have 32fC1 or 64fC1 type" );
+        CV_Error( CV_StsUnsupportedFormat, "fundamental matrix must have 32fC1 or 64fC1 type" );
 
     if( fmatrix->cols != 3 || fmatrix->rows != 3 )
-        CV_ERROR( CV_StsBadSize, "fundamental matrix must be 3x3" );
+        CV_Error( CV_StsBadSize, "fundamental matrix must be 3x3" );
 
     if( !CV_IS_MAT(lines) )
-        CV_ERROR( !lines ? CV_StsNullPtr : CV_StsBadArg, "lines parameter is not a valid matrix" );
+        CV_Error( !lines ? CV_StsNullPtr : CV_StsBadArg, "lines parameter is not a valid matrix" );
 
     abc_depth = CV_MAT_DEPTH(lines->type);
     abc_cn = CV_MAT_CN(lines->type);
     if( (abc_depth != CV_32F && abc_depth != CV_64F) || (abc_cn != 1 && abc_cn != 3) )
-        CV_ERROR( CV_StsUnsupportedFormat, "The format of the matrix of lines is unsupported" );
+        CV_Error( CV_StsUnsupportedFormat, "The format of the matrix of lines is unsupported" );
 
     if( lines->rows > lines->cols )
     {
@@ -727,16 +706,16 @@ cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
     else
     {
         if( (lines->rows > 1 && abc_cn > 1) || (lines->rows == 1 && abc_cn == 1) )
-            CV_ERROR( CV_StsBadSize, "The lines matrix does not have a proper layout (3xn or nx3)" );
+            CV_Error( CV_StsBadSize, "The lines matrix does not have a proper layout (3xn or nx3)" );
         abc_dims = abc_cn * lines->rows;
         abc_count = lines->cols;
     }
 
     if( abc_dims != 3 )
-        CV_ERROR( CV_StsOutOfRange, "The lines matrix does not have a proper layout (3xn or nx3)" );
+        CV_Error( CV_StsOutOfRange, "The lines matrix does not have a proper layout (3xn or nx3)" );
 
     if( abc_count != count )
-        CV_ERROR( CV_StsUnmatchedSizes, "The numbers of points and lines are different" );
+        CV_Error( CV_StsUnmatchedSizes, "The numbers of points and lines are different" );
 
     elem_size = CV_ELEM_SIZE(depth);
     abc_elem_size = CV_ELEM_SIZE(abc_depth);
@@ -763,7 +742,7 @@ cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
         abc_stride = lines->rows == 1 ? 3*abc_elem_size : lines->step;
     }
 
-    CV_CALL( cvConvert( fmatrix, &F ));
+    cvConvert( fmatrix, &F );
     if( pointImageID == 2 )
         cvTranspose( &F, &F );
 
@@ -819,44 +798,36 @@ cvComputeCorrespondEpilines( const CvMat* points, int pointImageID,
         bp += abc_stride;
         cp += abc_stride;
     }
-
-    __END__;
 }
 
 
-CV_IMPL void
-cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
+CV_IMPL void cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
 {
-    CvMat* temp = 0;
-    CvMat* denom = 0;
-
-    CV_FUNCNAME( "cvConvertPointsHomogeneous" );
-
-    __BEGIN__;
+    Ptr<CvMat> temp, denom;
 
     int i, s_count, s_dims, d_count, d_dims;
     CvMat _src, _dst, _ones;
     CvMat* ones = 0;
 
     if( !CV_IS_MAT(src) )
-        CV_ERROR( !src ? CV_StsNullPtr : CV_StsBadArg,
+        CV_Error( !src ? CV_StsNullPtr : CV_StsBadArg,
         "The input parameter is not a valid matrix" );
 
     if( !CV_IS_MAT(dst) )
-        CV_ERROR( !dst ? CV_StsNullPtr : CV_StsBadArg,
+        CV_Error( !dst ? CV_StsNullPtr : CV_StsBadArg,
         "The output parameter is not a valid matrix" );
 
     if( src == dst || src->data.ptr == dst->data.ptr )
     {
         if( src != dst && (!CV_ARE_TYPES_EQ(src, dst) || !CV_ARE_SIZES_EQ(src,dst)) )
-            CV_ERROR( CV_StsBadArg, "Invalid inplace operation" );
-        EXIT;
+            CV_Error( CV_StsBadArg, "Invalid inplace operation" );
+        return;
     }
 
     if( src->rows > src->cols )
     {
         if( !((src->cols > 1) ^ (CV_MAT_CN(src->type) > 1)) )
-            CV_ERROR( CV_StsBadSize, "Either the number of channels or columns or rows must be =1" );
+            CV_Error( CV_StsBadSize, "Either the number of channels or columns or rows must be =1" );
 
         s_dims = CV_MAT_CN(src->type)*src->cols;
         s_count = src->rows;
@@ -864,7 +835,7 @@ cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
     else
     {
         if( !((src->rows > 1) ^ (CV_MAT_CN(src->type) > 1)) )
-            CV_ERROR( CV_StsBadSize, "Either the number of channels or columns or rows must be =1" );
+            CV_Error( CV_StsBadSize, "Either the number of channels or columns or rows must be =1" );
 
         s_dims = CV_MAT_CN(src->type)*src->rows;
         s_count = src->cols;
@@ -876,7 +847,7 @@ cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
     if( dst->rows > dst->cols )
     {
         if( !((dst->cols > 1) ^ (CV_MAT_CN(dst->type) > 1)) )
-            CV_ERROR( CV_StsBadSize,
+            CV_Error( CV_StsBadSize,
             "Either the number of channels or columns or rows in the input matrix must be =1" );
 
         d_dims = CV_MAT_CN(dst->type)*dst->cols;
@@ -885,7 +856,7 @@ cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
     else
     {
         if( !((dst->rows > 1) ^ (CV_MAT_CN(dst->type) > 1)) )
-            CV_ERROR( CV_StsBadSize,
+            CV_Error( CV_StsBadSize,
             "Either the number of channels or columns or rows in the output matrix must be =1" );
 
         d_dims = CV_MAT_CN(dst->type)*dst->rows;
@@ -896,18 +867,18 @@ cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
         dst = cvReshape( dst, &_dst, 1, d_count );
 
     if( s_count != d_count )
-        CV_ERROR( CV_StsUnmatchedSizes, "Both matrices must have the same number of points" );
+        CV_Error( CV_StsUnmatchedSizes, "Both matrices must have the same number of points" );
 
     if( CV_MAT_DEPTH(src->type) < CV_32F || CV_MAT_DEPTH(dst->type) < CV_32F )
-        CV_ERROR( CV_StsUnsupportedFormat,
+        CV_Error( CV_StsUnsupportedFormat,
         "Both matrices must be floating-point (single or double precision)" );
 
     if( s_dims < 2 || s_dims > 4 || d_dims < 2 || d_dims > 4 )
-        CV_ERROR( CV_StsOutOfRange,
+        CV_Error( CV_StsOutOfRange,
         "Both input and output point dimensionality must be 2, 3 or 4" );
 
     if( s_dims < d_dims - 1 || s_dims > d_dims + 1 )
-        CV_ERROR( CV_StsUnmatchedSizes,
+        CV_Error( CV_StsUnmatchedSizes,
         "The dimensionalities of input and output point sets differ too much" );
 
     if( s_dims == d_dims - 1 )
@@ -937,7 +908,7 @@ cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
         {
             if( !CV_ARE_TYPES_EQ( src, dst ))
             {
-                CV_CALL( temp = cvCreateMat( src->rows, src->cols, dst->type ));
+                temp = cvCreateMat( src->rows, src->cols, dst->type );
                 cvConvert( src, temp );
                 src = temp;
             }
@@ -953,7 +924,7 @@ cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
 
         if( !CV_ARE_TYPES_EQ( src, dst ))
         {
-            CV_CALL( temp = cvCreateMat( src->rows, src->cols, dst->type ));
+            temp = cvCreateMat( src->rows, src->cols, dst->type );
             cvConvert( src, temp );
             src = temp;
         }
@@ -970,7 +941,7 @@ cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
         else
             d_stride = dst->step / elem_size, d_plane_stride = 1;
 
-        CV_CALL( denom = cvCreateMat( 1, d_count, dst->type ));
+        denom = cvCreateMat( 1, d_count, dst->type );
 
         if( CV_MAT_DEPTH(dst->type) == CV_32F )
         {
@@ -1065,11 +1036,6 @@ cvConvertPointsHomogeneous( const CvMat* src, CvMat* dst )
                 }
         }
     }
-
-    __END__;
-
-    cvReleaseMat( &denom );
-    cvReleaseMat( &temp );
 }
 
 namespace cv
@@ -1088,13 +1054,13 @@ static Mat _findHomography( const Mat& points1, const Mat& points2,
     
     Mat H(3, 3, CV_64F);
     CvMat _pt1 = Mat(points1), _pt2 = Mat(points2);
-    CvMat _H = H, _mask, *pmask = 0;
+    CvMat matH = H, _mask, *pmask = 0;
     if( mask )
     {
         mask->resize(points1.cols*points1.rows*points1.channels()/2);
         pmask = &(_mask = cvMat(1, (int)mask->size(), CV_8U, (void*)&(*mask)[0]));
     }
-    bool ok = cvFindHomography( &_pt1, &_pt2, &_H, method, ransacReprojThreshold, pmask ) > 0;
+    bool ok = cvFindHomography( &_pt1, &_pt2, &matH, method, ransacReprojThreshold, pmask ) > 0;
     if( !ok )
         H = Scalar(0);
     return H;
@@ -1113,13 +1079,13 @@ static Mat _findFundamentalMat( const Mat& points1, const Mat& points2,
     
     Mat F(3, 3, CV_64F);
     CvMat _pt1 = Mat(points1), _pt2 = Mat(points2);
-    CvMat _F = F, _mask, *pmask = 0;
+    CvMat matF = F, _mask, *pmask = 0;
     if( mask )
     {
         mask->resize(points1.cols*points1.rows*points1.channels()/2);
         pmask = &(_mask = cvMat(1, (int)mask->size(), CV_8U, (void*)&(*mask)[0]));
     }
-    int n = cvFindFundamentalMat( &_pt1, &_pt2, &_F, method, param1, param2, pmask );
+    int n = cvFindFundamentalMat( &_pt1, &_pt2, &matF, method, param1, param2, pmask );
     if( n <= 0 )
         F = Scalar(0);
     return F;
@@ -1163,8 +1129,8 @@ void cv::computeCorrespondEpilines( const Mat& points, int whichImage,
                points.cols*points.channels() == 2));
     
     lines.resize(points.cols*points.rows*points.channels()/2);
-    CvMat _points = points, _lines = Mat(lines), _F = F;
-    cvComputeCorrespondEpilines(&_points, whichImage, &_F, &_lines);
+    CvMat _points = points, _lines = Mat(lines), matF = F;
+    cvComputeCorrespondEpilines(&_points, whichImage, &matF, &_lines);
 }
 
 void cv::convertPointsHomogeneous( const Mat& src, vector<Point3f>& dst )