NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2021-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 DATAASSOCIATORLIB_DATAASSOCIATOR_FACTORY_HPP_
19 #define DATAASSOCIATORLIB_DATAASSOCIATOR_FACTORY_HPP_
20 
21 #include <memory>
22 #include "modules/NvMultiObjectTracker/NvTrackerParams.hpp"
23 #include "modules/DataAssociator/IDataAssociator.hpp"
24 // Data associators.
25 #include "modules/DataAssociator/DataAssociator.hpp"
26 
29 {
30 public:
33  {
35  }
36 
42  DataAssociatorFactoryParams(const std::string &configFilePath, const std::string moduleName)
43  {
44  YAML::Node configRoot = getConfigRoot(configFilePath);
45  this->read(configRoot[moduleName]);
46  }
47 
52  DataAssociatorFactoryParams(const YAML::Node &fn)
53  {
54  read(fn);
55  }
56 
61  void read(const YAML::Node &fn) override
62  {
64  if(!fn.size())
65  {
66  return;
67  }
68 
70  for (YAML::const_iterator fit = fn.begin(); fit != fn.end(); ++fit)
71  {
72  std::string paramKey = fit->first.as<std::string>();
73  if (paramKey == "dataAssociatorType")
74  {
75  m_dataAssociatorType = (DATA_ASSOCIATOR_TYPES)((int)fit->second.as<float>());
76  }
77  }
78  }
79 
81 };
82 
85 {
86 public:
89  {
90  static DataAssociatorFactory instance;
91  return instance;
92  }
93 
98  std::shared_ptr<IDataAssociator> makeDataAssociator(const std::string &configFilePath)
99  {
101  m_params = DataAssociatorFactoryParams(configFilePath, "DataAssociator");
102 
104  {
106  default:
107  {
108  return std::make_shared<DataAssociator>(configFilePath);
109  }
110  }
111  return nullptr;
112  }
113 
114 protected:
115 
117 };
118 
119 #endif // DATAASSOCIATORLIB_DATAASSOCIATOR_FACTORY_HPP_
DataAssociatorFactoryParams::DataAssociatorFactoryParams
DataAssociatorFactoryParams()
Initialize factory parameters with the default associator type.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:32
DataAssociatorFactory::m_params
DataAssociatorFactoryParams m_params
Config params.
Definition: sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:116
DEFAULT_ASSOCIATOR
@ DEFAULT_ASSOCIATOR
Selects the default data associator.
Definition: sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/IDataAssociator.hpp:26
NvTrackerParams::getConfigRoot
static const YAML::Node getConfigRoot(const std::string &configFilePath, const bool printMessage=false)
Load the root YAML node from a tracker configuration file.
Definition: sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvTrackerParams.hpp:121
DataAssociatorFactoryParams::m_dataAssociatorType
DATA_ASSOCIATOR_TYPES m_dataAssociatorType
The type of data associator.
Definition: sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:80
DataAssociatorFactoryParams
Config parser for factory.
Definition: sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:28
DataAssociatorFactoryParams::DataAssociatorFactoryParams
DataAssociatorFactoryParams(const YAML::Node &fn)
Initialize factory parameters from a YAML node.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:52
NvTrackerParams
Provides common loading helpers for tracker configuration parameters.
Definition: sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvTrackerParams.hpp:35
DataAssociatorFactoryParams::DataAssociatorFactoryParams
DataAssociatorFactoryParams(const std::string &configFilePath, const std::string moduleName)
Initialize factory parameters from a configuration module.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:42
DataAssociatorFactory::makeDataAssociator
std::shared_ptr< IDataAssociator > makeDataAssociator(const std::string &configFilePath)
Create the configured data-associator implementation.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:98
DataAssociatorFactory
Singleton factory for data associator objects.
Definition: sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:84
DATA_ASSOCIATOR_TYPES
DATA_ASSOCIATOR_TYPES
Definition: sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/IDataAssociator.hpp:24
DataAssociatorFactory::getInstance
static DataAssociatorFactory & getInstance()
Return the static instance reference to the factory.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:88
DataAssociatorFactoryParams::read
void read(const YAML::Node &fn) override
Update factory parameters from a YAML node.
Definition: sources/libs/nvmultiobjecttracker/include/modules/DataAssociator/DataAssociator_factory.hpp:61