Merge pull request #2751 from akashsharma02:master

Add depth_factor argument in rescaleDepth and typedef dynafu::Params for backwards compatibility

* Add depth factor argument (default = 1000.0) to rescaleDepth to
potentially support TUM type datasets

* typedef dynafu::Params as kinfu::Params for compatibility
pull/2764/head
Akash Sharma 4 years ago committed by GitHub
parent 478cc124f5
commit f63965759d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 5
      modules/rgbd/include/opencv2/rgbd/depth.hpp
  2. 6
      modules/rgbd/include/opencv2/rgbd/dynafu.hpp
  3. 6
      modules/rgbd/src/utils.cpp

@ -312,16 +312,17 @@ namespace rgbd
depthTo3d(InputArray depth, InputArray K, OutputArray points3d, InputArray mask = noArray());
/** If the input image is of type CV_16UC1 (like the Kinect one), the image is converted to floats, divided
* by 1000 to get a depth in meters, and the values 0 are converted to std::numeric_limits<float>::quiet_NaN()
* by depth_factor to get a depth in meters, and the values 0 are converted to std::numeric_limits<float>::quiet_NaN()
* Otherwise, the image is simply converted to floats
* @param in the depth image (if given as short int CV_U, it is assumed to be the depth in millimeters
* (as done with the Microsoft Kinect), it is assumed in meters)
* @param depth the desired output depth (floats or double)
* @param out The rescaled float depth image
* @param depth_factor (optional) factor by which depth is converted to distance (by default = 1000.0 for Kinect sensor)
*/
CV_EXPORTS_W
void
rescaleDepth(InputArray in, int depth, OutputArray out);
rescaleDepth(InputArray in, int depth, OutputArray out, double depth_factor = 1000.0);
/** Object that can compute planes in an image
*/

@ -13,6 +13,7 @@
#include "kinfu.hpp"
namespace cv {
namespace dynafu {
/** @brief DynamicFusion implementation
@ -37,6 +38,11 @@ namespace dynafu {
That's why you need to set the OPENCV_ENABLE_NONFREE option in CMake to use DynamicFusion.
*/
/** Backwards compatibility for old versions */
using Params = kinfu::Params;
class CV_EXPORTS_W DynaFu
{
public:

@ -22,7 +22,7 @@ namespace rgbd
* @param out_out The rescaled float depth image
*/
void
rescaleDepth(InputArray in_in, int depth, OutputArray out_out)
rescaleDepth(InputArray in_in, int depth, OutputArray out_out, double depth_factor)
{
cv::Mat in = in_in.getMat();
CV_Assert(in.type() == CV_64FC1 || in.type() == CV_32FC1 || in.type() == CV_16UC1 || in.type() == CV_16SC1);
@ -34,13 +34,13 @@ namespace rgbd
cv::Mat out = out_out.getMat();
if (in_depth == CV_16U)
{
in.convertTo(out, depth, 1 / 1000.0); //convert to float so that it is in meters
in.convertTo(out, depth, 1 / depth_factor); //convert to float so that it is in meters
cv::Mat valid_mask = in == std::numeric_limits<ushort>::min(); // Should we do std::numeric_limits<ushort>::max() too ?
out.setTo(std::numeric_limits<float>::quiet_NaN(), valid_mask); //set a$
}
if (in_depth == CV_16S)
{
in.convertTo(out, depth, 1 / 1000.0); //convert to float so tha$
in.convertTo(out, depth, 1 / depth_factor); //convert to float so tha$
cv::Mat valid_mask = (in == std::numeric_limits<short>::min()) | (in == std::numeric_limits<short>::max()); // Should we do std::numeric_limits<ushort>::max() too ?
out.setTo(std::numeric_limits<float>::quiet_NaN(), valid_mask); //set a$
}

Loading…
Cancel
Save