Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement "get_nvds_LayerInfo_buffer" #17

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions bindings/docstrings/functionsdoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ namespace pydsdoc
{
namespace methodsDoc
{
constexpr const char* get_nvds_LayerInfo_buffer=R"pyds(
This function returns the buffer of an :class:`NvDsInferLayerInfo` in Numpy format with dtype numpy.byte and ndim=1.

:arg data: An object of type :class:`NvDsInferLayerInfo`

:returns: NumPy array containing the buffer of an :class:`NvDsInferLayerInfo` object)pyds";

constexpr const char* get_segmentation_masks=R"pyds(
This function returns the inferred masks in Numpy format in the height X width shape, these height and width are obtained from the :class:`NvDsInferSegmentationMeta`.

Expand Down
29 changes: 29 additions & 0 deletions bindings/src/bindfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,35 @@ namespace pydeepstream {
},
py::return_value_policy::reference);

m.def("get_nvds_LayerInfo_buffer",
[](void *data) {
auto *info = (NvDsInferLayerInfo *) data;
unsigned char element_size = 0;
switch (info->dataType) {
case FLOAT:
element_size = 4;
break;
case HALF:
element_size = 2;
break;
case INT32:
element_size = 4;
break;
case INT8:
element_size = 1;
break;
case INT64:
element_size = 8;
break;
}
auto dtype = py::dtype(py::format_descriptor<signed char>::format());
return py::array(dtype, {(info->inferDims).numElements * element_size},
{sizeof(signed char)},
info->buffer);
},
"data"_a,
pydsdoc::methodsDoc::get_nvds_LayerInfo_buffer);

m.def("get_segmentation_masks",
[](void *data) {
auto *META = (NvDsInferSegmentationMeta *) data;
Expand Down
6 changes: 6 additions & 0 deletions docs/PYTHON_API/Methods/methodsdoc.rst
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,12 @@ gst_element_send_nvevent_interval_update

.. autofunction:: pyds.gst_element_send_nvevent_interval_update

======================
get_nvds_LayerInfo_buffer
======================

.. autofunction:: pyds.get_nvds_LayerInfo_buffer

======================
get_segmentation_masks
======================
Expand Down