extended cv::convertPointsHomogeneous to handle 4D input. corrected documentation
authorVadim Pisarevsky <no@email>
Thu, 18 Nov 2010 22:03:20 +0000 (22:03 +0000)
committerVadim Pisarevsky <no@email>
Thu, 18 Nov 2010 22:03:20 +0000 (22:03 +0000)
doc/calib3d.tex
modules/calib3d/src/fundam.cpp

index 16903d0..2988393 100644 (file)
@@ -298,8 +298,7 @@ Convert points to/from homogeneous coordinates.
 
 \cvdefPy{ConvertPointsHomogeneous( src, dst ) -> None}
 
-\cvdefCpp{void convertPointsHomogeneous( const Mat\& src, vector<Point3f>\& dst );
-
+\cvdefCpp{void convertPointsHomogeneous( const Mat\& src, vector<Point3f>\& dst );\newline
 void convertPointsHomogeneous( const Mat\& src, vector<Point2f>\& dst );}
 
 \begin{description}
@@ -307,8 +306,8 @@ void convertPointsHomogeneous( const Mat\& src, vector<Point2f>\& dst );}
 \cvarg{src}{The input point array, \texttt{2xN, Nx2, 3xN, Nx3, 4xN or Nx4 (where \texttt{N} is the number of points)}. Multi-channel \texttt{1xN} or \texttt{Nx1} array is also acceptable}
 \cvarg{dst}{The output point array, must contain the same number of points as the input; The dimensionality must be the same, 1 less or 1 more than the input, and also within 2 to 4}
 \else
-\cvarg{src}{The input array or vector of 2D or 3D points}
-\cvarg{dst}{The output vector of 3D or 2D points, respectively}
+\cvarg{src}{The input array or vector of 2D, 3D or 4D points}
+\cvarg{dst}{The output vector of 2D or 2D points}
 \fi
 \end{description}
 
@@ -752,7 +751,7 @@ Mat findHomography( const Mat\& srcPoints, const Mat\& dstPoints,\par
 \cvarg{CV\_LMEDS}{Least-Median robust method}
 \end{description}}
 \cvarg{ransacReprojThreshold}{The maximum allowed reprojection error to treat a point pair as an inlier (used in the RANSAC method only). That is, if
-\[\|\texttt{dstPoints}_i - \texttt{convertPointHomogeneous}(\texttt{H} \texttt{srcPoints}_i)\| > \texttt{ransacReprojThreshold}\]
+\[\|\texttt{dstPoints}_i - \texttt{convertPointsHomogeneous}(\texttt{H} \texttt{srcPoints}_i)\| > \texttt{ransacReprojThreshold}\]
 then the point $i$ is considered an outlier. If \texttt{srcPoints} and \texttt{dstPoints} are measured in pixels, it usually makes sense to set this parameter somewhere in the range 1 to 10.}
 \cvarg{status}{The optional output mask set by a robust method (\texttt{CV\_RANSAC} or \texttt{CV\_LMEDS}). \emph{Note that the input mask values are ignored.}}
 \end{description}
index 785b0f4..cc37125 100644 (file)
@@ -1134,10 +1134,10 @@ void cv::computeCorrespondEpilines( const Mat& points, int whichImage,
 
 void cv::convertPointsHomogeneous( const Mat& src, vector<Point3f>& dst )
 {
-    CV_Assert(src.checkVector(2) >= 0 &&
-              (src.depth() == CV_32F || src.depth() == CV_32S));
+    int srccn = src.checkVector(2) >= 0 ? 2 : src.checkVector(4) >= 0 ? 4 : -1;
+    CV_Assert( srccn > 0 && (src.depth() == CV_32F || src.depth() == CV_32S));
     
-    dst.resize(src.cols*src.rows*src.channels()/2);
+    dst.resize(src.cols*src.rows*src.channels()/srccn);
     CvMat _src = src, _dst = Mat(dst);
     cvConvertPointsHomogeneous(&_src, &_dst);
 }