Custom low level library for tracker

From my previous question https://devtalk.nvidia.com/default/topic/1070933/deepstream-sdk/iterate-bbox-in-nvmot/post/5426995/#5426995 For testing purpose I added hardcoded boxes in custom low level tracker. Below is my low_level_library code which I will compile it as .so file and use it as low level tracker in tracker config

#include <math.h>
#include <stdio.h>
#include "nvdstracker.h"
#include <iostream>
#include <glib.h>
#include "opencv2/opencv.hpp"
#include "nvbufsurface.h"
#include "nvbufsurftransform.h"
#include "gstnvdsmeta.h"
#include "gstnvdsinfer.h"
#include <cstddef>

NvMOTStatus NvMOT_Query(uint16_t customConfigFilePathSize, char* pCustomConfigFilePath, NvMOTQuery *pQuery)
{

pQuery->memType = NVBUF_MEM_CUDA_UNIFIED;
pQuery->colorFormats[0] = NVBUF_COLOR_FORMAT_RGBA;
pQuery->colorFormats[1] = NVBUF_COLOR_FORMAT_RGBA;
pQuery->colorFormats[2] = NVBUF_COLOR_FORMAT_RGBA;
pQuery->colorFormats[3] = NVBUF_COLOR_FORMAT_RGBA;

return NvMOTStatus_OK;
}

NvMOTStatus NvMOT_Init(NvMOTConfig *pConfigIn,NvMOTContextHandle *pContextHandle,NvMOTConfigResponse *pConfigResponse)
{

std::cout<<"trackerinit...!!!!!\n";
pConfigResponse->summaryStatus = NvMOTConfigStatus_OK;
pConfigResponse->computeStatus = NvMOTConfigStatus_OK;
pConfigResponse->transformBatchStatus = NvMOTConfigStatus_OK;
pConfigResponse->miscConfigStatus = NvMOTConfigStatus_OK;
pConfigResponse->customConfigStatus = NvMOTConfigStatus_OK;

NvMOTContextHandle *ctx = (NvMOTContextHandle *) pConfigIn;

*pContextHandle =  *ctx;
return NvMOTStatus_OK;

NvMOTStatus NvMOT_Process(NvMOTContextHandle contextHandle,NvMOTProcessParams *pParams,NvMOTTrackedObjBatch *pTrackedObjectsBatch)

{
NvMOTFrame *fr = pParams->frameList;
NvMOTObjToTrackList det_obj = fr->objectsIn;
NvMOTObjToTrack *obj_to_trk = det_obj.list;

for (int i = 0;i<det_obj.numFilled;i++){

  NvMOTTrackedObj OutObject ;
 OutObject.bbox.x = 100+i;
 OutObject.bbox.y = 100+i;
 OutObject.bbox.width = 258+i;
 OutObject.bbox.height = 897+i;
 OutObject.trackingId = i+1;
 OutObject.confidence = 0.9;
 OutObject.classId =0;
 out_trk.push_back(OutObject);
}
for (int i = 0;i<pTrackedObjectsBatch->numFilled;i++){
  NvMOTTrackedObjList OutObject_list ;
 OutObject_list.streamID = fr-> streamID;
 OutObject_list.frameNum = numbuf;
 OutObject_list.list = out_trk.data();
 OutObject_list.numFilled = det_obj.numFilled;
 OutObject_list.valid = true;
 OutObject_list.numAllocated = det_obj.numAllocated;
 out_trk_list.push_back(OutObject_list);
}

pTrackedObjectsBatch->list = out_trk_list.data();

return NvMOTStatus_OK;

}
void NvMOT_DeInit(NvMOTContextHandle contextHandle){

  std::cout<<"deinit...!!!!!\n";

}

when I send this hardcoded bbox value I can able to get these value in deepstream-sample-app(deepstream-infer-tensor-meta-test) for first two frames then I get segmentation fault error.
Help me to fix this error.

Before testing your own custom low-level tracker, you would need to make sure the caller to use the APIs properly. Have you tested your caller to be able to call and run KLT tracker?

Hi,

Yes I tested with KLT tracker, it is working fine, but when I change .so to point my tracker lib the above mentioned error appears. I think the issue is with my low level library.

any update?
I am also getting the below error,

gstnvtracker: Got output for unknown stream 7f804000b630

The following code snippets are suspicious. You assign the pre-allocated memory to OutObject_list.list, but you specify OutObject_list.numAllocated with different data. I am not sure if you are doing it correctly or not.

OutObject_list.list = out_trk.data();
OutObject_list.numFilled = det_obj.numFilled;
OutObject_list.numAllocated = det_obj.numAllocated;

Also SegFault happens typically when you make illegal memory access. Make sure if OutObject_list.numFilled <= OutObject_list.numAllocated always holds.

I can’t give you much advise/suggestion unless you provide full working code. You can create a partner ticket if you want us to review internally.

How to create partner ticket?

Hi sathiez,

Sorry for the late reply, have you got the update to move your project forward?

After some research. I find the problems.
The key point is we should use memcpy to set pTrackedObjectsBatch->list.

1 Like