opencv之图像畸变矫正


目录
  • 前言
  • 函数
  • 代码测试
  • 参考

前言

图像的畸变矫正需要相机的内参和畸变系数, 在opencv中, 有以下两个函数可以实现:

  • undistort()函数
  • initUndistortRectifyMap() + remap()函数

函数

  • undistort
void undistort(InputArray src, OutputArray dst, InputArray cameraMatrix, InputArray distCoeffs, InputArray newCameraMatrix=noArray() )
  • initUndistortRectifyMap
void initUndistortRectifyMap(InputArray cameraMatrix, InputArray distCoeffs, InputArray R, InputArray newCameraMatrix, Size size, int m1type, OutputArray map1, OutputArray map2)
  • remap
void remap(InputArray src, OutputArray dst, InputArray map1, InputArray map2, int interpolation, int borderMode=BORDER_CONSTANT, const Scalar& borderValue=Scalar())

remap有以下几种插值的方法:

interpolation method:

  • INTER_NEAREST - a nearest-neighbor interpolation
  • INTER_LINEAR - a bilinear interpolation (used by default)
  • INTER_AREA - resampling using pixel area relation. It may be a preferred method for image decimation, as it gives moire’-free results. But when the image is zoomed, it is similar to the INTER_NEAREST method.
  • INTER_CUBIC - a bicubic interpolation over 4x4 pixel neighborhood
  • INTER_LANCZOS4 - a Lanczos interpolation over 8x8 pixel neighborhood

代码测试

未完成

参考

  • https://docs.opencv.org/2.4/modules/imgproc/doc/geometric_transformations.html#undistort

  • https://answers.opencv.org/question/42808/difference-between-undistort-and-initundistortrectifymapremap/