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)

相关推荐
一点一木3 小时前
深度体验TRAE SOLO移动端7天:作为独立开发者,我把工作流揣进了兜里
前端·人工智能·trae
Lee川4 小时前
mini-cursor 揭秘:从 Tool 定义到 Agent 循环的完整实现
前端·人工智能·后端
weelinking4 小时前
【产品】00_产品经理用Claude实现产品系列介绍
数据库·人工智能·sql·数据挖掘·github·产品经理
Agent产品评测局4 小时前
制造业模具管理AI系统,主流产品能力对比详解:2026年智能制造选型深度洞察
人工智能·ai·chatgpt·制造
研华科技Advantech5 小时前
如何用一套实训设备,打通工业AI预测性维护技术全流程?
人工智能
Lab_AI5 小时前
AI for Science: MaXFlow AI Agent+ 报告体验双升级,让AI智能体更高效易用!
人工智能·ai for science·ai agent·ai智能体
李坤5 小时前
让 Codex 和 Claude 互相 Review:告别手动复制
人工智能·openai·claude
南屹川6 小时前
【API设计】GraphQL实战:从REST到GraphQL的演进
人工智能
KJ_BioMed6 小时前
当计算生物学遇上生成式AI:从头设计生物分子的“新范式”初探
人工智能·从头设计·生命科学·生物医药·科研干货·科晶生物
明月醉窗台6 小时前
深度学习(17)YOLO训练中的超参数详解
人工智能·深度学习·yolo