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)

相关推荐
emo猫pro_max44 分钟前
openclaw飞书流式回复配置指南
人工智能
FishCoderh1 小时前
被OpenClaw的Session搞晕了?这篇让你彻底搞懂
人工智能
孤烟2 小时前
19 万 + GitHub 星标!OpenClaw 凭什么成为 2026 最火 AI Agent,万字实测告诉你
人工智能
zhl772 小时前
YOLOv5:从0搭建你的第一个目标检测模型
人工智能
TechFind2 小时前
用 OpenClaw 搭建企业微信 AI Agent:从零到自动化客服只需 30 分钟
人工智能·agent
FishCoderh2 小时前
OpenClaw部署后Tools工具权限被禁用?一行配置解决
人工智能
飞哥数智坊4 小时前
openclaw 不是全站第一!但它的爆发,足以引人深思
人工智能
zone77395 小时前
001:LangChain的LCEL语法学习
人工智能·后端·面试
程序员鱼皮5 小时前
微软竟然出了免费的 AI 应用开发课?!我已经学上了
人工智能·程序员·ai编程
DevnullCoffe6 小时前
基于 OpenClaw + Pangolinfo API 的 Amazon 价格监控系统:架构设计与最佳实践
人工智能·架构