mirror of
https://github.com/opencv/opencv.git
synced 2026-07-30 15:53:03 +04:00
Merge pull request #27821 from savuor:rv/fix_nan_depth_scale
Fixed wrong NaN handling when scaling depth for OdometryFrame #27821 ### 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
4159c0ad98
commit
cdea2c3f76
@@ -47,14 +47,26 @@ static UMat prepareScaledDepth(OdometryFrame& frame)
|
||||
UMat depth;
|
||||
frame.getDepth(depth);
|
||||
CV_Assert(!depth.empty());
|
||||
bool isFloat = (depth.type() == CV_32FC1 || depth.type() == CV_64FC1);
|
||||
|
||||
// Odometry works well with depth values in range [0, 10)
|
||||
// If it's bigger, let's scale it down by 5000, a typical depth factor
|
||||
double maxv;
|
||||
cv::minMaxLoc(depth, nullptr, &maxv);
|
||||
UMat depthFlt;
|
||||
depth.convertTo(depthFlt, CV_32FC1, maxv > 10 ? (1.f / 5000.f) : 1.f);
|
||||
patchNaNs(depthFlt, 0);
|
||||
if (isFloat)
|
||||
{
|
||||
depth.convertTo(depthFlt, CV_32FC1);
|
||||
patchNaNs(depthFlt, 0);
|
||||
}
|
||||
|
||||
double maxv;
|
||||
cv::minMaxLoc(isFloat ? depthFlt : depth, nullptr, &maxv);
|
||||
|
||||
if (!isFloat || maxv > 10)
|
||||
{
|
||||
depth.convertTo(depthFlt, CV_32FC1, maxv > 10 ? (1.f / 5000.f) : 1.f);
|
||||
patchNaNs(depthFlt, 0);
|
||||
}
|
||||
|
||||
frame.impl->scaledDepth = depthFlt;
|
||||
|
||||
return depthFlt;
|
||||
|
||||
Reference in New Issue
Block a user