# 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
MarcoPage
- 粉丝: 4389
- 资源: 8837
最新资源
- 1791-2022美国警察警犬死亡数据.zip
- Python实现新年倒计时与祝福小程序
- 数据结构:链表及其Python实现与应用详解
- C#基于海康视觉VM4.1的二次开发框架源码,有多流程框架 运动控制卡 服务框架 需要有海康VM的基础并且有海康威视VM开发狗
- PCB板在线式自动贴条码标签设备工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- EPSON机械手跟相机搭配走tcp ip协议,及跟plc通讯将手动操作部分映射到触摸屏
- 通过爬虫获得各个地方的天气
- HTML与CSS实现的圣诞树网页代码
- ASME美国机械工程师协会论文模板
- 基于MapReduce实现好友推荐
- 基于springboot的考编论坛网站.zip
- 使用Python控制台代码创建圣诞树
- 2024年5-8月全国住宅房价.zip
- stm32 IAP升级 OTA升级 野外设备远程升级 自建FTP服务器升级 多App备份 切,防变砖 芯片 stm32f103系列 4G模块 EC200T 程序简介:一个bootloader程序
- 保压治具通用设备3D图纸和工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
- S260三辊研磨机3D图纸和工程图机械结构设计图纸和其它技术资料和技术方案非常好100%好用.zip
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈