|
|
NVIDIA DeepStream SDK API Reference
|
8.0 Release
|
Go to the documentation of this file.
22 #ifndef __GSTNVINFERSERVER_IMPL_H__
23 #define __GSTNVINFERSERVER_IMPL_H__
30 #include <condition_variable>
37 #include <nvbufsurface.h>
38 #include <nvbufsurftransform.h>
40 #include "infer_icontext.h"
41 #include "infer_utils.h"
44 #include "nvtx3/nvToolsExt.h"
47 #include "infer_datatypes.h"
48 #include "infer_post_datatypes.h"
49 #include "nvdsinferserver_config.pb.h"
50 #include "nvdsinferserver_plugin.pb.h"
57 const char* log_message,
void* user_ctx);
60 namespace ic = nvdsinferserver::config;
96 typedef std::unordered_map<uint64_t, SharedObjHistory>
106 gulong last_cleanup_frame_num = 0;
108 gulong last_seen_frame_num = 0;
137 struct RequestBuffer;
149 class ObjTrackingData {
161 bool initSource(uint32_t
id) {
171 void removeSource(uint32_t
id) { m_SourceInfo.erase(
id); }
189 bool hasSource(uint32_t
id)
const {
190 return m_SourceInfo.find(
id) != m_SourceInfo.end();
202 uint32_t sourceId, uint64_t objId);
213 uint32_t sourceId, uint64_t objId);
219 void clear() { m_SourceInfo.clear(); }
231 void clearUpHistory(uint64_t seqId);
236 std::unordered_map<uint32_t, GstNvInferServerSourceInfo> m_SourceInfo;
240 gulong m_LastMapCleanupSeqId = 0;
243 using FuncItem = std::function<void()>;
352 return m_NvtxDomain.get();
357 const ic::PluginControl&
config()
const {
return m_PluginConfig; }
358 void updateInterval(guint interval) {m_PluginConfig.mutable_input_control()->set_interval(interval);}
424 std::shared_ptr<RequestBuffer> reqBuf, std::vector<dsis::SharedBatchBuf> batchBuf);
437 void InferenceDone(std::shared_ptr<RequestBuffer> req);
481 ic::PluginControl& mutableConfig() {
return m_PluginConfig; }
482 bool isClassify()
const;
483 bool isDetection()
const;
484 bool isSegmentation()
const;
485 bool isOtherNetowrk()
const;
486 bool isFullFrame()
const;
487 bool maintainAspectRatio()
const;
488 bool symmetricPadding()
const;
489 bool needOutputTensorMeta()
const;
490 bool hasCustomProcess()
const;
491 uint32_t inferInterval()
const {
return m_PluginConfig.input_control().interval(); }
492 bool inputTensorFromMeta()
const
494 return m_PluginConfig.infer_config().has_input_tensor_from_meta();
506 bool validatePluginConfig(
507 ic::PluginControl&
config,
const std::string& path,
508 const GstNvInferServerProperties& update);
534 bool shouldInferObject(
NvDsObjectMeta* obj_meta, uint32_t frameNum,
535 GstNvInferServerObjectHistory* history);
546 bool outputLoop(FuncItem func);
552 using OutputThread = dsis::QueueThread<std::list<FuncItem>>;
559 mutable std::mutex m_ProcessMutex;
561 ic::PluginControl m_PluginConfig;
563 ObjTrackingData m_ObjTrackingData;
566 std::unique_ptr<OutputThread> m_OutputThread;
569 std::unique_ptr<nvtxDomainRegistration, std::function<void(nvtxDomainRegistration*)>>
573 bool m_Stopped =
false;
582 uint32_t m_IntervalCounter = 0;
584 uint64_t m_UntrackedObjectWarnPts = UINT64_C(-1);
587 bool m_1stInferDone =
false;
GstNvInferServerObjectHistoryMap object_history_map
Map of object tracking IDs and inference history of the object.
This is a header file for pre-processing cuda kernels with normalization and mean subtraction require...
Holds the box parameters of the box to be overlayed.
uint64_t last_inferred_frame_num
Number of the frame in the stream when the object was last inferred on.
NvDsInferStatus lastError() const
typedefG_BEGIN_DECLS struct _GstNvInferServer GstNvInferServer
NvDsInferStatus start()
Reads the configuration file and sets up processing context.
uint64_t last_accessed_frame_num
Number of the frame in the stream when the object was last accessed.
std::shared_ptr< GstNvInferServerObjectHistory > SharedObjHistory
Holds information about batched buffers.
std::string classifierType
bool addTrackingSource(uint32_t sourceId)
Add a new source to the object history structure.
void updateInterval(guint interval)
const std::string & classifierType() const
Class of the nvinferserver element implementation.
@ NVDSINFER_SUCCESS
NvDsInferContext operation succeeded.
void eraseTrackingSource(uint32_t sourceId)
Removes a source from the object history structure.
std::function< void(void *, NvDsInferNetworkInfo &, NvDsInferLayerInfo *, uint32_t, uint32_t)> RawOutputCallback
Function for raw output callback .
NvDsInferLogLevel
Enum for the log levels of NvDsInferContext.
GstNvInferServerImpl(GstNvInferServer *infer)
Constructor, registers the handle of the parent GStreamer element.
void resetIntervalCounter()
Resets the inference interval used in frame process mode to 0.
void gst_nvinfer_server_logger(uint32_t unique_id, NvDsInferLogLevel log_level, const char *log_message, void *user_ctx)
Function to output the logs using the GStreamer's debugging subsystem.
GstNvInferServerProperties m_GstProperties
Holds information about the model network.
Holds information about one layer in the model.
uint32_t maxBatchSize() const
NvDsInferStatus stop()
Deletes the inference context.
nvtxDomainHandle_t nvtxDomain()
NvDsInferStatus processBatchMeta(NvDsBatchMeta *batchMeta, NvBufSurface *inSurf, uint64_t seqId, void *gstBuf)
Submits the input batch for inference.
bool canSupportGpu(int gpuId) const
void setRawoutputCb(RawOutputCallback cb)
Saves the callback function pointer for the raw tensor output.
bool under_inference
Boolean indicating if the object is already being inferred on.
Holds information about the detected objects in the specific input source.
~GstNvInferServerImpl()
Constructor, do nothing.
uint32_t uniqueId() const
NvDsInferStatus sync()
Waits for the output thread to finish processing queued operations.
std::vector< int32_t > operateOnClassIds
NvDsInferStatus queueOperation(FuncItem func)
Queues the inference done operation for the request to the output thread.
Holds the inference information/history for one object based on its tracking ID.
const ic::PluginControl & config() const
std::shared_ptr< IBatchBuffer > SharedIBatchBuffer
NvOSD_RectParams last_inferred_coords
Bounding box co-ordinates of the object when it was last inferred on.
InferClassificationOutput cached_info
Cached object information.
Holds the configuration information from the nvinferserver element properties.
std::shared_ptr< dsis::IInferContext > SharedInferContext
std::weak_ptr< GstNvInferServerObjectHistory > WeakObjHistory
NvDsInferStatus
Enum for the status codes returned by NvDsInferContext.
std::unordered_map< uint64_t, SharedObjHistory > GstNvInferServerObjectHistoryMap
Map for maintaining inference history for objects based on their tracking ids: Object ID : Object His...