Skip to content
Merged
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
3 changes: 2 additions & 1 deletion bindings/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ add_library(pyds SHARED src/pyds.cpp src/utils.cpp src/bindanalyticsmeta.cpp
src/bindnvdsmeta.cpp src/bindnvosd.cpp src/bindopticalflow.cpp
src/bindschema.cpp src/bindtrackermeta.cpp src/custom_binding/bindcustom.cpp
src/bind_reidembed_metadata.cpp src/bind_embed_metadata.cpp
src/bind_label.cpp src/bind_tracker_status_metadata.cpp src/bind_instance_segmentation.cpp)
src/bind_label.cpp src/bind_tracker_status_metadata.cpp
src/bind_instance_segmentation.cpp src/bind_occupancy.cpp)

set_target_properties(pyds PROPERTIES PREFIX "")
set_target_properties(pyds PROPERTIES OUTPUT_NAME "pyds")
Expand Down
5 changes: 5 additions & 0 deletions bindings/docstrings/functionsdoc.h
Original file line number Diff line number Diff line change
Expand Up @@ -622,6 +622,11 @@ constexpr const char *alloc_instance_segmentation_struct = R"pyds(

:returns: Allocated :class:`InstanceSegmentationMetadata`)pyds";

constexpr const char *alloc_occupancy_struct = R"pyds(
Allocate an :class:`OccupancyMetadata`.

:returns: Allocated :class:`OccupancyMetadata`)pyds";

constexpr const char *alloc_reidembedding_struct = R"pyds(
Allocate an :class:`ReIDEmbeddingMetadata`.

Expand Down
36 changes: 36 additions & 0 deletions bindings/docstrings/occupancydoc.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* SPDX-FileCopyrightText: Copyright (c) 2021-2022 NVIDIA CORPORATION &
* AFFILIATES. All rights reserved. SPDX-License-Identifier: Apache-2.0
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

#pragma once

namespace pydsdoc
{
namespace occupancy
{
namespace OccupancyMetadata
{
constexpr const char *descr = R"pyds(
Holds occupancy information of the frame.
Available only when instance segmentation is enabled.
:ivar occupancy: *int*, occupancy value)pyds";

constexpr const char *cast
= R"pyds(cast given object/data to :class:`OccupancyMetadata`, call pyds.OccupancyMetadata.cast(data))pyds";
}
}
}

12 changes: 12 additions & 0 deletions bindings/include/bind/bind_occupancy.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#include "../../docstrings/functionsdoc.h"
#include "../../docstrings/occupancydoc.h"
#include "occupancy.h" // Include the actual C++ header file for OccupancyMetadata
#include "pyds.hpp"

namespace py = pybind11;

namespace pydeepstream
{
void bindoccupancy (
py::module &m);
}
26 changes: 26 additions & 0 deletions bindings/src/bind_occupancy.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#include "bind_occupancy.hpp"

namespace py = pybind11;

namespace pydeepstream
{

void
bindoccupancy (py::module &m)
{
/* OccupancyMetadata bindings to be used with NvDsFrameMeta */
py::class_<OccupancyMetadata> (
m, "OccupancyMetadata",
pydsdoc::occupancy::OccupancyMetadata::descr)
.def (py::init<> ())
.def_readwrite ("percent_occupancy", &OccupancyMetadata::percent_occupancy)
.def (
"cast",
[] (void *data) { return (OccupancyMetadata *)data; },
py::return_value_policy::reference,
pydsdoc::occupancy::OccupancyMetadata::cast);

m.attr ("NVDS_USER_META_OCCUPANCY")
= py::cast (NVDS_USER_META_OCCUPANCY);
}
}
3 changes: 2 additions & 1 deletion bindings/src/pyds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ AFFILIATES. All rights reserved.
#include "bindschema.hpp"
#include "bindtrackermeta.hpp"
#include "custom_binding/include/bindcustom.hpp"
#include "bind_occupancy.hpp"

/*#define NPY_NO_DEPRECATED_API NPY_1_7_API_VERSION

Expand Down Expand Up @@ -77,6 +78,6 @@ PYBIND11_MODULE (pyds, m)
bindlabel (m);
bindtrackerstatus (m);
bindinstancesegmentation (m);

bindoccupancy (m);
} // end PYBIND11_MODULE(pyds, m)
}