NVIDIA VPI GStreamer Plug-in/Examples/Undistort: Difference between revisions
Line 122: | Line 122: | ||
<source lang=bash> | <source lang=bash> | ||
gst-launch-1.0 v4l2src ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! nvvidconv ! vpiupload ! vpiundistort k1=0.52 k2=-0.02 p1=0 p2=0 k3=-0.001 k4=0.8 k5=0.05 k6=-0.008 model=polynomial ! vpidownload ! nvvidconv ! nvoverlaysink | gst-launch-1.0 v4l2src ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! nvvidconv ! vpiupload ! vpiundistort k1=0.52 k2=-0.02 p1=0 p2=0 k3=-0.001 k4=0.8 k5=0.05 k6=-0.008 model=polynomial intrinsic='<<305.95,0.0,654.03>,<0.0,305.23,415.65>>' ! vpidownload ! nvvidconv ! nvoverlaysink | ||
</source> | </source> | ||
Revision as of 16:31, 21 January 2021
GstVPI |
---|
GstVPI Basics |
Getting Started |
Examples |
Performance |
Contact Us |
Introduction
The vpiundistort element applies the Lens Distortion Correction algorithm from the NVIDIA VPI library to a video stream. In order to use this algorithm you must provide the camera distortion parameters. See the next section to learn how to obtain them.
How to Obtain the Camera Calibration Parameters
Element properties
- backend
Backend to use to execute VPI algorithms. Available options:
- cpu: CPU backend
- cuda: CUDA backend
- pva: PVA backend (Xavier only)
- vic: VIC backend
Flags: readable, writable
Default: "cuda"
- extrinsinc
3x4 matrix resulting of concatenation of 3x3 rotation matrix with 3x1 vector containing the position of the origin world coordinate system expressed in coordinates of camera-centered system.
Type: GstValueArray of GValues of type GstValueArray
Flags: readable, writable
Default: <<1.0,0.0,0.0,0.0>,<0.0,1.0,0.0,0.0>,<0.0,0.0,1.0,0.0>>
- intrinsic
2x3 matrix with the parameters: [[fx,s,cx],[0,fy,cy]] where:
- fx, fy: focal length in pixels in x and y direction
- s: skew
- cx, cy: the principal point in x and y direction
If not provided, a default calibration matrix will be created.
Type: GstValueArray of GValues of type GstValueArray
Flags: readable, writable
Default: <<f, 0.0, width/2>,<0.0, f, height/2>>. Where
- interpolator
Interpolation method to be used. Available options:
- nearest: Nearest neighbor interpolation
- linear: Fast linear interpolation
- catmull: Fast Catmull-Rom cubic interpolation
Flags: readable, writable
Default: "catmull"
- model
Type of distortion model to use. Available options:
- fisheye: Fisheye distortion model
- polynomial: Polynomial (Brown-Conrady) distortion model
Flags: readable, writable
Default: "fisheye"
- mapping
Type of fisheye lens mapping types (only for fisheye model). Available options:
- equidistant: Specifies the equidistant fisheye mapping
- equisolid: Specifies the equisolid fisheye mapping
- ortographic: Specifies the ortographic fisheye mapping
- stereographic: Specifies the stereographic fisheye mapping
Flags: readable, writable
Default: "equidistant"
- k1
Distortion coefficient 1 of the chosen distortion model (fisheye or polynomial).
Type: Double
Range: -1,797693e+308 - 1,797693e+308
Flags: readable, writable
Default: 0
- k2
Distortion coefficient 2 of the chosen distortion model (fisheye or polynomial).
Type: Double
Range: -1,797693e+308 - 1,797693e+308
Flags: readable, writable
Default: 0
- k3
Distortion coefficient 3 of the chosen distortion model (fisheye or polynomial).
Type: Double
Range: -1,797693e+308 - 1,797693e+308
Flags: readable, writable
Default: 0
- k4
Distortion coefficient 4 of the chosen distortion model (fisheye or polynomial).
Type: Double
Range: -1,797693e+308 - 1,797693e+308
Flags: readable, writable
Default: 0
- k5
Distortion coefficient 5. Only for polynomial model.
Type: Double
Range: -1,797693e+308 - 1,797693e+308
Flags: readable, writable
Default: 0
- k6
Distortion coefficient 6. Only for polynomial model.
Type: Double
Range: -1,797693e+308 - 1,797693e+308
Flags: readable, writable
Default: 0
- p1
Tangential distortion coefficient 1. Only for polynomial model.
Type: Double
Range: -1,797693e+308 - 1,797693e+308
Flags: readable, writable
Default: 0
- p2
Tangential distortion coefficient 2. Only for polynomial model.
Type: Double
Range: -1,797693e+308 - 1,797693e+308
Flags: readable, writable
Default: 0
Example
The following example pipes will help you correct the distortion from your camera lens. You may modify the properties values according to the information above. In these examples we provide some distortion coefficients and calibration matrices for the camera we used, however you should modify them according to your camera's parameters (see How to Obtain the Camera Calibration Parameters).
Polynomial Distortion
gst-launch-1.0 v4l2src ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! nvvidconv ! vpiupload ! vpiundistort k1=0.52 k2=-0.02 p1=0 p2=0 k3=-0.001 k4=0.8 k5=0.05 k6=-0.008 model=polynomial intrinsic='<<305.95,0.0,654.03>,<0.0,305.23,415.65>>' ! vpidownload ! nvvidconv ! nvoverlaysink
Fisheye Distortion
gst-launch-1.0 v4l2src ! nvvidconv ! 'video/x-raw(memory:NVMM)' ! nvvidconv ! vpiupload ! vpiundistort k1=0.05 k2=0.01 k3=0 k4=0 model=fisheye intrinsic='<<305.95,0.0,654.03>,<0.0,305.23,415.65>>' mapping=equisolid ! vpidownload ! nvvidconv ! nvoverlaysink