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.shape0: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.shape1, undistorted_img1.shape0, 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.shape1))))

print(points)

相关推荐
ZGIAI22 分钟前
旧模型下线前,客服 Agent 怎么迁移
人工智能·架构
东风破_31 分钟前
程序重启后,AI 为什么把你忘了?从 InMemory 到持久化 Memory
人工智能
ZGIAI37 分钟前
客服知识库更新后,怎么批量验收
人工智能·架构
Asize1 小时前
AI 协作开发新范式:我用 SDD 做了个排版 npm 包
前端·人工智能
IT_陈寒3 小时前
用了Proxy才发现以前的JavaScript白写了
前端·人工智能·后端
甲维斯4 小时前
Claude Opus5手搓“NewAPI Plus”首轮成果!
人工智能
程序猿DD4 小时前
分享两个我每天都在用的 Skill,拖进豆包就能跑,限时领 30 天会员
人工智能
阿里云大数据AI技术4 小时前
Agentic Search 2.0:从单轮对话迈向企业级 AI 搜索自动驾驶Agent
人工智能·elasticsearch·agent
东风破_4 小时前
从 messages 数组到 Memory:大模型到底是怎么“记住”上一轮对话的?
人工智能
AEI5 小时前
四年间大模型的演进历程
人工智能·面试·程序员