NVIDIA DeepStream SDK API Reference

9.2 Release
sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2018-2026 NVIDIA CORPORATION & AFFILIATES. All rights reserved.
3  * SPDX-License-Identifier: Apache-2.0
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at
8  *
9  * http://www.apache.org/licenses/LICENSE-2.0
10  *
11  * Unless required by applicable law or agreed to in writing, software
12  * distributed under the License is distributed on an "AS IS" BASIS,
13  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  * See the License for the specific language governing permissions and
15  * limitations under the License.
16  */
17 
18 #ifndef __NVDSINFER_DBSCANCLUSTERING_HPP__
19 #define __NVDSINFER_DBSCANCLUSTERING_HPP__
20 
21 #include <memory>
22 #include <vector>
23 //WINDOWS
24 #ifdef _WIN32
25 #include <Eigen/Dense>
26 #else
27 /* Ignore errors from open source headers. */
28 #pragma GCC diagnostic push
29 #pragma GCC diagnostic ignored "-Wunused-local-typedefs"
30 #if __GNUC__ >= 6
31 #pragma GCC diagnostic ignored "-Wmisleading-indentation"
32 #endif
33 #if __GNUC__ >= 7
34 #pragma GCC diagnostic ignored "-Wint-in-bool-context"
35 #endif
36 #include <Eigen/Dense>
37 #pragma GCC diagnostic pop
38 #endif
39 #include "EigenDefs.hpp"
40 
41 #include <nvdsinfer_dbscan.h>
42 
46 typedef struct
47 {
48  float x;
49  float y;
50  float width;
51  float height;
52 } BBox;
53 
54 typedef struct
55 {
65  uint32_t numMembers;
67 
69 
73 private:
74  typedef Eigen::Matrix<int32_t, Eigen::Dynamic, Eigen::Dynamic, Eigen::RowMajor> RowMatrixXi;
75 
77  ~NvDsInferDBScan();
78 
79  void clusterObjects(NvDsInferObjectDetectionInfo *detections, size_t &numDetections,
80  NvDsInferDBScanClusteringParams *params, bool hybridClustering = false);
81 
82  void re_allocate (size_t num_detections);
83 
84  void buildDistanceMatrix(const NvDsInferObjectDetectionInfo input[],
85  int32_t inputSize);
86 
87  void findNeighbors(int32_t boxIdx, int32_t inputSize, float eps);
88 
89  void joinNeighbors(int32_t boxDstIdx, int32_t boxSrcIdx);
90 
91  std::unique_ptr<MatrixXf> m_distanceMatrix;
92  std::unique_ptr<RowMatrixXi> m_neighborListMatrix;
93  std::unique_ptr<MatrixXb> m_neighborshipMatrix;
94  std::vector<uint32_t> m_neighborCounts;
95  std::vector<int32_t> m_labels;
96  std::vector<bool> m_visited;
97  size_t m_maxProposals;
98  std::vector <ClusteredObject> m_clusteredObjects;
99 
101  friend void NvDsInferDBScanDestroy(NvDsInferDBScanHandle handle);
104  NvDsInferObjectDetectionInfo *objects, size_t *numObjects);
107  NvDsInferObjectDetectionInfo *objects, size_t *numObjects);
108 };
109 
110 #endif
ClusteredObject::totalConfidence
float totalConfidence
Total confidence of the members of the cluster.
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:61
BBox::width
float width
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:50
NvDsInferDBScan::NvDsInferDBScanCluster
friend void NvDsInferDBScanCluster(NvDsInferDBScanHandle handle, NvDsInferDBScanClusteringParams *params, NvDsInferObjectDetectionInfo *objects, size_t *numObjects)
Clusters an array of objects in place using specified clustering parameters.
NvDsInferDBScan::NvDsInferDBScanClusterHybrid
friend void NvDsInferDBScanClusterHybrid(NvDsInferDBScanHandle handle, NvDsInferDBScanClusteringParams *params, NvDsInferObjectDetectionInfo *objects, size_t *numObjects)
Clusters an array of objects in place using specified clustering parameters.
ClusteredObject::boxVariance
BBox boxVariance
Variance of bounding boxes of the members of the cluster.
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:59
BBox::height
float height
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:51
NvDsInferDBScan::NvDsInferDBScanDestroy
friend void NvDsInferDBScanDestroy(NvDsInferDBScanHandle handle)
Destroys a DBScan object clustering context.
NvDsInferObjectDetectionInfo
Holds information about one parsed object from a detector's output.
Definition: includes/nvdsinfer.h:150
EigenDefs.hpp
NvDsInferDBScanClusteringParams
Holds object clustering parameters required by DBSCAN.
Definition: includes/nvdsinfer_dbscan.h:54
ClusteredObject::box
BBox box
Bounding box of the detected object.
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:57
NvDsInferDBScan::NvDsInferDBScanCreate
friend NvDsInferDBScanHandle NvDsInferDBScanCreate()
Creates a new DBScan object clustering context.
ClusteredObject::numMembers
uint32_t numMembers
Number of members of the cluster.
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:65
ClusteredObject::maximumConfidence
float maximumConfidence
Maximum confidence of the members of the cluster.
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:63
ClusteredObject
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:54
NvDsInferDBScan
NvDsInferDBScan class.
Definition: sources/libs/nvdsinferutils/dbscan/nvdsinfer_dbscan.hpp:72
BBox
Holds the bounding box co-ordindates.
Definition: service-maker/sources/python/src/bindings/metadata.h:21