Receiving single channel data when using vpi.F32 format in a vpi pipeline

Hi,

I am using the following code to perform distortion correction on input RGB8 image (width:1280, height:720)

param_videoOutput = []
param_videoOutput.append("--width=" + str(1280))
param_videoOutput.append(f"--height=" + str(720))

input = videoSource('file:///home/front_video.mp4')
output = videoOutput('display://0', argv=param_videoOutput)

while True:
    image = input.Capture(format='rgb8')
    if image is None:
            continue
        
    with vpi.Backend.CUDA:
        distortion_corrected_front = vpi.asimage(image)\
                                        .convert(vpi.Format.NV12_ER)\
                                        .remap(warpmap_distortion_correction, interp=vpi.Interp.NEAREST)\
                                        .convert(vpi.Format.F32)
        distortion_corrected_cpu = distortion_corrected_front.cpu()
        print(distortion_corrected_cpu.shape)

This code prints (720, 1280) as opposed to (720,1280,3). When I copy the vpi image into a numpy array, the shape of the numpy array is (720, 1280) as opposed to (720, 1280, 3). When I change the vpi pipeline to .convert(vpi.Format.RGB8) instead in the end, I get a numpy array with shape (720, 1280, 3). How can I get a F32 format vpi image that has 3 channels? The reason I want to use F32 format is to pass the image to a numba cuda kernel.

Kindly advice.

Thanks

Hi,

VPI image only supports single channel floating type:
https://docs.nvidia.com/vpi/python/build/vpi.Format.html#vpi.Format

If you want 3-channel F32 data, please use the VPI array:
https://docs.nvidia.com/vpi/python/build/vpi.Array.html

Thanks.

1 Like

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