Hello,
I think I may have found a bug. I was lightly modifiying the pyramidal LK optical flow example to track points between current and previous frames following this tutorial:
https://docs.nvidia.com/vpi/2.1/sample_optflow_lk.html
When I execute this on an x86 machine I get no problems using VPI 2.0 or VPI 2.2 however on a jetson NX ( 5.0.2 using an ngc container version 35.1) in a l4t-jetpack container using VPI 2.1.6 I cannot write to the status array at the end of my function ready for the next loop.
This is problematic as the status array is a VPI_ARRAY_TYPE_U8 (8-bit array) indicating 0 or 1 if the point is tracked or not. For the next frame all values need to be set back to 0 so all new incoming points are tracked.
However, I cannot write 0 to the status array for the new incoming points. I try like this:
VPIArrayData statusBuff;
CHECK_VPI(vpiArrayLockData(featStatus, VPI_LOCK_WRITE, VPI_ARRAY_BUFFER_HOST_AOS, &statusBuff));
uint8_t* featStatusArray = (uint8_t*)statusBuff.buffer.aos.data;
for (int i=0; i<numPoints; i++)
{
featStatusArray[i] = 0;
}
CHECK_VPI(vpiArrayUnlock(featStatus));
And also memsetting the pointer like this:
memset(featStatusArray, 0, maxCorners);
On an x86 machine the array is written to, on a jetson device it is not so remains 1, etc. which means the coordinate at that index position is no longer tracked. A memset function in the VPI API would be very useful.
I have no problems writing or reading to arrays of type VPI_ARRAY_TYPE_F32 but need a VPI_ARRAY_TYPE_U8 for the status as shown here: VPI - Vision Programming Interface: Pyramidal LK Optical Flow
Please could you describe to me whether this is a bug or I am doing something wrong. Equally, if someone could give me more information if I need different backend settings, etc due to the different memory layout (shared CPU and GPU memory) compared to an ordinary PC.
At the moment it seems like the memory is copied into a VPIArrayData object for me to access upon locking and copied back (hopefully) when it is unlocked, however this can’t be the case for U8.
Also, if someone could give me direction if it makes and difference what type I cast the pointer to. I have tried unsigned char* and uint8_t as per the example. I also tried memsetting it as a void* pointer as I am trying to set all values (and bytes) to zero.
The only way around this I have found is to destroy the status buff and reallocate it (vpiArrayCreate) every frame (to get a clean array of zeros), however this is not an optimal solution and I eventually get a VPI OOP error despite destroying it at every time afterwards.
Thanks, Tom.