Smart recorder python bindings

Please provide complete information as applicable to your setup.

• Hardware Platform (Jetson / GPU) GPU
• DeepStream Version 7.0

Hi, I’ve been trying to build smart recorder’s bindings for python using the following guide link to obtain additional information about the recording, such as filename. But i’ve noticed that the utils.cpp shown in the example is different than mine, and when I try to compile I get some syntax errors.

Could that be due to the deepstream’s version? If so, what version has been used in the example?

/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/../3rdparty/pybind11/include/pybind11/pytypes.h:315:20: note: previous declaration of 'std::string pybind11::detail::error_string()' here
  315 | inline std::string error_string();
      |                    ^~~~~~~~~~~~
/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/src/utils.cpp: In function 'pybind11::arg pydeepstream::operator""_a(const char*, size_t)':
/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/src/utils.cpp:49:57: warning: unused parameter 'len' [-Wunused-parameter]
   49 |     pybind11::arg operator ""_a(const char *str, size_t len) {
      |                                                  ~~~~~~~^~~
/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/src/utils.cpp: At global scope:
/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/src/utils.cpp:52:37: error: expected ')' before ',' token
   52 |     py::enum_<NvDsSRContainerType>(m, "NvDsSRContainerType")
      |                                   ~ ^
      |                                     )
/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/src/utils.cpp:52:39: error: expected unqualified-id before string constant
   52 |     py::enum_<NvDsSRContainerType>(m, "NvDsSRContainerType")
      |                                       ^~~~~~~~~~~~~~~~~~~~~
/opt/nvidia/deepstream/deepstream/sources/deepstream_python_apps/bindings/src/utils.cpp:57:38: error: expected ')' before ',' token
   57 |     py::class_<NvDsSRRecordingInfo>(m, "NvDsSRRecordingInfo")
      |                                    ~ ^
      |                                      )

This patch is based on an internal branch, but is easily migrated to the github DS-7.0 branch, it’s just a c++ syntax issue

Please modify according to your local code

Refer to the following pseudo code

Utils.cpp


namespace pydeepstream {
    void bindutils(py::module &m) {
             py::enum_<NvDsSRContainerType>(m, "NvDsSRContainerType")
        .value("NVDSSR_CONTAINER_MP4", NVDSSR_CONTAINER_MP4)
        .value("NVDSSR_CONTAINER_MKV", NVDSSR_CONTAINER_MKV)
        .export_values();

py::class_<NvDsSRRecordingInfo>(m, "NvDsSRRecordingInfo")
        .def(py::init<>())
        .def_property("filename", STRING_CHAR_ARRAY(NvDsSRRecordingInfo, filename))
        .def_property("dirpath", STRING_CHAR_ARRAY(NvDsSRRecordingInfo, dirpath))
        .def_readwrite("duration", &NvDsSRRecordingInfo::duration)
        .def_readwrite("containerType", &NvDsSRRecordingInfo::containerType)
        .def_readwrite("width", &NvDsSRRecordingInfo::width)
        .def_readwrite("height", &NvDsSRRecordingInfo::height)
        .def_readwrite("containsVideo", &NvDsSRRecordingInfo::containsVideo)
        .def_readwrite("channels", &NvDsSRRecordingInfo::channels)
        .def_readwrite("samplingRate", &NvDsSRRecordingInfo::samplingRate)
        .def_readwrite("containsAudio", &NvDsSRRecordingInfo::containsAudio)
        .def("cast", [](size_t data) {
                return (NvDsSRRecordingInfo *) data;
                },
                py::return_value_policy::reference)
        .def("cast", [](void* data) {
                return (NvDsSRRecordingInfo *) data;
                },
                py::return_value_policy::reference);
struct SRUserContext {
    int sessionid;
    char name[32];
};
py::class_<SRUserContext>(m, "SRUserContext")
        .def(py::init<>())
        .def_readwrite("sessionid", &SRUserContext::sessionid)
        .def_property("name", STRING_CHAR_ARRAY(SRUserContext, name))
        .def("cast", [](size_t data) {
                return (SRUserContext *) data;
                },
                py::return_value_policy::reference)
        .def("cast", [](void* data) {
                return (SRUserContext *) data;
                },
                py::return_value_policy::reference);
   }

pyds.cpp

        bindopticalflowmeta(m);
        bindutils(m);
        bindcustom(m);

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.