Я вызываю функцию python из c ++ с помощью pybind 11. Функция python возвращает массив numpy, я хочу проанализировать данные в массив numpy в c ++
//the code for testing
#include <pybind11/embed.h> // everything needed for embedding
#include <pybind11/pybind11.h>
#include <pybind11/numpy.h>
int main()
{
py::scoped_interpreter guard{};
py::print("test python interpreter");
auto sys = py::module::import("sys");
sys.attr("path").attr("append")(
"<path for python module>");
auto hdf5 = py::module::import("reader_hdf5");
auto rdata = hdf5.attr("load_next_chunk")(0, 1);
// how to access the data from the return value ?
py::array_t<int16_t> array(331776);
array = rdata.cast<py::array_t<int16_t>>();
}
Здесь есть ошибка для кода:
terminate called after throwing an instance of 'pybind11::error_already_set'
what(): TypeError: int() argument must be a string, a bytes-like object or a number, not 'NoneType'