摄像头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. goloader - golang动态加载的实现

    github地址:https://github.com/dearplain/goloader 这里有以前的一些思路:http://www.cnblogs.com/dearplain/p/8145985 ...

  2. 硬件篇-04-SLAM移动底盘机械设计

    这篇比较水,发出来主要是为了呼应专栏主题,既然是实现,那各个方面都得讲一下不是.   底盘SW模型   淘的,主要是看上了它有弹簧阻尼器,适合野外,抗震,但是这种底盘结构转向起来比较吃力.是再有个全轮 ...

  3. Bootstrap自适应各种设备

    <!DOCTYPE html><html><head> <title>Bootstrap 实例 - 手机.平板电脑.台式电脑</title> ...

  4. hdu4585 STL水题

    题意:       成立少林寺,刚开始有一个大师,id是1,攻击力是10E,现在陆续来人,每个人有自己的id,和自己的攻击力,但是每一个新来的要和之前的和尚pk,他必须选择和他攻击力差值最小的那个,如 ...

  5. hdu3665 水最短路

    题意 :        从起点0开始,到达最近的那个是海边的城镇的距离.. 思路:       水的最短路,随你怎么写,dij,floyd,spfa..都行,只要你喜欢..我写的spfa好久不写了,复 ...

  6. XML和JSON数据格式

    目录 XML DTD(文档类型定义) DTD实体 JSON 使用python解析JSON数据 XML和JSON的区别 XML的优缺点 JSON的优缺点 XML和JSON都是web存储和传输过程中数据的 ...

  7. [CTF]摩斯电码

    摩尔斯电码 -----------转载 https://morse.supfree.net/ 摩尔斯电码定义了包括:英文字母A-Z(无大小写区分)十进制数字0-9,以及"?"&qu ...

  8. 【maven和jdk】报错:系统找不到指定的文件

    创建一个maven项目出错 问题描述 在idea.log出现如下错误(系统找不到指定的文件,但是不知道指定文件是什么) com.intellij.execution.process.ProcessNo ...

  9. layui的loading加载中

    var load = layer.load(1, { content: '数据加载中', shade: [0.4, '#393D49'], // time: 10 * 1000, success: f ...

  10. pytest用法---学习篇1

    一.pytest运行规则: pytest可以收集所有以test_*.py文件,Test开头的类,和以test_开头的函数和方法,都能识别成测试用例. 当然也可以改变这个的识别规则 二.常用参数 -k ...