mirror of
https://github.com/opencv/opencv_contrib.git
synced 2025-10-19 02:16:34 +08:00
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
This commit is contained in:
@@ -312,16 +312,17 @@ namespace rgbd
|
|||||||
depthTo3d(InputArray depth, InputArray K, OutputArray points3d, InputArray mask = noArray());
|
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
|
/** 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
|
* 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
|
* @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)
|
* (as done with the Microsoft Kinect), it is assumed in meters)
|
||||||
* @param depth the desired output depth (floats or double)
|
* @param depth the desired output depth (floats or double)
|
||||||
* @param out The rescaled float depth image
|
* @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
|
CV_EXPORTS_W
|
||||||
void
|
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
|
/** Object that can compute planes in an image
|
||||||
*/
|
*/
|
||||||
|
@@ -13,6 +13,7 @@
|
|||||||
#include "kinfu.hpp"
|
#include "kinfu.hpp"
|
||||||
|
|
||||||
namespace cv {
|
namespace cv {
|
||||||
|
|
||||||
namespace dynafu {
|
namespace dynafu {
|
||||||
|
|
||||||
/** @brief DynamicFusion implementation
|
/** @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.
|
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
|
class CV_EXPORTS_W DynaFu
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
|
@@ -22,7 +22,7 @@ namespace rgbd
|
|||||||
* @param out_out The rescaled float depth image
|
* @param out_out The rescaled float depth image
|
||||||
*/
|
*/
|
||||||
void
|
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::Mat in = in_in.getMat();
|
||||||
CV_Assert(in.type() == CV_64FC1 || in.type() == CV_32FC1 || in.type() == CV_16UC1 || in.type() == CV_16SC1);
|
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();
|
cv::Mat out = out_out.getMat();
|
||||||
if (in_depth == CV_16U)
|
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 ?
|
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$
|
out.setTo(std::numeric_limits<float>::quiet_NaN(), valid_mask); //set a$
|
||||||
}
|
}
|
||||||
if (in_depth == CV_16S)
|
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 ?
|
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$
|
out.setTo(std::numeric_limits<float>::quiet_NaN(), valid_mask); //set a$
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user