I am currently using jetson_utils.VideoSourceCapture method to read frames from an mp4 file, perform some operations on those frames using vpi, PyCUDA and/or Numba Cuda, and ultimately pass those frames to jetson_utils.VideoOutputRender method to display the output video.
However, I am unable to pass data in the formats of vpi.Image, DeviceNDArray and/or GPUArray formats to the Render method of VideoOutput. The Render method is expecting data in the format cudaImage. How do I convert the the aforementioned data formats to cudaImage format for compatibility with Render method of VideoOutput?
I believe they all have the cuda_array_interface property. But I am trying to figure out a way to use it for interoperability between libraries.
However I believe you are correct that the reverse direction isn’t explicitly implemented - I will add this to my todo list to investigate. Could you use a cudaImage as the output of PyCUDA/Numba/ect, so that those results are already stored in the cudaImage?
Hi @dusty_nv, thank you for the response. However, I have tried the following code -
try:
while True:
frame_left = __cap_front_stream__.Capture(format='rgb8')
if frame_left is None:
continue
with vpi.Backend.CUDA:
distortion_corrected_left = vpi.asimage(frame_left)\
.convert(vpi.Format.NV12_ER)\
.remap(warpmap_distortion_correction, interp=vpi.Interp.LINEAR)\
.convert(vpi.Format.RGB8)
with distortion_corrected_left.rlock_cuda() as cudaBuffer:
device_pointer = cudaBuffer.__cuda_array_interface__['data'][0]
distortion_corrected_left_cudaImg = cudaImage(ptr = device_pointer, width=1280, height=720, format='rgb8')
__output_stream__.Render(distortion_corrected_left_cudaImg)
if not __cap_front_stream__.IsStreaming() or not __output_stream__.IsStreaming():
break
except Exception as exception:
print(str(exception))
And the error I get is -
'ptr' is an invalid keyword argument for this function
Do I need to update my jetson_utils library to your latest commit? Because I am of the assumption that you just added an example to your latest commit. Let me know otherwise.