Discussion on problems encountered in using vpi.WarpMap in Python

The code was as follows:

with vpi.Backend.CUDA:
frame_left = vpi.asimage(np.asarray(Image.fromarray(np.uint8(frame_left)))).convert(vpi.Format.Y16_ER, scale=1)
frame_right = vpi.asimage(np.asarray(Image.fromarray(np.uint8(frame_right)))).convert(vpi.Format.Y16_ER,
scale=1)
R=cv2.Rodrigues(R)[0]
T=T.T
print(R,T)
print(type(left_intrinsic_parameter[:2,:]),type(np.concatenate([R,T],axis=1)),type(R[:1,:]),type(T[:1,:]))
print(left_intrinsic_parameter[:2,:].shape,np.concatenate([R,T],axis=1).shape,R[:1,:].squeeze(0).shape,T.T[:1,:].squeeze(0).shape)

    print("vpi.WarpGrid(frame_left.size) ",vpi.WarpGrid(frame_left.size))


    print("   frame_left.size ",frame_left.size)

    print(" left_intrinsic_parameter[:2,:]   ",left_intrinsic_parameter[:2,:])
    print(" np.concatenate([R,T],axis=1)   ",np.concatenate([R,T],axis=1))
    print("R[:1,:].squeeze(0)   ",R[:1,:].squeeze(0))


    # Create an uniform grid
    grid = vpi.WarpGrid(frame_left.size)

    #Create undistort warp map from the calibration parameters and the grid
    #warpL = vpi.WarpMap.fisheye_correction(grid,K=left_intrinsic_parameter[:2,:],X=np.concatenate([R,T],axis=1), coeffs=R[:1,:].squeeze(0),mapping=vpi.FisheyeMapping.EQUIDISTANT)

    warpL = vpi.WarpMap.polynomial_correction(vpi.WarpGrid(frame_left.size),left_intrinsic_parameter[:2,:],X=np.concatenate([R,T],axis=1),R=R[:1,:].squeeze(0),T=T.T[:1,:].squeeze(0))
    warpR = vpi.WarpMap.polynomial_correction(vpi.WarpGrid(frame_right.size),right_intrinsic_parameter[:2,:],X=np.concatenate([R,T],axis=1),R=R[:1,:].squeeze(0),T=T.T[:1,:].squeeze(0))

When I use the JestonTX2,here was the error when it run:

[ WARN:0] global /home/nvidia/host/build_opencv/nv_opencv/modules/videoio/src/cap_gstreamer.cpp (933) open OpenCV | GStreamer warning: Cannot query video position: status=0, value=-1, duration=-1
NVMEDIA_ARRAY: 53, Version 2.1
NVMEDIA_VPI : 172, Version 2.4
[[ 9.99991314e-01 4.93794835e-04 4.13872961e-03]
[ -4.99947323e-04 9.99998771e-01 1.48566158e-03]
[ -4.13799091e-03 -1.48771783e-03 9.99990332e-01]] [[ -1.49653167e-01]
[ 1.40314849e-04]
[ 4.56383365e-04]]
<class ‘numpy.ndarray’> <class ‘numpy.ndarray’> <class ‘numpy.ndarray’> <class ‘numpy.ndarray’>
(2, 3) (3, 4) (3,) (3,)
vpi.WarpGrid(frame_left.size) <vpi.WarpGrid(regions=([
frame_left.size (1920, 1200)
left_intrinsic_parameter[:2,:] [[ 960.66729736 0. 959.99499512]
[ 0. 958.38024902 584.94726562]]
np.concatenate([R,T],axis=1) [[ 9.99991314e-01 4.93794835e-04 4.13872961e-03 -1.49653167e-01]
[ -4.99947323e-04 9.99998771e-01 1.48566158e-03 1.40314849e-04]
[ -4.13799091e-03 -1.48771783e-03 9.99990332e-01 4.56383365e-04]]
R[:1,:].squeeze(0) [ 9.99991314e-01 4.93794835e-04 4.13872961e-03]
Traceback (most recent call last):
File “show_img.py”, line 77, in
warpL = vpi.WarpMap.polynomial_correction(vpi.WarpGrid(frame_left.size),left_intrinsic_parameter[:2,:],X=np.concatenate([R,T],axis=1),R=R[:1,:].squeeze(0),T=T.T[:1,:].squeeze(0))
TypeError: polynomial_correction(): incompatible function arguments. The following argument types are supported:
1. (grid: vpi.WarpGrid, *, Kin: numpy.ndarray[numpy.float32], X: numpy.ndarray[numpy.float32], Kout: numpy.ndarray[numpy.float32], rcoeffs: numpy.ndarray[numpy.float32], tcoeffs: numpy.ndarray[numpy.float32] = array(, dtype=float32)) → vpi.WarpMap
2. (grid: vpi.WarpGrid, *, K: numpy.ndarray[numpy.float32], X: numpy.ndarray[numpy.float32], rcoeffs: numpy.ndarray[numpy.float32], tcoeffs: numpy.ndarray[numpy.float32] = array(, dtype=float32)) → vpi.WarpMap

Invoked with: <vpi.WarpGrid(regions=([, array([[ 960.66729736, 0. , 959.99499512],
[ 0. , 958.38024902, 584.94726562]]); kwargs: X=array([[ 9.99991314e-01, 4.93794835e-04, 4.13872961e-03,
-1.49653167e-01],
[ -4.99947323e-04, 9.99998771e-01, 1.48566158e-03,
1.40314849e-04],
[ -4.13799091e-03, -1.48771783e-03, 9.99990332e-01,
4.56383365e-04]]), R=array([ 9.99991314e-01, 4.93794835e-04, 4.13872961e-03]), T=<built-in method squeeze of numpy.ndarray object at 0x7f72ba5e90>

As we can see, the format of each parameter is satisfactory.
I can’t find any reason why the vpi.WarpMap.polynomial_correction() can’t work.
So I’m here to seek the help of Nvidia and other algorithm engineers.
Help me,please.