# camera_calibration_tool
camera_calibration_tool is used to easily calibrate and rectify camera using
opencv-python.
With only one line of command, you can get parameters of your
camera or rectify your video.
It is similar with calibration package of ROS.
# Content
* [camera_calibration_tool](#camera_calibration_tool)
* [Content](#content)
* [Usage](#usage)
* [Calibration](#calibration)
* [Rectify video](#rectify-video)
* [Rectify camera](#rectify-camera)
* [Command line parameters](#command-line-parameters)
# Requirement
This code works well in the following environment:
Ubuntu: 16.04
Python: 3.5.2
OpenCV: 3.2.0
Package requirement:
- glob
- numpy
- xml
# Usage
This code can be used to calculate matrix and distortion coefficients
of your camera, and rectify video/camera with these parameters.
## Calibration
1. Prepare more than 10 images of chessboard photoed by your camera
in different position and direction.
2. Be sure they are in the format of 'JPG' or 'jpg' or 'png'.
(They are better to be in the same format, because I do not know
if it will work or not.)
3. Put them in a folder named `chess` which should be in the same
directory as `calibration.py`.
4. Run Terminal in current directory:
```
python3 calibration.py --image_size 1920x1080 --mode calibrate --corner 8x6 --square 20
```
**Replace the value according to your camera and chessboard.**
Your camera parameters will saved in a xml file named `camera_params.xml`.
## Rectify video
If you have already calibrated your camera and saved params in `camera_params.xml`, then
run:
```
python3 calibration.py --image_size 1920x1080 --mode rectify --video_path test.mp4
```
**Replace the value according to your video. Only `mp4` and `avi` are tested.
Not sure about other format.**
**NOTE: image_size should be the same with chessboard images you used to calibrate.**
## Rectify camera
To rectify camera, run:
```
python3 calibration.py --image_size 1920x1080 --mode rectify --camera_id 0
```
**Replace the value according to your camera.**
**NOTE: image_size should be the same with chessboard images you used to calibrate.**
It will show the origin and rectified images of your camera.
# Command line parameters
All the parameters and their actions are listed here:
```
python3 calibration.py [option] [value]
```
option|type|help|example
------|----|----|------------|
--image_size|str|width and height of image|1920x1080
--mode|str|to calibrate or rectify| choose from calibrate/rectify
--square|int|length of chessboard square(Necessary when calibrating)|20
--corner|str|width*height of chessboard corner(Necessary when calibrating)|8x6
--video_path|str|path of video need to rectify|./test.mp4
--camera_id|int|usb camera id|0
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
相机标定 【作品名称】:基于OpenCV-Python 相机标定及矫正,张正友相机标定法 【适用人群】:适用于希望学习不同技术领域的小白或进阶学习者。可作为毕设项目、课程设计、大作业、工程实训或初期项目立项。 【项目介绍】: Prepare more than 10 images of chessboard photoed by your camera in different position and direction. Be sure they are in the format of 'JPG' or 'jpg' or 'png'. (They are better to be in the same format, because I do not know if it will work or not.) Put them in a folder named chess which should be in the same directory as calibration.py. Run Terminal in current directory:
资源推荐
资源详情
资源评论
收起资源包目录
camera_calibration_tool.zip (16个子文件)
camera_calibration_tool
camera_params.xml 879B
.DS_Store 6KB
calibration.py 10KB
chess
chess (7).JPG 208KB
chess (8).JPG 224KB
chess (11).JPG 160KB
chess (5).JPG 189KB
chess (4).JPG 241KB
chess (10).JPG 246KB
chess (6).JPG 206KB
chess (0).JPG 189KB
chess (3).JPG 168KB
chess (1).JPG 242KB
chess (2).JPG 207KB
chess (9).JPG 197KB
README.md 3KB
共 16 条
- 1
资源评论
MarcoPage
- 粉丝: 4303
- 资源: 8839
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功