Hi, I’ve noticed this in the past but I wasn’t sure where it came from and didnt have much time to dig into it as I was focused on other areas of the project. However now that I got back into this part, I still see that the problem persists, and after some digging I believe it has something to do with the cudaToNumpy() function … Apparently the cudaToNumpy() call works on some buffer that gets corrupted (or rewritten into) before we can finish working on the final numpy array (even if the first thing I do with this numpy array is to safe copy to another place: the b = a.copy() below)
You can reproduce this issue by modifying the detectnet-camera.py in the following manner:
while True: img = input.Capture() a = jetson.utils.cudaToNumpy() b = a.copy() cv2.imwrite('/tmp/{}.jpg'.format(time.monotonic()), b) detections = net.Detect(img, overlay=opt.overlay)
I would expect all the frames that come from the input (videoSource) to be saved as they came to disk, but they get corrupted/overwritten (you can even see some pieces of the overlays that are made in the detection step to show up in the numpy array just returned by the cudaToNumpy().
I can also confirm that the cudaImages returned by the videoSource component themselves are not corrupted because they show up perfectly on the opengl window without any corruption/overwriting, but when they are converted to numpy they start to show some signs of corruption/overwriting.
I can also confirm that if I sleep 1 second after the Capture I don’t experience this problem anymore. I’m sure that with a much smaller delay it would also work, but I wouldn’t really like to walk that path, I think we all agree that this should work with no delays at all.
Can anyone confirm/explain this behaviour?
Thank you,
Best regards,
Eduardo