opencv 三维重建基础

import cv2

import numpy as np

假设已经获取了相机矩阵和畸变系数

camera_matrix = np.array(...)

dist_coeffs = np.array(...)

读取校正前的图像

img1 = cv2.imread('left01.jpg')

校正图像

map1, map2 = cv2.fisheye.initUndistortRectifyMap(camera_matrix, dist_coeffs, np.eye(3), camera_matrix, img1.shape[0:2][::-1], cv2.CV_16SC2)

undistorted_img1 = cv2.remap(img1, map1, map2, interpolation=cv2.INTER_LINEAR, borderMode=cv2.BORDER_CONSTANT)

计算投影矩阵

proj_matrix = cv2.fisheye.getOptimizedProjectionMatrix(camera_matrix, dist_coeffs, undistorted_img1.shape[1], undistorted_img1.shape[0], alpha=0.0)

将校正后的图像投影到三维空间

img1_3d = cv2.fisheye.projectImageTo3D(undistorted_img1, proj_matrix)

显示三维点云

points = np.reshape(img1_3d, (3, -1)).T

points = np.hstack((points, np.ones((1, points.shape[1]))))

print(points)

相关推荐
m0_6090004244 分钟前
向日葵好用吗?4款稳定的远程控制软件推荐。
运维·服务器·网络·人工智能·远程工作
开MINI的工科男2 小时前
深蓝学院-- 量产自动驾驶中的规划控制算法 小鹏
人工智能·机器学习·自动驾驶
AI大模型知识分享3 小时前
Prompt最佳实践|如何用参考文本让ChatGPT答案更精准?
人工智能·深度学习·机器学习·chatgpt·prompt·gpt-3
张人玉5 小时前
人工智能——猴子摘香蕉问题
人工智能
草莓屁屁我不吃5 小时前
Siri因ChatGPT-4o升级:我们的个人信息还安全吗?
人工智能·安全·chatgpt·chatgpt-4o
小言从不摸鱼5 小时前
【AI大模型】ChatGPT模型原理介绍(下)
人工智能·python·深度学习·机器学习·自然语言处理·chatgpt
AI科研视界5 小时前
ChatGPT+2:修订初始AI安全性和超级智能假设
人工智能·chatgpt
霍格沃兹测试开发学社测试人社区5 小时前
人工智能 | 基于ChatGPT开发人工智能服务平台
软件测试·人工智能·测试开发·chatgpt
小R资源6 小时前
3款免费的GPT类工具
人工智能·gpt·chatgpt·ai作画·ai模型·国内免费
artificiali8 小时前
Anaconda配置pytorch的基本操作
人工智能·pytorch·python