As written in pybindissue, when passing None to C++ function, numpy actually passes NaN. This leads to access violation as (const float*)depth_buf.ptr in void set_image(int frame_idx, pybind11::array_t<float> img, pybind11::array_t<float> depth_img, float depth_scale) is not nullptr, while being empty.
Other solution would be to make void set_image(int frame_idx, pybind11::array_t<float> img, pybind11::array_t<float> depth_img, float depth_scale) argument depth_img type std::optional<pybind11::array_t<float>>. This would lead to no code duplication, however requires C++17.
As written in
pybind
issue, when passingNone
to C++ function,numpy
actually passesNaN
. This leads to access violation as(const float*)depth_buf.ptr
invoid set_image(int frame_idx, pybind11::array_t<float> img, pybind11::array_t<float> depth_img, float depth_scale)
is notnullptr
, while being empty. Other solution would be to makevoid set_image(int frame_idx, pybind11::array_t<float> img, pybind11::array_t<float> depth_img, float depth_scale)
argumentdepth_img
typestd::optional<pybind11::array_t<float>>
. This would lead to no code duplication, however requires C++17.