NVIDIA DeepStream SDK API Reference

9.2 Release
9.2/sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: Copyright (c) 2025-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 REIDSERVICE_FACTORY_HPP_
19 #define REIDSERVICE_FACTORY_HPP_
20 
21 #include <memory>
22 #include "modules/NvMultiObjectTracker/NvTrackerParams.hpp"
23 #include "modules/ReIDService/IReIDService.hpp"
24 #include "modules/ReIDService/DummyReIDService.hpp"
25 #ifndef _WIN32
26 #include "modules/ReIDService/ReIDService.hpp"
27 #endif
28 
31 {
32 public:
35  {
37  }
38 
44  ReIDServiceFactoryParams(const std::string &configFilePath, const std::string moduleName)
45  {
46  YAML::Node configRoot = getConfigRoot(configFilePath);
47  this->read(configRoot[moduleName]);
48  }
49 
54  ReIDServiceFactoryParams(const YAML::Node &fn)
55  {
56  read(fn);
57  }
58 
63  void read(const YAML::Node &fn) override
64  {
66  *this = ReIDServiceFactoryParams();
67  if(!fn.size())
68  {
69  return;
70  }
71 
73  for (YAML::const_iterator fit = fn.begin(); fit != fn.end(); ++fit)
74  {
75  std::string paramKey = fit->first.as<std::string>();
76  if (paramKey == "reidServiceType")
77  {
78  m_reidServiceType = (REID_SERVICE_TYPES)((int)fit->second.as<float>());
79  }
80  }
81  }
82 
84 };
85 
88 {
89 public:
92  {
93  static ReIDServiceFactory instance;
94  return instance;
95  }
96 
101  std::shared_ptr<IReIDService> makeReIDService(const std::string &configFilePath)
102  {
103 #ifdef _WIN32
104  m_params = ReIDServiceFactoryParams(configFilePath, "ReIDService");
106  throw std::runtime_error("ReID service is not available in the Windows IOU-only tracker build");
107  }
108  return std::make_shared<DummyReIDService>(configFilePath);
109 #else
110  m_params = ReIDServiceFactoryParams(configFilePath, "ReIDService");
112 
113  switch (m_params.m_reidServiceType)
114  {
116  {
117  return std::make_shared<ReIDService>(configFilePath);
118  }
120  {
121  return std::make_shared<DummyReIDService>(configFilePath);
122  }
123  default:
124  {
125  std::cerr << "WARNING: Invalid ReIDService type: " << m_params.m_reidServiceType << std::endl;
126  return std::make_shared<DummyReIDService>(configFilePath);
127  }
128  }
129  return nullptr;
130 #endif
131  }
132 
133 protected:
135 };
136 
137 #endif // REIDSERVICE_FACTORY_HPP_
ReIDServiceFactory::makeReIDService
std::shared_ptr< IReIDService > makeReIDService(const std::string &configFilePath)
Construct the configured ReID service implementation.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:101
ReIDServiceFactoryParams::ReIDServiceFactoryParams
ReIDServiceFactoryParams()
Construct ReID-service factory parameters.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:34
ReIDServiceFactoryParams::m_reidServiceType
REID_SERVICE_TYPES m_reidServiceType
The type of reid service.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:83
ReIDServiceFactoryParams
Stores the implementation type selected by the factory.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:30
ReIDServiceFactoryParams::read
void read(const YAML::Node &fn) override
Load configuration values from a YAML node.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:63
REID_SERVICE
@ REID_SERVICE
Implementation that associates targets through a remote ReID service.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReIDService/IReIDService.hpp:30
ReIDServiceFactory::m_params
ReIDServiceFactoryParams m_params
Config params.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:134
DUMMY_REID_SERVICE
@ DUMMY_REID_SERVICE
No-op implementation that performs no remote association.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReIDService/IReIDService.hpp:29
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
ReIDServiceFactory::getInstance
static ReIDServiceFactory & getInstance()
Get the singleton factory instance.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:91
NvTrackerParams
Provides common loading helpers for tracker configuration parameters.
Definition: sources/libs/nvmultiobjecttracker/include/modules/NvMultiObjectTracker/NvTrackerParams.hpp:35
REID_SERVICE_TYPES
REID_SERVICE_TYPES
Identifies the available ReID-service implementations.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReIDService/IReIDService.hpp:27
ReIDServiceFactoryParams::ReIDServiceFactoryParams
ReIDServiceFactoryParams(const YAML::Node &fn)
Construct a ReIDServiceFactoryParams instance.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:54
ReIDServiceFactory
Singleton factory that constructs the configured implementation.
Definition: sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:87
ReIDServiceFactoryParams::ReIDServiceFactoryParams
ReIDServiceFactoryParams(const std::string &configFilePath, const std::string moduleName)
Construct a ReIDServiceFactoryParams instance.
Definition: 9.2/sources/libs/nvmultiobjecttracker/include/modules/ReIDService/ReIDService_factory.hpp:44