VPI v1.1 runs into segmentation fault

Hi

I am connecting my jetson xavier nx to Intel Realsense and get the frame every 0.2 seconds (5Hz). I use vpi harris coners with CUDA to calculate the features on every frame i get. However it runs into segmentation fault after sometimes. This doesnt happen with cpu execution. any reasons?

Hi,

Please check if there is a synchronization after calling the VPI algorithm.
For example:

...
// Then get Harris corners
CHECK_STATUS(
    vpiSubmitHarrisCornerDetector(stream, backend, harris, imgGrayscale, keypoints, scores, &harrisParams));

// Wait until the algorithm finishes processing
CHECK_STATUS(vpiStreamSync(stream));
...

Please also check if you have locked and unlocked the data when reading the output.
For example:

// Lock output keypoints and scores to retrieve its data on cpu memory
VPIArrayData outKeypointsData;
VPIArrayData outScoresData;
VPIImageData imgData;
CHECK_STATUS(vpiArrayLockData(keypoints, VPI_LOCK_READ, VPI_ARRAY_BUFFER_HOST_AOS, &outKeypointsData));
CHECK_STATUS(vpiArrayLockData(scores, VPI_LOCK_READ, VPI_ARRAY_BUFFER_HOST_AOS, &outScoresData));
CHECK_STATUS(vpiImageLockData(imgGrayscale, VPI_LOCK_READ, VPI_IMAGE_BUFFER_HOST_PITCH_LINEAR, &imgData));
....
// Done handling outputs, don't forget to unlock them.
CHECK_STATUS(vpiImageUnlock(imgGrayscale));
CHECK_STATUS(vpiArrayUnlock(scores));
CHECK_STATUS(vpiArrayUnlock(keypoints));

Thanks.

I wrote the code in python, any chance this is caused by the synchronisation error in python

Hi,

No, synchronization is done by the python wrapper.
Could you share a simple reproducible source for us to check?

More, is the below topic a duplicate issue?

Thanks.

Yea its a duplicate issue, so I will just produce the code here.
I connected my Jetson to Intel Realsense camera and get the frame from there.

def main():
    while True:
        # get frame from realsense camera
        cvframe = camera.get_frame() 
    
        with vpi.Backend.CUDA:
            input = vpi.asimage(cvframe, vpi.Format.BGR8).convert(vpi.Format.S16)
  
        with vpi.Backend.CUDA:
            corners, scores = input.harriscorners(strength=0.1, sensitivity=0.01, min_nms_distance=20)
        
        time.sleep(0.2)

it will run into segmentation fault after random period.
If I remove the sleep function, it runs perfectly fine without segmentation fault
I can provide the c++ code if you need.

Hi,

We modify your source to use image input and it can work well.
Could you check if the sample can also work on your side? main.py (2.4 KB)

If yes, the segmentation fault might be related to the camera rather than VPI.
Could you try to turn off the VPI algorithm and only run the loop with the camera and sleep to see if it works?

Thanks.

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