diff --git a/modules/3d/include/opencv2/3d.hpp b/modules/3d/include/opencv2/3d.hpp index 1fd0092ae2..a8afcf1b6d 100644 --- a/modules/3d/include/opencv2/3d.hpp +++ b/modules/3d/include/opencv2/3d.hpp @@ -2127,7 +2127,8 @@ CV_EXPORTS_W int decomposeHomographyMat(InputArray H, @param beforePoints Vector of (rectified) visible reference points before the homography is applied @param afterPoints Vector of (rectified) visible reference points after the homography is applied @param possibleSolutions Vector of int indices representing the viable solution set after filtering -@param pointsMask optional Mat/Vector of 8u type representing the mask for the inliers as given by the #findHomography function +@param pointsMask optional Mat/Vector of CV_8U, CV_8S or CV_Bool type representing the mask for the inliers +as given by the #findHomography function This function is intended to filter the output of the #decomposeHomographyMat based on additional information as described in @cite Malis2007 . The summary of the method: the #decomposeHomographyMat function diff --git a/modules/3d/include/opencv2/3d/depth.hpp b/modules/3d/include/opencv2/3d/depth.hpp index c05d014e72..2a40c3df93 100644 --- a/modules/3d/include/opencv2/3d/depth.hpp +++ b/modules/3d/include/opencv2/3d/depth.hpp @@ -132,7 +132,7 @@ CV_EXPORTS_W void rescaleDepth(InputArray in, int type, OutputArray out, double * This function can be used to visualize the results of the Odometry algorithm. * @param depth Depth data, should be 1-channel CV_16U, CV_16S, CV_32F or CV_64F * @param image RGB image (optional), should be 1-, 3- or 4-channel CV_8U - * @param mask Mask of used pixels (optional), should be CV_8UC1 + * @param mask Mask of used pixels (optional), should be CV_8UC1, CV_8SC1 or CV_BoolC1 * @param Rt Rotation+translation matrix (3x4 or 4x4) to be applied to depth points * @param cameraMatrix Camera intrinsics matrix (3x3) * @param warpedDepth The warped depth data (optional) diff --git a/modules/3d/src/homography_decomp.cpp b/modules/3d/src/homography_decomp.cpp index e9153a686d..36b697e394 100644 --- a/modules/3d/src/homography_decomp.cpp +++ b/modules/3d/src/homography_decomp.cpp @@ -506,7 +506,7 @@ void filterHomographyDecompByVisibleRefpoints(InputArrayOfArrays _rotations, InputArray _pointsMask) { CV_Assert(_beforeRectifiedPoints.type() == CV_32FC2 && _afterRectifiedPoints.type() == CV_32FC2); - CV_Assert(_pointsMask.empty() || _pointsMask.type() == CV_8U); + CV_Assert(_pointsMask.empty() || _pointsMask.type() == CV_8U || _pointsMask.type() == CV_8S || _pointsMask.type() == CV_Bool); Mat beforeRectifiedPoints = _beforeRectifiedPoints.getMat(); Mat afterRectifiedPoints = _afterRectifiedPoints.getMat(); diff --git a/modules/3d/src/levmarq.cpp b/modules/3d/src/levmarq.cpp index f7c147ed6e..a92f273dab 100644 --- a/modules/3d/src/levmarq.cpp +++ b/modules/3d/src/levmarq.cpp @@ -466,7 +466,7 @@ struct LevMarqDenseLinearBackend : public detail::LevMarqBackend if (!mask_.empty()) { - CV_Assert(mask_.depth() == CV_8U); + CV_Assert(mask_.depth() == CV_8U || mask_.depth() == CV_8S || mask_.depth() == CV_Bool); CV_Assert(mask_.size() == currentX_.size()); int maskSize = mask_.size().area(); this->mask.create(maskSize, 1); diff --git a/modules/3d/src/ptsetreg.cpp b/modules/3d/src/ptsetreg.cpp index b600f8b476..3be9fa76e0 100644 --- a/modules/3d/src/ptsetreg.cpp +++ b/modules/3d/src/ptsetreg.cpp @@ -86,7 +86,7 @@ public: cb->computeError( m1, m2, model, err ); mask.create(err.size(), CV_8U); - CV_Assert( err.isContinuous() && err.type() == CV_32F && mask.isContinuous() && mask.type() == CV_8U); + CV_Assert( err.isContinuous() && err.type() == CV_32F && mask.isContinuous() && (mask.type() == CV_8S || mask.type() == CV_8U || mask.type() == CV_Bool)); const float* errptr = err.ptr(); uchar* maskptr = mask.ptr(); float t = (float)(thresh*thresh); diff --git a/modules/3d/src/rendering.cpp b/modules/3d/src/rendering.cpp index 18c81ff20a..3c628b129a 100644 --- a/modules/3d/src/rendering.cpp +++ b/modules/3d/src/rendering.cpp @@ -118,7 +118,7 @@ static void drawTriangle(Vec4f verts[3], Vec3f colors[3], Mat& depthBuf, Mat& co static void linearizeDepth(const Mat& inbuf, const Mat& validMask, Mat outbuf, double zFar, double zNear) { CV_Assert(inbuf.type() == CV_32FC1); - CV_Assert(validMask.type() == CV_8UC1); + CV_Assert(validMask.type() == CV_8UC1 || validMask.type() == CV_8SC1 || validMask.type() == CV_BoolC1); CV_Assert(outbuf.type() == CV_32FC1); CV_Assert(outbuf.size() == inbuf.size()); diff --git a/modules/3d/src/rgbd/depth_to_3d.hpp b/modules/3d/src/rgbd/depth_to_3d.hpp index 463646eceb..26d47ea9f8 100644 --- a/modules/3d/src/rgbd/depth_to_3d.hpp +++ b/modules/3d/src/rgbd/depth_to_3d.hpp @@ -52,7 +52,7 @@ size_t convertDepthToFloat(const cv::Mat& depth, const cv::Mat& mask, float scal cv::Mat_ uchar_mask = mask; - if (mask.depth() != CV_8U) + if ((mask.depth() != CV_8S) && (mask.depth() != CV_8U) && (mask.depth() != CV_Bool)) mask.convertTo(uchar_mask, CV_8U); u_mat = cv::Mat_(depth_size.area(), 1); diff --git a/modules/3d/src/rgbd/odometry.cpp b/modules/3d/src/rgbd/odometry.cpp index c323efc5f4..018227f08f 100644 --- a/modules/3d/src/rgbd/odometry.cpp +++ b/modules/3d/src/rgbd/odometry.cpp @@ -358,7 +358,7 @@ void warpFrame(InputArray depth, InputArray image, InputArray mask, Mat_ maskMat; if (!mask.empty()) { - CV_Assert(mask.type() == CV_8UC1); + CV_Assert(mask.type() == CV_8UC1 || mask.type() == CV_8SC1 || mask.type() == CV_BoolC1); CV_Assert(mask.size() == sz); maskMat = mask.getMat(); } diff --git a/modules/3d/src/rgbd/odometry_functions.cpp b/modules/3d/src/rgbd/odometry_functions.cpp index d210e0a9ac..66fc945a17 100644 --- a/modules/3d/src/rgbd/odometry_functions.cpp +++ b/modules/3d/src/rgbd/odometry_functions.cpp @@ -273,7 +273,7 @@ static void prepareRGBFrameBase(OdometryFrame& frame, OdometrySettings settings) } else { - CV_Assert(mask.type() == CV_8UC1); + CV_Assert(mask.type() == CV_8UC1 || mask.type() == CV_8SC1 || mask.type() == CV_BoolC1); CV_Assert(mask.size() == grayImage.size()); cv::bitwise_and(mask, depthMask, frame.impl->mask); } @@ -358,7 +358,7 @@ static void prepareICPFrameBase(OdometryFrame& frame, OdometrySettings settings) } else { - CV_Assert(mask.type() == CV_8UC1); + CV_Assert(mask.type() == CV_8UC1 || mask.type() == CV_8SC1 || mask.type() == CV_BoolC1); CV_Assert(mask.size() == scaledDepth.size()); cv::bitwise_and(mask, depthMask, frame.impl->mask); } diff --git a/modules/3d/test/test_filter_homography_decomp.cpp b/modules/3d/test/test_filter_homography_decomp.cpp index 633d43ad8e..8fb0572376 100644 --- a/modules/3d/test/test_filter_homography_decomp.cpp +++ b/modules/3d/test/test_filter_homography_decomp.cpp @@ -556,7 +556,7 @@ private: _rotations.swap(rotations); _normals.swap(normals); - _mask = Mat(514, 1, CV_8U, maskArray).clone(); + _mask = Mat(514, 1, CV_8S, maskArray).clone(); } bool isValidResult(const vector& solutions)