From ea6b44105280339ed969f094d3816b9de78ea12f Mon Sep 17 00:00:00 2001 From: Vadim Pisarevsky Date: Thu, 18 Nov 2010 22:03:20 +0000 Subject: [PATCH] extended cv::convertPointsHomogeneous to handle 4D input. corrected documentation --- doc/calib3d.tex | 9 ++++----- modules/calib3d/src/fundam.cpp | 6 +++--- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/doc/calib3d.tex b/doc/calib3d.tex index 16903d0..2988393 100644 --- a/doc/calib3d.tex +++ b/doc/calib3d.tex @@ -298,8 +298,7 @@ Convert points to/from homogeneous coordinates. \cvdefPy{ConvertPointsHomogeneous( src, dst ) -> None} -\cvdefCpp{void convertPointsHomogeneous( const Mat\& src, vector\& dst ); - +\cvdefCpp{void convertPointsHomogeneous( const Mat\& src, vector\& dst );\newline void convertPointsHomogeneous( const Mat\& src, vector\& dst );} \begin{description} @@ -307,8 +306,8 @@ void convertPointsHomogeneous( const Mat\& src, vector\& 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} diff --git a/modules/calib3d/src/fundam.cpp b/modules/calib3d/src/fundam.cpp index 785b0f4..cc37125 100644 --- a/modules/calib3d/src/fundam.cpp +++ b/modules/calib3d/src/fundam.cpp @@ -1134,10 +1134,10 @@ void cv::computeCorrespondEpilines( const Mat& points, int whichImage, void cv::convertPointsHomogeneous( const Mat& src, vector& 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); } -- 2.7.4