Hello!
I’m trying to use DCF tracker in combination with an object detector for object tracking.
I always receive an error (VPIStatus 2, i.e. VPI_ERROR_INVALID_ARGUMENT) during the Update and Localize stage as soon as I have at least one tracked object.
I have checked that all the inputs are correct according to what is mentioned in the docs, i.e.
* @retval #VPI_ERROR_INVALID_ARGUMENT \p stream is NULL.
* @retval #VPI_ERROR_INVALID_ARGUMENT \p inPatches or trackedObjects are NULL.
* @retval #VPI_ERROR_INVALID_ARGUMENT \p payload not created by vpiCreateDCFTracker.
* @retval #VPI_ERROR_INVALID_ARGUMENT \p inPatches dimensions outside valid range.
* @retval #VPI_ERROR_INVALID_ARGUMENT Unsupported array type in \p trackedObjects.
* @retval #VPI_ERROR_INVALID_ARGUMENT Parameter(s) in \p params outside valid range.
however, the inputs seem to be normal.
Here is the snippet of my code:
initialization:
VPI_CHECK(vpiCreateCropScaler(VPI_BACKEND_CUDA, 1, max_det, &cropPayload));
VPIDCFTrackerCreationParams dcfTrackerCreateParams;
VPI_CHECK(vpiInitDCFTrackerCreationParams(&dcfTrackerCreateParams));
VPI_CHECK(vpiCreateDCFTracker(VPI_BACKEND_CUDA, 1, max_det, &dcfTrackerCreateParams, &dcfPayload));
VPI_CHECK(vpiInitDCFTrackerParams(&dcfTrackerParams));
VPI_CHECK(vpiArrayCreate(max_det, VPI_ARRAY_TYPE_DCF_TRACKED_BOUNDING_BOX, VPI_BACKEND_CUDA|VPI_BACKEND_CPU, &trackedObjects));
VPI_CHECK(vpiArrayCreate(max_det, VPI_ARRAY_TYPE_F32, VPI_BACKEND_CUDA|VPI_BACKEND_CPU, &trackedObjectsCorrelationResponses));
patchH = patchW = dcfTrackerCreateParams.featurePatchSize * dcfTrackerCreateParams.hogCellSize;
VPI_CHECK(vpiImageCreate(patchW,
patchH * max_det,
VPI_IMAGE_FORMAT_RGBA8,
VPI_BACKEND_CUDA,
&objPatches));
loop:
...
...
VPIImage vpiImg; // U8
VPI_CHECK(vpiImageCreateWrapperOpenCVMat(cvImg, VPI_BACKEND_CUDA, &vpiImg));
VPIImage vpiImgRGBA8; // RGBA8
VPI_CHECK(vpiImageCreate(cvImg.cols, cvImg.rows, VPI_IMAGE_FORMAT_RGBA8, VPI_BACKEND_CUDA, &vpiImgRGBA8));
VPI_CHECK(vpiSubmitConvertImageFormat(vpiStream, VPI_BACKEND_CUDA, vpiImg, vpiImgRGBA8, nullptr));
...
...
// Track
// predict and visualy localize
int nTrackedObjects;
VPI_CHECK(vpiArrayGetSize(trackedObjects, &nTrackedObjects));
if (nTrackedObjects > 0)
{
VPI_CHECK(vpiSubmitCropScalerBatch(vpiStream, VPI_BACKEND_CUDA, cropPayload,
&vpiImgRGBA8, 1, trackedObjects,
patchW, patchH, objPatches));
VPI_CHECK(vpiSubmitDCFTrackerLocalizeBatch(vpiStream, VPI_BACKEND_CUDA, dcfPayload, nullptr, 1,
nullptr, objPatches, trackedObjects, trackedObjects, nullptr,
trackedObjectsCorrelationResponses, &dcfTrackerParams));
VPI_CHECK(vpiStreamSync(vpiStream));
}
// update objects
if (nTrackedObjects > 0 or numDets[0] > 0)
{
VPIArrayData trackedObjectsData;
VPI_CHECK(vpiArrayLockData(trackedObjects, VPI_LOCK_READ_WRITE, VPI_ARRAY_BUFFER_HOST_AOS, &trackedObjectsData));
...
...
// add new objects (not associated)
VPI_CHECK(vpiArrayGetSize(trackedObjects, &nTrackedObjects));
VPI_CHECK(vpiArraySetSize(trackedObjects, nTrackedObjects + nNewObjects));
for (int i = 0; i < nNewObjects; ++i)
{
int idxBbox = newObjects[i];
int idxObject = nTrackedObjects + i;
VPIAxisAlignedBoundingBoxF32 newObjectBbox{(float)bboxes[0][idxBbox].x, (float)bboxes[0][idxBbox].y, (float)bboxes[0][idxBbox].width, (float)bboxes[0][idxBbox].height};
VPIDCFTrackedBoundingBox newObject{newObjectBbox, VPI_TRACKING_STATE_NEW, 0, filterLR, filterChannelWeightsLR, new trackedObjectInfo{0}};
((VPIDCFTrackedBoundingBox*)trackedObjectsData.buffer.aos.data)[idxObject] = newObject;
}
VPI_CHECK(vpiArrayUnlock(trackedObjects));
}
// update tracker
VPI_CHECK(vpiArrayGetSize(trackedObjects, &nTrackedObjects));
if (nTrackedObjects > 0)
{
// Extract from the current frame the image patches of each object given its refined bounding box.
VPI_CHECK(vpiSubmitCropScalerBatch(vpiStream, VPI_BACKEND_CUDA, cropPayload,
&vpiImgRGBA8, 1, trackedObjects,
patchW, patchH, objPatches));
// Update tracking information
VPI_CHECK(vpiSubmitDCFTrackerUpdateBatch(vpiStream, VPI_BACKEND_CUDA, dcfPayload,
nullptr, 1,
nullptr, nullptr,
objPatches, trackedObjects, &dcfTrackerParams));
VPI_CHECK(vpiStreamSync(vpiStream));
VPIArrayData trackedObjectsData;
VPI_CHECK(vpiArrayLockData(trackedObjects, VPI_LOCK_READ_WRITE, VPI_ARRAY_BUFFER_HOST_AOS, &trackedObjectsData));
for (int i = 0; i < nTrackedObjects; ++i) {
if (((VPIDCFTrackedBoundingBox *) trackedObjectsData.buffer.aos.data)[i].state != VPI_TRACKING_STATE_LOST)
((VPIDCFTrackedBoundingBox *) trackedObjectsData.buffer.aos.data)[i].state = VPI_TRACKING_STATE_TRACKED;
}
VPI_CHECK(vpiArrayUnlock(trackedObjects));
}