opencv 去畸变
作者:互联网
import cv2 import numpy as np # 相机坐标系到像素坐标系的转换矩阵 fx = 831.514230246688 fy = 831.972596866759 cx = 327.324903206150 cy = 262.347092547845 K = np.array([[fx, 0., cx], [0., fy, cy], [0., 0., 1.0]]) #畸变系数k1 k2 pq p2 k3 k1, k2, p1, p2, k3 = 0.195387502976378, -1.36446754085673, 0.0, 0.0, 0.0 d=np.array(([[k1 ,k2, p1 ,p2 ,k3]])) #返回畸变矫正后的图像 def undistort(frame): h, w = frame.shape[:2] mapx, mapy = cv2.initUndistortRectifyMap(K, d, None, K, (w, h), 5) return cv2.remap(frame, mapx, mapy, cv2.INTER_LINEAR) #检测实时画面 cap = cv2.VideoCapture(1) while(cap.isOpened()): ret, frame = cap.read() # frame = cv2.imshow('frame', undistort(frame)) if cv2.waitKey(1) & 0xFF == ord('q'): break cap.release() cv2.destroyAllWindows()
标签:k2,0.0,frame,cap,cv2,k1,opencv,畸变 来源: https://www.cnblogs.com/lockingball/p/16348477.html