diff --git a/modules/rgbd/src/dynafu_tsdf.cpp b/modules/rgbd/src/dynafu_tsdf.cpp index 8aff8fec20..34b1a507a2 100644 --- a/modules/rgbd/src/dynafu_tsdf.cpp +++ b/modules/rgbd/src/dynafu_tsdf.cpp @@ -127,7 +127,7 @@ void TSDFVolumeCPU::reset() volume.forEach([](VecT& vv, const int* /* position */) { Voxel& v = reinterpret_cast(vv); - v.v = 0; v.weight = 0; + v.v = 0; v.weight = 0; v.n = 0; }); } diff --git a/modules/rgbd/test/test_dynafu.cpp b/modules/rgbd/test/test_dynafu.cpp index 1ee102e6e0..5f242f8199 100644 --- a/modules/rgbd/test/test_dynafu.cpp +++ b/modules/rgbd/test/test_dynafu.cpp @@ -6,9 +6,21 @@ #include "test_precomp.hpp" -#ifdef HAVE_OPENGL namespace opencv_test { namespace { +// integrate() before any warp field nodes exist used to crash with uninitialized Voxel::n +TEST(DynamicFusion, firstFrameDoesNotCrashBeforeWarpNodesExist) +{ + Ptr params = kinfu::Params::coarseParams(); + + Mat depth(params->frameSize, CV_16U, Scalar(static_cast(1.5f * params->depthFactor))); + + Ptr df = dynafu::DynaFu::create(params); + ASSERT_NO_THROW(df->update(depth)); +} + +#ifdef HAVE_OPENGL + static std::vector readDepth(std::string fileList) { std::vector v; @@ -124,6 +136,6 @@ TEST(DynamicFusion, DISABLED) CV_UNUSED(flyTest); } -}} // namespace +#endif // HAVE_OPENGL -#endif +}} // namespace