|
|
NVIDIA DeepStream SDK API Reference
|
9.2 Release
|
Go to the documentation of this file.
18 #ifndef CV_FUNCSLIB_DSLOWLEVELTRACKER_HPP_
19 #define CV_FUNCSLIB_DSLOWLEVELTRACKER_HPP_
24 #include "modules/NvMultiObjectTracker/nvdstracker.h"
27 typedef std::map<NvMOTStreamId, std::vector<std::tuple<int, cv::Rect2f, uint, float > > >
RoiBatch;
30 typedef std::map<NvMOTStreamId, std::pair<uint32_t, cv::Mat> >
FrameBatch;
81 const uint32_t gpuId,
const int maxVideoStreams,
const int numVideoStreams,
82 const int maxObjectsPerFrame,
const int numTransforms,
const uint maxWidth,
84 std::string lowLevelTrackerConfigFilePath =
"",
const int debugVerboseLevel = 0
109 numVideoStreams, numTransforms, lowLevelTrackerConfigFilePath
125 const bool isDetectionDone =
false,
const uint32_t frameBatchNo = 0
138 std::cerr <<
"NvMOT_Process() returned error " << nvtstatus << std::endl;
157 std::map<NvMOTStreamId, NvMOTFrame *> inputParam;
163 inputParam[frame->
streamID] = frame;
183 uint maxStream,
uint numTransforms, std::string lowLevelTrackerConfigFilePath =
""
188 perTransformBatchConfig.
maxWidth = maxWidth;
189 perTransformBatchConfig.
maxHeight = maxHeight;
190 perTransformBatchConfig.
maxPitch = maxPitch;
192 perTransformBatchConfig.
maxSize = maxPitch * maxHeight;
193 perTransformBatchConfig.colorFormat = colorFormat;
230 std::cerr <<
"NvMOTInit returned error " << nvtstatus << std::endl;
252 for(
int i=0; i<maxVideoStreams; i++)
258 objList->
valid =
false;
297 for(
int i=0; i<numVideoStreams; i++)
304 newFrame->
reset =
true;
309 for(
int i=0; i<numTransforms; i++)
348 const bool isDetectionDone,
const uint32_t frameBatchNo = 0
353 for(
auto it = framesInBatch.begin(); it != framesInBatch.end(); ++it)
356 const uint32_t frameNumPerStream = it->second.first;
358 const cv::Mat cvFrame = it->second.second;
360 assert(cvFrame.type() == CV_8UC1 || cvFrame.type() == CV_8UC4);
362 if(rois.find(videoStreamId) == rois.end())
365 const std::vector<std::tuple<int, cv::Rect2f, uint, float > > &roisPerStream = rois.at(videoStreamId);
386 if(resolvedFrameNum == 0)
392 frame->
reset =
false;
397 for(
int j=0; j<numTransforms; j++)
401 transform->
dataSize = cvFrame.step*cvFrame.rows;
402 transform->
width = cvFrame.cols;
403 transform->
pitch = cvFrame.step;
406 transform->
dataPtr = (
void *)cvFrame.data;
412 transform->
height = cvFrame.rows/1.5;
438 transform->
height = cvFrame.rows;
453 std::runtime_error(
"Invalid color format!");
462 "(objs->numAllocated, roisPerStream.size() = (%d, %d)\n",
471 if(isDetectionDone && roisPerStream.size() > 0)
473 for(
uint i=0; i<roisPerStream.size(); i++, objs->
numFilled++)
476 int classId = std::get<2>(roisPerStream[i]);
477 cv::Rect2f bbox = std::get<1>(roisPerStream[i]);
478 float detectionConfidence = std::get<3>(roisPerStream[i]);
495 "[DsLowLevelTracker::generateMotInputParams()] videoStreamId[%lx], frameNum[%d]: feeding %d objects \n",
496 videoStreamId, resolvedFrameNum, objs->
numFilled
515 #endif // CV_FUNCSLIB_DSLOWLEVELTRACKER_HPP_
NvMOTMiscConfig m_motMiscConfig
Miscellaneous tracker configuration.
uint32_t width
Holds the width of the buffer.
void NvMOT_DeInit(NvMOTContextHandle contextHandle)
Deinitializes a stream context.
NvMOTCompute m_computeType
Requested tracker compute target.
bool m_isIntialized
Indicates whether the low-level tracker is initialized.
NvMOTStatus
Defines generic status codes for tracking operations.
uint32_t num_planes
Holds the number of planes.
float confidence
Holds the detection confidence of the object.
void * dataPtr
Holds a pointer to allocated memory.
NvBufSurfaceColorFormat m_srcImgColorFormat
Source image color format.
uint32_t gpuId
Holds the ID of the GPU to be used.
bool m_useBatchNumForFrameId
Selects frame-batch numbers instead of per-stream frame numbers.
uint32_t width[NVBUF_MAX_PLANES]
Holds the widths of planes.
uint32_t dataSize
Holds the amount of allocated memory.
NvMOTProcessParams m_motInputParams
Input batch submitted to the tracker.
Holds a batch of lists of tracked objects.
uint32_t numFilled
Holds the number of populated blocks in the list.
~DsLowLevelTracker()
Deinitialize the tracker context and release allocated metadata.
uint32_t numAllocated
Holds the number of blocks allocated for the list.
const void removeStream(const NvMOTStreamId videoStreamID)
Remove a stream from the low-level tracker context.
@ NVBUF_MEM_CUDA_UNIFIED
Specifies CUDA Unified memory type.
NvMOTTrackedObj * list
Holds a pointer to a list or array of object information blocks.
uint32_t numFrames
Holds the number of frames in the batch.
void initialize(const uint32_t gpuId, const int maxVideoStreams, const int numVideoStreams, const int maxObjectsPerFrame, const int numTransforms, const uint maxWidth, const uint maxHeight, const uint maxPitch, const NvBufSurfaceColorFormat srcImgColorFormat, std::string lowLevelTrackerConfigFilePath="", const int debugVerboseLevel=0)
Allocate tracker metadata and initialize a low-level tracking context.
NvBufSurfaceParams ** bufferList
Holds a pointer to an array of pointers to buffer parameter structures.
Holds a frame containing the image and objects to be tracked.
NvMOTObjToTrack * list
Holds a pointer to a list or array of object information blocks.
bool reset
Holds a Boolean which is true to reset tracking for the stream.
uint32_t psize[NVBUF_MAX_PLANES]
Holds the sizes of planes in bytes.
Holds information about each tracked object.
uint32_t offset[NVBUF_MAX_PLANES]
Holds the offsets of planes in bytes.
NvMOTTimeMeta timeMeta
Holds stream PTS / NTP time, host-local receive time, and frame index.
NvMOTObjToTrackList objectsIn
Holds a list of objects in this frame which are to be tracked.
bool generateMotInputParams(const FrameBatch &framesInBatch, const int numTransforms, RoiBatch &rois, const bool isDetectionDone, const uint32_t frameBatchNo=0)
Populate low-level tracker input metadata from frame and ROI batches.
NvMOTFrameNum frameNum
Holds the frame number for objects in the list.
DsLowLevelTracker()
Initialize empty low-level tracker input and output storage.
#define NVMOTCOMP_ANY
Defines a compute target flag for "any target.".
NvMOTStatus NvMOT_RemoveStreams(NvMOTContextHandle contextHandle, NvMOTStreamId streamIdMask)
Removes streams from a batch.
void deAllocateMotInputData()
Release low-level tracker input storage.
NvMOTClassId classId
Holds the class of the object.
const NvMOTTrackedObjBatch & update(const FrameBatch &framesInBatch, const int numTransforms, RoiBatch rois=RoiBatch(), const bool isDetectionDone=false, const uint32_t frameBatchNo=0)
Process a batch of frames and return the current tracker output.
struct NvBufSurfaceParams NvBufSurfaceParams
Hold the information of single buffer in the batch.
NvMOTStatus NvMOT_Init(NvMOTConfig *pConfigIn, NvMOTContextHandle *pContextHandle, NvMOTConfigResponse *pConfigResponse)
Initializes a tracking context for a batch of one or more image streams.
Hold the information of single buffer in the batch.
Holds a tracker's configuration status.
NvMOTStreamId streamID
Holds the stream ID of the stream source for this frame.
NvMOTMiscConfig miscConfig
Holds miscellaneous configurations.
uint16_t customConfigFilePathSize
Holds the length of customConfigFilePath.
uint8_t numBuffers
Holds the number of entries in bufferList.
void allocateMotOutputData(const int maxVideoStreams, const int maxObjectsPerFrame)
Allocate current-frame tracker output storage.
bool isInitialized()
Report whether the low-level tracker is initialized.
NvMOTRect bbox
Holds the bounding box of the object.
uint32_t numFilled
Holds the number of filled blocks in the list.
Adapts test frame and ROI batches to the low-level tracker API.
uint32_t pitch[NVBUF_MAX_PLANES]
Holds the pitches of planes in bytes.
uint32_t bytesPerPix[NVBUF_MAX_PLANES]
Holds the number of bytes occupied by a pixel in each plane.
uint32_t height
Holds the height of the buffer.
void * addr[NVBUF_MAX_PLANES]
Holds planewise pointers to a CPU mapped buffer.
uint32_t numAllocated
Holds the number of blocks allocated for the list.
Holds information about an object to be tracked.
uint32_t numAllocated
Holds the number of blocks allocated for the list.
float height
Holds the height of the bounding box, in pixels.
NvMOTCompute computeConfig
Holds the compute target.
Context for input video streams.
uint32_t height[NVBUF_MAX_PLANES]
Holds the heights of planes.
bool doTracking
Holds a Boolean which is true if NvMOT is to track this object.
uint32_t maxStreams
Holds the maximum number of streams in a batch.
Holds parameters for processing a batch.
void initializeLowLeveTracker(uint maxWidth, uint maxHeight, uint maxPitch, NvBufSurfaceColorFormat colorFormat, uint maxStream, uint numTransforms, std::string lowLevelTrackerConfigFilePath="")
Recreate the low-level tracker context for configured transforms and streams.
NvBufSurfacePlaneParams planeParams
Holds planewise information (width, height, pitch, offset, etc.).
void allocateMotInputData(const int numTransforms, const int numVideoStreams, const int maxObjectsPerFrame)
Allocate low-level tracker input storage.
Holds a list of tracked objects.
NvMOTFrameNum frameNum
Holds the sequential frame number that identifies the frame within the stream.
NvMOTTrackedObjBatch m_motOutputObjectsMeta
Current-frame output from the tracker.
NvMOTContext * mp_MotCtx
Low-level tracker context.
NvMOTConfigResponse m_motConfigResponse
Response to the tracker configuration request.
float width
Holds the width of the bounding box, in pixels.
bool detectionDone
Holds a Boolean which is true if detection was done on this frame even if the list of objects to trac...
const std::map< NvMOTStreamId, NvMOTFrame * > getMotInputParams()
Return input frame metadata keyed by video stream ID.
NvMOTFrame * frameList
Holds a pointer to an array of frame data.
std::map< NvMOTStreamId, std::pair< uint32_t, cv::Mat > > FrameBatch
Maps each stream ID to a frame number and source image.
float x
Holds the left edge position of the object bounding box, in pixels.
float y
Holds the top edge position of the object bounding box, in pixels.
Formats and compares system-clock timestamps.
std::map< NvMOTStreamId, std::vector< std::tuple< int, cv::Rect2f, uint, float > > > RoiBatch
Maps each stream ID to tuples of bounding-box index, bounding box, class ID, and detection confidence...
const char * sensorName
Holds the sensor name of the stream source (e.g.
uint32_t numFilled
Holds the number of populated blocks in the list.
NvBufSurfaceMappedAddr mappedAddr
Holds pointers to mapped buffers.
@ NVBUF_COLOR_FORMAT_NV12
Specifies BT.601 colorspace - Y/CbCr 4:2:0 multi-planar.
void deAllocateMotOutputData()
Release current-frame tracker output storage.
bool doTracking
Holds a Boolean which is true if objects in this frame are to be tracked.
NvMOTPerTransformBatchConfig * perTransformBatchConfig
Holds a pointer to a list of numTransform batch configurations, one per transform,...
uint32_t pitch
Holds the pitch of the buffer.
@ NVBUF_COLOR_FORMAT_RGBA
Specifies RGBA-8-8-8-8 single plane.
NvMOTStreamId streamID
Holds the stream ID of the stream associated with objects in the list.
Holds a tracker configuration.
char * customConfigFilePath
A pointer to the pathname of the tracker's custom configuration file.
NvMOTStatus NvMOT_Process(NvMOTContextHandle contextHandle, NvMOTProcessParams *pParams, NvMOTTrackedObjBatch *pTrackedObjectsBatch)
Processes a batch.
NvBufSurfaceColorFormat colorFormat
Holds the color format of the buffer.
NvBufSurfaceColorFormat
Defines color formats for NvBufSurface.
bool valid
Holds a Boolean which is true if this entry in the batch is valid.
uint8_t numTransforms
Holds the number of NvMOTPerTransformBatchConfig entries in perTransformBatchConfig.
int m_debugVerboseLevel
Debug verbosity level.
NvMOTTrackedObjList * list
Holds a pointer to an array of object lists.
TimeStamp getUnixTimestampNanoSeconds()
Return nanoseconds elapsed since the Unix epoch.
Holds miscellaneous configurations.