惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

AI
AI
小众软件
小众软件
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
月光博客
月光博客
云风的 BLOG
云风的 BLOG
Recorded Future
Recorded Future
Apple Machine Learning Research
Apple Machine Learning Research
F
Fortinet All Blogs
罗磊的独立博客
爱范儿
爱范儿
GbyAI
GbyAI
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
D
Docker
C
CXSECURITY Database RSS Feed - CXSecurity.com
Spread Privacy
Spread Privacy
Recent Announcements
Recent Announcements
酷 壳 – CoolShell
酷 壳 – CoolShell
G
GRAHAM CLULEY
A
About on SuperTechFans
C
Cisco Blogs
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
B
Blog
Project Zero
Project Zero
V
V2EX
K
Kaspersky official blog
P
Privacy International News Feed
博客园 - 叶小钗
I
Intezer
T
Threatpost
The GitHub Blog
The GitHub Blog
CTFtime.org: upcoming CTF events
CTFtime.org: upcoming CTF events
V
Vulnerabilities – Threatpost
D
Darknet – Hacking Tools, Hacker News & Cyber Security
C
Cybersecurity and Infrastructure Security Agency CISA
Cyberwarzone
Cyberwarzone
Microsoft Azure Blog
Microsoft Azure Blog
N
Netflix TechBlog - Medium
Application and Cybersecurity Blog
Application and Cybersecurity Blog
博客园 - 【当耐特】
P
Proofpoint News Feed
L
Lohrmann on Cybersecurity
S
Schneier on Security
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
F
Full Disclosure
The Cloudflare Blog
P
Palo Alto Networks Blog
K
KPMG report finds enterprise disconnect between AI and its ROI | CIO
T
Tenable Blog

StudyingLover's Blog

Diffusion Policy笔记 rwkv笔记 act笔记 nanovllm-block_manager opencode多智能体 nanobot-pre-train nanobot-rl nanobot-sft nanobot-checkpoint_manager nanobot-gpt nanobot-mid-train Vision Mamba (Vim)笔记 BPE演示 最后一遍学习Transformer YOLOv5 目标检测笔记 下载根服务器解析记录 Dynaseal A Backend-Controlled LLM API Key Distribution Scheme with Constrained Invocation Parameters 判断链表有环 王道25数据结构勘误 关于perplexity的open-sourcing-r1-1776 AI为什么不像人类一样进行多轮对话 新博客改造日记和功能测试 linuxqq只显示登陆背景图 数字设计和计算机体系结构(机械工业出版社)勘误(自制) Dynaseal:面向未来端侧llm agent的llm api key分发机制 A Definitive Guide to Markdown Style This post is using MDX, Where you can embed JSX and Astro components RT-Patch学习 pydantic实现的LLM ReAct fastapi 和 uvicorn 设置监听 ipv6 pydantic+openai+json 控制大模型输出的最佳范式 解决 Matplotlib Scatter 不支持 Marker 列表的问题:mscatter 实现 roofline model zhipuAI接口兼容openai 在docker部署fastapi宝塔里使用nginx反代套上cloudflare获取请求的真实ip clion搭建libbpf-bootstrap开发环境 coze+coze-discord-proxy+ChatNextWebUI实现AI自由 安卓内核时间使用的是UTC时间 colab运行google最新开源模型Gemma Sora技术报告 视频生成模型作为世界模拟器 笔记 archlinux flutter开发踩坑 fastapi集成google auth登录 linux下NTFS磁盘报错输入输出错误 Venn-Abers 预测器 基于Venn-Abers预测器的系统日志异常检测方法_顾兆军 手机平板远程访问kvm虚拟机的windows phi-2弱智吧测评 poe的gemini pro或是百度开发 google gemini api使用 google gemini api申请 构建用于复杂数据处理的高效UDP服务器和客户端 matplotlib中文字体渲染 TruFor笔记和代码复现 深入分析:GitHub Trending 项目 "multipleWindow3dScene" pua大模型 ggml教程|mnist手写体识别量化推理 xgboost2.0最佳实践 xgboost使用GPU最佳实践 马踏棋盘 cloudlflare推理llama2 docker搭建elasticsearch并使用python连接 FreeU-文字生成图片的免费午餐笔记 使用xgboost的c接口推理模型 Archlinux使用CMake调用xgboost的c接口 m2cgen生成机器学习c语言推理代码 xgboost模型序列化存储并推理 speculative-sampling笔记 prompt2model笔记 RoboTAP笔记 自建obsidian同步服务 MediaPipe即将推出图像生成服务 Dual-Stream Diffusion Net for Text-to-Video Generation笔记 ViT在DDPM取代UNet(DiT) arch4edu搞崩了我的flutter LISA(推理分割)笔记 在终端绘制GPU显存使用曲线 GPTBot介绍 arch蓝牙无法连接 GPU部署llama-cpp-python(llama.cpp通用) 花式求GCD 使用llama构建一个蜜罐(前端) 使用llama构建一个蜜罐(后端) llama-cpp-python快速上手 快速上手llama2.c(更新版) Paper Gestalt笔记 DINO-v2笔记 快速上手llama2.c AnyDoor笔记 Archlinux安装scrcpy加载共享库出错 error while loading shared libraries:libusb-1.0.so.0:wrong ELF class:ELFCLASS32 npc_gzip笔记 python调用c++函数 Filesystem type ntfs3,ntfs not configured in kernel open_clip编码图像和文本 PicGo配置CloudflareR2图片储存 ArchlinuxGnome快捷键打开终端 clip-interrogator代码解析 GroundingDINO安装报错解决 2023华为鲲鹏畅想日暨西安高新国际会议中心零食午饭测评 RoboMaster开源仓库汇总(长期更新) 没有手都可以在腾讯云创建镜像
摄像机模型
About the Author StudyingLover · 2022-12-30 · via StudyingLover's Blog

摄像机模型

摄像机模型

本文是鲁鹏老师机器视觉课程的笔记

针孔模型与透镜

image.png

image.png

虚拟像平面是倒着的

image.png

image.png

y′f=yz  ⟹  y′=fyz\dfrac{y'}{f}=\dfrac{y}{z}\quad\implies y'=f\dfrac{y}{z}

x′f=xz  ⟹  x′=fxz\dfrac{x'}{f}=\dfrac{x}{z}\quad\implies x'=f\dfrac{x}{z} P=[xyz]→P′=[x′y′]P=\begin{bmatrix}x\\ y\\ z\end{bmatrix}\to P'=\begin{bmatrix}x'\\ y'\end{bmatrix}\quad\quad

{x′=fxZy′=fyZ\begin{cases}x'=f\dfrac{x}{Z}\\ y'=f\dfrac{y}{Z}\end{cases}

光圈尺寸

光圈偏大会导致场景模糊

光圈偏小会场景清晰,但偏暗 image.png

增加透镜

  • 透镜将多条光线聚焦到胶片上,增加了照片的亮度:
    • 所有平行于光轴的光线都会会聚到焦点,焦点到透镜中心的距离称为焦距
    • 穿过中心的光线的方向不发生改变

image.png 根据折射定律: f=R2(n−1)f=\frac{ {R} }{ {2}({n}-1)} ,RR 是透镜球面半径,nn是透镜折射系数

z′=f+z0{x′=z′xzy′=z′yzz'=f+z_0\quad\begin{cases}x'=z'\dfrac{x}{z}\\ y'=z'\dfrac{y}{z}\end{cases}

要是透镜不合适,则会发生失焦 image.png

透镜将光线聚焦到胶片上

  • 物体“聚焦”有特定距离
  • 景深

径向畸变

图像中所成的像发生形变

径向畸变:图像像素点以畸变中心为中心点,沿着径向产生的位置偏差,从而导致

image.png

枕形畸变:畸变像点相对于理想像点沿径向向外偏移,远离中心 桶形畸变:畸变像点相对于理想点沿径向向中心靠拢

摄像机几何

齐次坐标

E→HE\to H 图像点的齐次坐标(x,y)⇒[xy1]\text{}(x,y)\Rightarrow\left[\begin{array}{c}x\\ y\\ 1\end{array}\right]

空间点的齐次坐标(x,y,z)⇒[xyz1](x,y,z)\Rightarrow\left[\begin{array}{c}x\\ y\\ z\\ 1\end{array}\right]

H→EH \to E [xyw]⇒(x/w,y/w)\left[\begin{array}{c}x\\ y\\ w\end{array}\right]\Rightarrow\left(x/w,y/w\right)

[xyzw]⇒(x/w,y/w,z/w)\left[\begin{array}{c}x\\ y\\ z\\ w\end{array}\right]\Rightarrow\left(x/w,y/w,z/w\right)

H→EH \to E 的转变不是唯一的,但E→HE \to H 的转变是唯一的

像素坐标系

建立像平面到像素平面关系

  1. 偏置

image.png

image.png

(x,y,z)→(fxz+cx,fyz+cy)(x,y,z)\to(f\dfrac{x}{z}+c_x,f\dfrac{y}{z}+c_y)

  1. 单位变换 (x,y,z)→(fkxz+cx,flyz+cy)(x,y,z)\to({fk}\frac{x}{z}+c_x,{fl}\frac{y}{z}+c_y) 单位:k.l:pixel/m , f:m k表示竖直方向上多少米表示一个像素,l表示水平方向上多少米表示一个像素

fkfkα\alpha ,flflβ\beta P=(x,y,z)→P′=(αxz+cx,βyz+cy)P=(x,y,z)\rightarrow P^{\prime}=\left(\alpha{\frac{x}{z} }+c_{x},\beta{\frac{y}{z} }+c_{y}\right) ,这里的cx,cyc_x,c_y是像素上的偏置

P=(x,y,z)→P′=(αxz+cx,βyz+cy)P=(x,y,z)\rightarrow P^{\prime}=\left(\alpha{\frac{x}{z} }+c_{x},\beta{\frac{y}{z} }+c_{y}\right)是非线性变换

在齐次坐标系下 Ph′=[αx+cxzβy+cyzz]=[α0cx00βcy00010][xyz1]P_h'=\begin{bmatrix}\alpha x+c_x z\\ \beta y+c_yz\\ z\end{bmatrix}=\begin{bmatrix}\alpha&0&c_x&0\\ 0&\beta&c_y&0\\ 0&0&1&0\end{bmatrix}\begin{bmatrix}x\\y\\z\\1\end{bmatrix}

Ph′→P′=(αxz+cx,βyz+cy)P'_h\to P'=(\alpha\dfrac{x}{z}+c_x,\beta\dfrac{y}{z}+c_y)

Ph′P'_h是齐次,P′P' 是欧式

摄像机的投影矩阵

image.png

P′=[α0cx00βcy00010][xyz1]=MPP'=\begin{bmatrix}\alpha&0&c_x&0\\ 0&\beta&c_y&0\\ 0&0&1&0\end{bmatrix}\begin{bmatrix}x\\ y\\ z\\ 1\end{bmatrix}=MP

其中M=[α−αcot⁡θcx00βsinθcy00010]M=\begin{bmatrix}\alpha&-\alpha\cot\theta&c_x&0\\ 0&\dfrac{\beta}{sin\theta}&c_y&0\\ 0&0&1&0\end{bmatrix}

此时PPP′P' 是线性表示 P′P'3∗13*1矩阵,PP4∗14*1矩阵

摄像机偏斜

image.png P′=[α−αcot⁡θcx00βsinθcy00010][xyz1]P'=\begin{bmatrix}\alpha&-\alpha\cot\theta&c_x&0\\ 0&\frac{\beta}{sin\theta}&c_y&0\\ 0&0&1&0\end{bmatrix}\begin{bmatrix}x\\ y\\ z\\ 1\end{bmatrix}

摄像机坐标系下的摄像机模型

P′=[α−αcot⁡θcx00βsinθcy00010][xyz1]=MPP'=\begin{bmatrix}\alpha&-\alpha\cot\theta&c_x&0\\ 0&\frac{\beta}{sin\theta}&c_y&0\\ 0&0&1&0\end{bmatrix}\begin{bmatrix}x\\ y\\ z\\ 1\end{bmatrix}=MP

M=[α−αcot⁡θcx00βsinθcy00010]M=\begin{bmatrix}\alpha&-\alpha\cot\theta&c_x&0\\ 0&\frac{\beta}{sin\theta}&c_y&0\\ 0&0&1&0\end{bmatrix}被称为投影矩阵,

K=[α−αcot⁡θcx0βsinθcy001]K=\begin{bmatrix}\alpha&-\alpha\cot\theta&c_x\\ 0&\frac{\beta}{sin\theta}&c_y\\ 0&0&1\end{bmatrix} 被称为摄像机内参数矩阵,内参数矩阵决定了摄像机坐标系下空间点到图像点的映射

摄像机内参数为α,β,cx,cy,θ\alpha,\beta,c_x,c_y,\theta,K有五个自由度

规范化投影变换

P′=[xyz]=[100001000010][xyz1]P'=\begin{bmatrix}x\\ y\\ z\end{bmatrix}=\begin{bmatrix}1&0&0&0\\ 0&1&0&0\\ 0&0&1&0\end{bmatrix}\begin{bmatrix}x\\ y\\ z\\ 1\end{bmatrix}

已知摄像机矩阵MM , P′=I(MP)P'=I(MP),I=[100010001]I=\begin{bmatrix}1&0&0\\ 0&1&0\\ 0&0&1\end{bmatrix}

ℜ4→Hℜ3P′=MP\begin{array}{c}\Re^4\xrightarrow{H}\Re^3\\ \boldsymbol{P'}=M\boldsymbol{P}\end{array}

PP 的欧式坐标[xzyz]\left[\begin{array}{c}{ {\frac{x}{z} }}\\ { {\frac{y}{z} }}\\ \end{array}\right]

世界坐标系

image.png

OwO_w 为世界坐标系 OO摄像机坐标系,C′C'像平面坐标系

齐次坐标系P=[RT01]PwP=\left[\begin{matrix}{R}&{T}\\ {0}&{1}\\ \end{matrix}\right]\boldsymbol{P}_{w} , [xwywzw1]\begin{bmatrix}x_w\\ y_w\\ z_w\\ 1\end{bmatrix} ,即摄像机坐标系是世界坐标系经过一个旋转,再经过一个平移得到的

世界坐标系下Pw=RT(P−T)P_w=R^T(P-T)

从世界坐标系到像素坐标系P′=K[I0]P=K[I0][RT01]Pw=K[RT]Pw=MPw=[m1m2m3]PwP'=K[I\quad0]P=K[I\quad0]\begin{bmatrix}R&T\\ 0&1\end{bmatrix}P_w=K[R\quad T]P_w=MP_w=\left[{\begin{matrix}{m_{1} }\\ {m_{2} }\\ {m_{3} }\end{matrix} }\right]P_{\mathrm{w} } [RT]\begin{bmatrix}R & T\end{bmatrix}称为外参数矩阵,K是内参数,这就是完整的摄像机模型

MM 称为投影矩阵,有11个自由度

摄像机O点坐标为−RTT-R^TT

[m1m2m3]Pw\left[{\begin{matrix}{m_{1} }\\ {m_{2} }\\ {m_{3} }\end{matrix} }\right]P_{\mathrm{w} } 是转换为欧式坐标系的写法,mim_i 是一个1∗41*4 的矩阵

image.png

投影变化的性质

  1. 点投影为点
  2. 线投影为线
  3. 近大远小
  4. 角度不再保持
  5. 平行线相交

其他摄像机模型

透视投影摄像机

^b240bc

image.png

P3×1′=MPW=K3×3[RT]3×4PW4×1=[m1m2m3]Pw=[m1Pwm2Pwm3Pw]⟶E(m1Pwm3Pw,m2Pwm3Pw),M=[m1m2m3]P'_{3\times1}=MP_W=K_{3\times3}[R\quad T]_{3\times4}P_{W4\times1}=\begin{bmatrix}m_1\\ m_2\\ m_3\end{bmatrix}P_w=\begin{bmatrix}m_1P_w\\ m_2P_w\\ m_3P_w\end{bmatrix}\stackrel{E}{\longrightarrow}(\dfrac{m_1P_w}{m_3P_w},\dfrac{m_2P_w}{m_3P_w})\quad,M=\begin{bmatrix}m_1\\ m_2\\ m_3\end{bmatrix}

弱透视投影摄像机

image.png

{x′=f′zxy′=f′zy→{x′=f′z0xy′=fz0y\begin{cases}x'=\dfrac{f'}{z}x\\ y'=\dfrac{f'}{z}y\end{cases}\rightarrow\begin{cases}x'=\dfrac{f'}{z_0}x\\ y'=\dfrac{f}{z_0}y\end{cases}

从投影(透视)到弱透视M=K[RT]=[A2×3b2×1v1×21]→M=[Ab01]M=K[RT]=\begin{bmatrix}A_{2\times3}&b_{2\times1}\\ v_{1\times2}&1\end{bmatrix}\quad\to M=\begin{bmatrix}A&b\\ 0&1\end{bmatrix}\quad

P′=MPw=[m1m2m3]Pw=[m1Pwm2Pw1]⟶E(m1PW,m2Pw)P'=MP_w=\begin{bmatrix}m_1\\ m_2\\ m_3\end{bmatrix}P_w=\begin{bmatrix}m_1P_w\\ m_2P_w\\ 1\end{bmatrix}\stackrel{E}{\longrightarrow}\left(m_{1}P_{W},m_{2}P_{w}\right) ,m1,m2m_1,m_2 为放大率

M=[Abv1]=[m1m2m3]=[m1m20001]M=\begin{bmatrix}A&b\\ v&1\end{bmatrix}=\begin{bmatrix}m_1\\ m_2\\ m_3\end{bmatrix}=\begin{bmatrix}&m_1&\\ &m_2&\\ 0&0&0&1\end{bmatrix}

正交投影摄像机

image.png

{x′=f′zxy′=f′zy→{x′=xy′=y\begin{cases}x'=\dfrac{f'}{z}x\\ y'=\dfrac{f'}{z}y\end{cases}\quad\to\quad\begin{cases}x'=x\\ y'=y\end{cases}

各种摄像机模型的应用场合

  • 正交投影
    • 更多应用在建筑设计(AUTOCAD)或者工业设计行业
  • 弱透视投影在数学方面更简单
    • 当物体较小且较远时准确,常用于图像识别任务
  • 透视投影对于3D到2D映射的建模更为准确
    • 用于运动恢复结构或SLAM