mirror of
https://github.com/opencv/opencv.git
synced 2026-07-29 23:33:05 +04:00
Merge pull request #23098 from savuor:nanMask
finiteMask() and doubles for patchNaNs() #23098 Related to #22826 Connected PR in extra: [#1037@extra](https://github.com/opencv/opencv_extra/pull/1037) ### TODOs: - [ ] Vectorize `finiteMask()` for 64FC3 and 64FC4 ### Changes This PR: * adds a new function `finiteMask()` * extends `patchNaNs()` by CV_64F support * moves `patchNaNs()` and `finiteMask()` to a separate file **NOTE:** now the function is called `finiteMask()` as discussed with the OpenCV core team ### Pull Request Readiness Checklist See details at https://github.com/opencv/opencv/wiki/How_to_contribute#making-a-good-pull-request - [x] I agree to contribute to the project under Apache 2 License. - [x] To the best of my knowledge, the proposed patch is not based on a code under GPL or another license that is incompatible with OpenCV - [x] The PR is proposed to the proper branch - [x] There is a reference to the original bug report and related work - [x] There is accuracy test, performance test and test data in opencv_extra repository, if applicable Patch to opencv_extra has the same branch name. - [x] The feature is well documented and sample code can be built with the project CMake
This commit is contained in:
committed by
GitHub
parent
34f34f6227
commit
53aad98a1a
@@ -16,11 +16,8 @@ void dilateFrame(Mat& image, Mat& depth)
|
||||
CV_Assert(depth.type() == CV_32FC1);
|
||||
CV_Assert(depth.size() == image.size());
|
||||
|
||||
Mat mask(image.size(), CV_8UC1, Scalar(255));
|
||||
for(int y = 0; y < depth.rows; y++)
|
||||
for(int x = 0; x < depth.cols; x++)
|
||||
if(cvIsNaN(depth.at<float>(y,x)) || depth.at<float>(y,x) > 10 || depth.at<float>(y,x) <= FLT_EPSILON)
|
||||
mask.at<uchar>(y,x) = 0;
|
||||
Mat mask;
|
||||
inRange(depth, FLT_EPSILON, 10, mask);
|
||||
|
||||
image.setTo(255, ~mask);
|
||||
Mat minImage;
|
||||
@@ -726,7 +723,8 @@ TEST(RGBD_Odometry_WarpFrame, nansAreMasked)
|
||||
|
||||
ASSERT_EQ(0, rgbDiff);
|
||||
|
||||
Mat goodVals = (w.warpedDepth == w.warpedDepth);
|
||||
Mat goodVals;
|
||||
finiteMask(w.warpedDepth, goodVals);
|
||||
|
||||
double l2diff = cv::norm(w.dstDepth, w.warpedDepth, NORM_L2, goodVals);
|
||||
double lidiff = cv::norm(w.dstDepth, w.warpedDepth, NORM_INF, goodVals);
|
||||
|
||||
Reference in New Issue
Block a user