摄像头Camera 标定Calibration原理Theory

cv2.cameraCalibration

Pinhole camera calibration calls camera vision from 3D objects in the real world and transforms them into a 2D image.

摄像头标定这里指利用常规(小孔成像)摄像头观察真实三位物体对二维图像的矫正转换。

We named points from objects as objects point and points in image as image points.

3D的点被叫做物体点,而2D的图像点被叫做图像点。

To calibrate camera, we need to undistort radial distortion and tangential distortion.

Radial Distortion: Radial Distortion is the most common type that affects the images, In which when a camera captured pictures of straight lines appeared slightly curved or bent.

Tangential distortion: Tangential distortion occurs mainly because the lens is not parallely aligned to the imaging plane, that makes the image to be extended a little while longer or tilted, it makes the objects appear farther away or even closer than they actually are.

摄像头标定矫正主要解决径向畸变和切向畸变。

径向畸变是图像像素点以畸变中心为中心点,沿着径向产生的位置偏差,从而导致图像中所成的像发生形变。

图像径向畸变是成像过程中最主要的畸变,同时也是对成像效果影响最大的畸变,广角或者鱼眼的畸变效果,

矫正算法采用多项式拟合:

切向畸变,这是由于透镜与成像平面不可能绝对平行造成的。

这种畸变会造成图像中的某些点看上去的位置会比我们认为的位置要近一些。

Five Distortion Coefficients 五个畸变系数:

In math, the Transformation from 3D object points, P of X, Y and Z to X and Y is done by a transformative matrix called the camera matrix(C), we’ll be using this to calibrate the camera.

max = 摄像机矩阵 = 摄像机的内部参数(焦距和光学中心)

内部参数是摄像机本身具有的,包括的信息有焦距(f x ,f y ),光学中心(c x ,c y )。

dist = 外部参数(旋转和变换向量)

外部参数与旋转和变换向量相对应,它可以将 3D 点的坐标转换到坐标系统中。

It’s recommended to use at least 20 images to get a reliable calibration, For this, we have a lot of images here, each chess board has eight by six corners to detect

于是必须要提供一些包含明显图案模式的样本棋盘图片,一般至少需要 10 个(部分中文资料)建议20个这样的图案模式。

or

where

(X, Y, Z) are the coordinates of a 3D point in the world coordinate space

(u, v) are the coordinates of the projection point in pixels

A is a camera matrix, or a matrix of intrinsic parameters

(cx, cy) is a principal point that is usually at the image center

fx, fy are the focal lengths expressed in pixel units.

A chessboard is great for calibration because it's regular, high contrast pattern makes it easy to detect automatically. And we know how an undistorted flat chessboard looks like. So, if we use our camera to take pictures of Chessboard at different angles

棋盘主要是通过角点来计算畸变,

import numpy as np

import cv2, glob

calibrate_source_path = './data/camera_cal/*.jpg'

calibrate_test_path = './data/test_image.jpg'

# define

objpoints = []

imgpoints = []

nx = 8

ny = 6

objp = np.zeros((ny*nx,3),np.float32)

objp[:,:2] = np.mgrid[0:nx,0:ny].T.reshape(-1,2)

# chessboard

for path in glob.glob(calibrate_source_path):

gray = cv2.cvtColor(cv2.imread(path),cv2.COLOR_BGR2GRAY)

ret,corners = cv2.findChessboardCorners(gray,(nx,ny))

if ret:

objpoints.append(objp)

imgpoints.append(corners);

# gray = cv2.drawChessboardCorners(gray, (nx,ny), corners, ret)

# execute

img = cv2.imread(calibrate_test_path)

ret, mtx, dist, rvecs, tvecs = cv2.calibrateCamera(objpoints, imgpoints, img.shape[1:], None, None)

dst = cv2.undistort(img, mtx, dist, None, mtx)

# display

cv2.imshow(None, cv2.pyrDown(np.hstack((img,dst))))

cv2.waitKey(0); cv2.destroyAllWindows()

摄像头Camera 标定Calibration原理Theory的更多相关文章

  1. Android中直播视频技术探究之---采集摄像头Camera视频源数据进行推流(采用金山云SDK)

    一.前言 在之前已经详细介绍了Android中的一种视频数据源:Camera,不了解的同学可以点击进入:Android中Camera使用详解 ,在这篇文章中我们介绍了如何采集摄像头的每一帧数据,然后进 ...

  2. Android中直播视频技术探究之---摄像头Camera视频源数据采集解析

    一.前言 在视频直播中一般都是两种视频数据源,一个是摄像头数据,一个是录制桌面数据,而一般来说美女妹子直播都是来自于摄像头数据,游戏直播都是录制桌面数据的,那么今天就来看看第一个数据源数据采集分析,A ...

  3. Camera Calibration 相机标定:原理简介(五)

    5 基于2D标定物的标定方法 基于2D标定物的标定方法,原理与基于3D标定物相同,只是通过相机对一个平面进行成像,就可得到相机的标定参数,由于标定物为平面,本身所具有的约束条机,相对后者标定更为简单. ...

  4. Camera Calibration 相机标定:原理简介(一)

    1 相机标定常见方法 广义来说,相机标定不单包括成像过程的几何关系标定,还包括辐射关系的标定,本文只探讨几何关系.相机标定是3D计算机视觉(Computer Vision)里从2D图像中提取量测信息的 ...

  5. Camera Calibration 相机标定:原理简介(四)

    4 基于3D标定物的标定方法 使用基于3D标定物进行相机标定,是一种传统且常见的相机标定法.3D标定物在不同应用场景下不尽相同,摄影测量学中,使用的3D标定物种类最为繁杂,如图-1的室内控制场,由多条 ...

  6. Camera Calibration 相机标定:原理简介(二)

    2 针孔相机模型 常见的相机标定中,使用的相机多为针孔相机(Pinhole camera),也就是大家熟知的小孔成像理论.将其中涉及的坐标系之间的相互转换抽离出来,即为针孔相机模型的核心. 上图所示的 ...

  7. Camera Calibration 相机标定:原理简介(三)

    3 绝对圆锥曲线 在进一步了解相机标定前,有必要了解绝对圆锥曲线(Absolute Conic)这一概念. 对于一个3D空间的点x,其投影空间的坐标为:x~=[x1,x2,x3,x4]T.我们定义无穷 ...

  8. android摄像头(camera)之 v4l2的c测试代码【转】

    转自:https://blog.csdn.net/ldswfun/article/details/8745577 在移植android hal的过程中,移植的首要任务是要确保驱动完好,camera是属 ...

  9. android摄像头(camera)之buffer管理

    一,V4L2驱动申请buffer 视频应用可以通过两种方式从V4L2驱动申请buffer 1. V4L2_MEMORY_USERPTR方式, 顾名思义是用户空间指针的意思,应用层负责分配需要的内存空间 ...

随机推荐

  1. 在Visual Studio 中使用git——使用git管理源代码(三)

    在Visual Studio 中使用git--什么是Git(一) 在Visual Studio 中使用git--给Visual Studio安装 git插件(二)   第三部分:使用git管理源代码 ...

  2. win 远程桌面 ubuntu

    开始 起因 因为工作需求经常要远程 局域网内的 Ubuntu设备 之前用的一直是 Teamviver 但是最近不知怎么了,Teamviver发病 打不开了,也懒得折腾了! 简单的记录一下 能用的几种连 ...

  3. 【Feign/Ribbon】记录一次生产上的SpringCloudFeign的重试问题

    在上周在的微供有数项目中(数据产品),需要对接企业微信中第三方应用,在使用Feign的去调用微服务的用户模块用微信的code获取access_token以及用户工厂信息时出现Feign重试超时报错的情 ...

  4. 阿里早期Android加固代码的实现分析

    本文博客地址:http://blog.csdn.net/qq1084283172/article/details/78320445 看雪上有作者(寒号鸟二代)将阿里移动早期的Android加固进行了逆 ...

  5. Google Hacking的用法

    目录 Google Hacking 基本搜索 高级搜索 Index of inurl Google Hacking Google Hacking 是利用谷歌搜索的强大,来在浩瀚的互联网中搜索到我们需要 ...

  6. C#-CMD

    private static string InvokeCmd(string cmdArgs) { string Tstr = ""; Process p = new Proces ...

  7. Window内核学习之保护模式基础

    段寄存器 段寄存器有6个分别是 cs,ss,ds,es,fs,gs.这些段寄存器包含16位的可见部分和80位的隐藏部分,共90位. 16位的可见部分就是我们知道的cs等段寄存器的值,我们可以在od中查 ...

  8. ecl函数的用法

    相关函数 fork, execle, execlp, execv, execve, execvp Windows下头文件 #include <process.h> Linux下头文件 #i ...

  9. PHPcms v9.6.0 文件上传漏洞

    title: PHPcms v9.6.0 文件上传漏洞 date: 2021-4-5 tags: 渗透测试,CVE漏洞复现,文件上传 categories: 渗透测试 CVE漏洞复现 文件上传 PHP ...

  10. ssh-的搭建和使用

    ssh的作用 : 可实现远程客户端登录服务器并对服务器的文件进行操作 ssh服务器的安装 farsight@ubuntu:~$ sudo apt-get install openssh-server ...