【发布时间】:2016-10-08 01:00:59
【问题描述】:
我使用以下代码对图像进行地理配准
有输入
grid = "for example a utm grid"
img_raw = cv2.imread(filename)
mtx, dist = "intrinsic camera matrix and
distortion coefficient from calibration matrix"
src_pts = "camera location of gcp on undistorted image"
dst_pts = "world location of gcp in the grid coordinate"
我校正相机失真并应用单应性
img = cv2.undistort(img_raw, mtx, dist, None, None)
H, mask = cv2.findHomography(src_pts, dst_pts, cv2.RANSAC,5.0)
img_geo = cv2.warpPerspective(img,(grid.shape[0],grid.shape[1]),\
flags=cv2.INTER_NEAREST,borderValue=0)
然后我想获取相机的位置。我尝试使用在 cv2.solvePnP 中计算的旋转和平移矩阵,例如 here 所示。如果我是对的,我需要至少一组 4 个共面点的相机和世界坐标。
flag, rvec, tvec = cv2.solvePnP(world, cam, mtx, dist)
再次,如果我是对的,在solvePnP中,相机坐标需要来自原始图像帧,而不是像src_pts中的未失真帧。
所以我的问题是,我怎样才能在原始图像帧中获得 src_pts 的像素位置?或者有没有其他方法可以获取 rvec 和 tvec?
【问题讨论】:
标签: opencv