From 300075443b7e89fc28089df5dcd1b839b0a4be08 Mon Sep 17 00:00:00 2001 From: Naoto Kondo Date: Sat, 25 Apr 2020 07:18:46 +0900 Subject: [PATCH] get video array --- src/main.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index cf77de8..bf5dfed 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,7 +103,16 @@ PYBIND11_MODULE(NDIlib, m) { &NDIlib_video_frame_v2_t::frame_format_type) .def_readwrite("timecode", &NDIlib_video_frame_v2_t::timecode) .def_property( - "data", nullptr, + "data", + [](const NDIlib_video_frame_v2_t &self) { + auto buffer_info = + py::buffer_info(self.p_data, sizeof(uint8_t), + py::format_descriptor::format(), 3, + {self.yres, self.xres, 4}, + {sizeof(uint8_t) * self.xres * 4, + sizeof(uint8_t) * 4, sizeof(uint8_t)}); + return py::array(buffer_info); + }, [](NDIlib_video_frame_v2_t &self, const py::array_t &array) { auto info = array.request(); self.p_data = reinterpret_cast(info.ptr);