Batch processing in tracker not working

Hardware Platform (Jetson / GPU) GPU RTX 2060
• DeepStream Version 5.0
• TensorRT Version 7.1
• NVIDIA GPU Driver Version (valid for GPU only) 450

I have succesfully implemented the nvtracker with a single stream process function as below
‘’’
NvMOTStatus NvMOT_Process(NvMOTContextHandle contextHandle,
NvMOTProcessParams *pParams,
NvMOTTrackedObjBatch *pTrackedObjectsBatch)
{
NvMOTFrame *fr = pParams->frameList;
fr->timeStamp = time(0);
std::cerr<<“fr->timeStamp:”<timeStamp<<std::endl;
NvMOTObjToTrackList det_obj = fr->objectsIn;
NvMOTObjToTrack *obj_to_trk = det_obj.list;
int filled = det_obj.numFilled;
NvMOTTrackedObjBatch motOutputObjectsMeta;
NvMOTTrackedObjList
tObjList = &pTrackedObjectsBatch->list[0];

for(uint streamInd = 0; streamInd < filled; streamInd++)
{

	TrackingBox tb;
	tb.frame= sort.frame_count+1;
	tObjList->list[streamInd] = NvMOTTrackedObj{};
	tObjList->list[streamInd].classId = obj_to_trk[streamInd].classId;
	tObjList->list[streamInd].confidence = obj_to_trk[streamInd].confidence;
	tObjList->list[streamInd].age = 0;
	tb.id = -1;
	tb.score =  obj_to_trk[streamInd].confidence;
	tb.box = Rect_<float>(Point_<float>(obj_to_trk[streamInd].bbox.x, obj_to_trk[streamInd].bbox.y), Point_<float>(obj_to_trk[streamInd].bbox.x + obj_to_trk[streamInd].bbox.width, obj_to_trk[streamInd].bbox.y + obj_to_trk[streamInd].bbox.height));
	sort.detData.push_back(tb);
	//std:cerr<<obj_to_trk[streamInd].pPreservedData<<endl;

}
/*Passing the ids, bboxes and confidences to tracked output data*/
uint streamInd = 0;
for (auto tb : sort.update())
{

	tObjList->list[streamInd].trackingId = tb.id;
	tObjList->list[streamInd].bbox.x = tb.box.x;
	tObjList->list[streamInd].bbox.y = tb.box.y;
	tObjList->list[streamInd].bbox.height = tb.box.height;
	tObjList->list[streamInd].bbox.width = tb.box.width;
	tObjList->numFilled =  filled;
	tObjList->valid = true;
	if(tObjList->valid == false)
		continue;
	uint32_t streamID = tObjList->streamID;
	if(tObjList->numFilled > 0)
	{
		for(uint i=0; i<tObjList->numFilled; ++i)
		{
			NvMOTTrackedObj *tObj = &tObjList->list[i];
		}
	}
	streamInd++;
}


return NvMOTStatus_OK;

but for batch processing with more than 1 stream I am not getting continous bboxes My code is like below

NvMOTStatus NvMOT_Process(NvMOTContextHandle contextHandle,
NvMOTProcessParams *pParams,
NvMOTTrackedObjBatch *pTrackedObjectsBatch)
{
NvMOTFrame *fr = pParams->frameList;
NvMOTObjToTrackList det_obj[maxstreams];
NvMOTObjToTrack obj_to_trk[maxstreams];
int filled[maxstreams];
NvMOTTrackedObjList
tObjList[maxstreams];
NvMOTTrackedObj *tObj[maxstreams];
vector detData_i;
vector<vector> detstreamData;
vector<vector> tempData;
vector trkData;

/*Obtaining the bboxes and confidences from detected output data*/
for(uint streamid = 0; streamid < maxstreams; streamid++ )
{
	det_obj[streamid] = fr[streamid].objectsIn;
	obj_to_trk[streamid] = det_obj[streamid].list;
	filled[streamid] = det_obj[streamid].numFilled;
	tObjList[streamid] = &pTrackedObjectsBatch->list[streamid];


}

int maxfilled = filled[0];
for(uint streamid = 0; streamid < maxstreams; streamid++ )
{
	if(filled[streamid]>maxfilled)
		maxfilled = filled[streamid];
}

for(uint streamid = 0; streamid < maxstreams; streamid++ )
{

	for(uint streamInd = 0; streamInd < filled[streamid]; streamInd++)
	{

		TrackingBox tb;
		tb.frame= fi+1;
		tObjList[streamid]->list[streamInd] = NvMOTTrackedObj{};
		tObjList[streamid]->list[streamInd].classId = obj_to_trk[streamid][streamInd].classId;
		tObjList[streamid]->list[streamInd].confidence = obj_to_trk[streamid][streamInd].confidence;
		tObjList[streamid]->list[streamInd].age = 0;
		tb.id = streamInd;
		tb.score =  obj_to_trk[streamid][streamInd].confidence;
		tb.box = Rect_<float>(Point_<float>(obj_to_trk[streamid][streamInd].bbox.x, obj_to_trk[streamid][streamInd].bbox.y), Point_<float>(obj_to_trk[streamid][streamInd].bbox.x + obj_to_trk[streamid][streamInd].bbox.width, obj_to_trk[streamid][streamInd].bbox.y + obj_to_trk[streamid][streamInd].bbox.height));
		tb.obj_num = streamInd;
		tb.batchID = fr[streamid].streamID;
		detData_i.push_back(tb);


	}


}

vector<TrackingBox> tempVec;
if(detData_i.size()!=0)
{

	for(uint streamid = 0; streamid < maxstreams; streamid++ )
	{
		for (auto tb : detData_i){
			if (tb.batchID == fr[streamid].streamID)
				tempVec.push_back(tb);
		}
		detstreamData.push_back(tempVec);

		tempVec.clear();
	}
	batchtracker.obj.id=1;
	uint streamInd = 0;

	for(uint streamid = 0; streamid < maxstreams; streamid++ )
	{

		for (auto tb : batchtracker.update(detstreamData[streamid],streamid))
		{


			batchtracker.old_id.push_back(tb.id);
			for (uint k = 0;k < batchtracker.j; k++){

				if(batchtracker.old_id[k] == tb.id){
					batchtracker.obj.id = batchtracker.new_id[k];
					batchtracker.flag=1;

				}
			}

			if(!batchtracker.flag){
				if(batchtracker.j!=0){

					batchtracker.m=batchtracker.m+1;
					batchtracker.obj.id = batchtracker.m+1;
				}
			}
			batchtracker.new_id.push_back(batchtracker.obj.id);
			batchtracker.j++;
			batchtracker.flag=0;

			//tb.id = batchtracker.obj.id;
			tb.obj_num = streamInd;
			trkData.push_back(tb);
			streamInd++;
			cerr<<"tb.id"<<tb.id<<"tb.streamid"<<tb.batchID<<endl;


		}

		streamInd = 0;


	}


	for(uint streamInd = 0; streamInd < maxfilled; streamInd++)
	{

		uint streamid = 0;
		for (auto tb : trkData){
			if ((tb.batchID == fr[streamid].streamID) && (tb.obj_num == streamInd) )
			{

				tObjList[streamid]->list[streamInd].trackingId = tb.id;
				tObjList[streamid]->list[streamInd].bbox.x = tb.box.x;
				tObjList[streamid]->list[streamInd].bbox.y = tb.box.y;
				tObjList[streamid]->list[streamInd].bbox.height = tb.box.height;
				tObjList[streamid]->list[streamInd].bbox.width = tb.box.width;
				tObjList[streamid]->numFilled =  filled[streamid];
				tObjList[streamid]->valid = true;
				if(tObjList[streamid]->valid == false)
					continue;

				streamid++;


			}
		}
	}


}



fi++;
return NvMOTStatus_OK;

}

Hi Please some one respond

Sorry for the late response, we will investigate this issue to have update soon. Thanks

What does this mean?

I am getting cross talks if one stream ends in the batch processing mode between other streams

I have the same issue that is mentioned in this post but I couldnt understand how he resolved it . Can you please give me an example

We don’t have such sample. Please check if the tracked object metadata in NvMOTTrackedObjBatch are all correct in terms of StreamID.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.