matlab 桶型畸变,如何利用OpenCV改变K矩阵和畸变系数来模拟python中的桶形畸变

我有相机的固有参数,以及失真系数,我知道如何计算出枪管的变形。-主要来自以下博客:

但是,现在我想添加桶形失真,就像相机本身一样。在

校正筒体变形的代码如下:import numpy as np

import cv2

from matplotlib import pyplot as plt

# Define camera matrix K

K = np.array([[1.051e+03,0,0],

[0, 1.0845e+03,0],

[964.4480,544.2625,1.]])

#Matrix was written in matlab style, hence it has to be transposed ...

K = K.transpose()

# Define distortion coefficients d

d = np.array([0.0719,-0.0833,0.0013,-6.1840e-04,0])

# Read an example image and acquire its size

img = cv2.imread("grid.png")

h, w = img.shape[:2]

# Generate new camera matrix from parameters

newcameramatrix, roi = cv2.getOptimalNewCameraMatrix(K, d, (w,h), 0)

# Generate look-up tables for remapping the camera image

mapx, mapy = cv2.ini

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值