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)

相关推荐
许泽宇的技术分享16 分钟前
AI黑客来袭:Strix如何用大模型重新定义渗透测试游戏规则
人工智能
Oxo Security23 分钟前
【AI安全】检索增强生成(RAG)
人工智能·安全·网络安全·ai
少林码僧27 分钟前
2.3 Transformer 变体与扩展:BERT、GPT 与多模态模型
人工智能·gpt·ai·大模型·bert·transformer·1024程序员节
shayudiandian30 分钟前
如何使用 DeepSeek 帮助自己的工作
人工智能
程序猿追1 小时前
轻量级云原生体验:在OpenEuler 25.09上快速部署单节点K3s
人工智能·科技·机器学习·unity·游戏引擎
@小码农1 小时前
2025年北京海淀区中小学生信息学竞赛第一赛段试题(附答案)
人工智能·python·算法·蓝桥杯
程序猿追2 小时前
异腾910B NPU实战:vLLM模型深度测评与部署指南
运维·服务器·人工智能·机器学习·架构
York·Zhang2 小时前
Ollama:在本地运行大语言模型的利器
人工智能·语言模型·自然语言处理·ollama
reesn2 小时前
nanochat大语言模型讲解一
人工智能·语言模型·自然语言处理
张较瘦_2 小时前
[论文阅读] AI + 软件工程 | 3340个Python ML项目实证:PyQu工具+61种代码变更,精准提升软件质量!
论文阅读·人工智能·软件工程