OpenCVを用いたカメラキャリブレーションのサンプルです。2021/06/21時点でPython実装のある3種類(通常カメラ向け、魚眼レンズ向け(fisheyeモジュール)、全方位カメラ向け(omnidirモジュール))について用意しています。

Overview

OpenCV-CameraCalibration-Example

FishEyeCameraCalibration.mp4

OpenCVを用いたカメラキャリブレーションのサンプルです
2021/06/21時点でPython実装のある以下3種類について用意しています。

  • 通常カメラ向け
  • 魚眼レンズ向け(fisheyeモジュール)
  • 全方位カメラ向け(omnidirモジュール)
    全方位カメラは以下のような構造のカメラを想定しています。

    画像はWikipediaのOmnidirectional (360-degree) cameraから引用

Requirement

  • opencv-python 4.5.2.54 or later
  • opencv-contrib-python 4.5.2.54 or later ※omnidirモジュールを使用する場合のみ

Calibration Pattern

サンプルでは以下の7×10のチェスボード型のキャリブレーションパターンを使用します。

他の行列数のキャリブレーションパターンを使用したい場合は、以下を参照して作成or入手してください。

また、以下のようなサークル型のパターンやセクターベース型のパターンのサンプルは用意していません。

Usage

calibrateCameraのサンプルでキャリブレーションパラメータをcsvに保存し、
undistortのサンプルで歪み補正を実施してください。

01.calibrateCamera

python 01-01_calibrateCamera.py
python 02-01_fisheyeCalibrateCamera.py
python 03-01_omnidirCalibrateCamera.py

キャリブレーションパターン検出時にEnterを押すことで撮影します。
ESCを押すことでプログラムを終了し、キャリブレーションパラメータを保存します。

実行時には、以下のオプションが指定可能です。

オプション指定
  • --device
    カメラデバイス番号の指定
    デフォルト:
    • 01-01_calibrateCamera:0
    • 02-01_fisheyeCalibrateCamera.py:0
    • 03-01_omnidirCalibrateCamera.py:0
  • --file
    動画ファイル名の指定 ※指定時はカメラデバイスより優先し動画を読み込む
    デフォルト:
    • 01-01_calibrateCamera:None
    • 02-01_fisheyeCalibrateCamera.py:None
    • 03-01_omnidirCalibrateCamera.py:None
  • --width
    カメラキャプチャ時の横幅
    デフォルト:
    • 01-01_calibrateCamera:640
    • 02-01_fisheyeCalibrateCamera.py:640
    • 03-01_omnidirCalibrateCamera.py:640
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:
    • 01-01_calibrateCamera:360
    • 02-01_fisheyeCalibrateCamera.py:360
    • 03-01_omnidirCalibrateCamera.py:360
  • --square_len
    キャリブレーションパターン(チェスボード)の1辺の長さ(mm)
    デフォルト:
    • 01-01_calibrateCamera:23.0
    • 02-01_fisheyeCalibrateCamera.py:23.0
    • 03-01_omnidirCalibrateCamera.py:23.0
  • --square_len
    キャリブレーションパターン(チェスボード)の1辺の長さ(mm)
    デフォルト:
    • 01-01_calibrateCamera:23.0
    • 02-01_fisheyeCalibrateCamera.py:23.0
    • 03-01_omnidirCalibrateCamera.py:23.0
  • --grid_size
    キャリブレーションパターン(チェスボード)の行列数(カンマ区切り指定)
    デフォルト:
    • 01-01_calibrateCamera:10,7
    • 02-01_fisheyeCalibrateCamera.py:10,7
    • 03-01_omnidirCalibrateCamera.py:10,7
  • --k_filename
    半径方向の歪み係数の保存ファイル名(csv)
    デフォルト:
    • 01-01_calibrateCamera:K.csv
    • 02-01_fisheyeCalibrateCamera.py:K_fisheye.csv
    • 03-01_omnidirCalibrateCamera.py:K_omni.csv
  • --d_filename
    円周方向の歪み係数の保存ファイル名(csv)
    デフォルト:
    • 01-01_calibrateCamera:d.csv
    • 02-01_fisheyeCalibrateCamera.py:d_fisheye.csv
    • 03-01_omnidirCalibrateCamera.py:d_omni.csv
  • --xi_filename
    Mei'sモデルパラメータxiの保存ファイル名(csv)
    デフォルト:
    • 03-01_omnidirCalibrateCamera.py:xi_omni.csv
  • --use_autoappend
    キャリブレーションパターン検出時に自動で撮影するか否か(指定しない場合はEnterで明示的に撮影)
    デフォルト:
    • 01-01_calibrateCamera:指定なし
    • 02-01_fisheyeCalibrateCamera.py:指定なし
    • 03-01_omnidirCalibrateCamera.py:指定なし
  • --interval_time
    use_autoappend指定時の撮影間隔(ms)
    デフォルト:
    • 01-01_calibrateCamera:500
    • 02-01_fisheyeCalibrateCamera.py:500
    • 03-01_omnidirCalibrateCamera.py:500

02.undistort

python 01-02_undistort.py
python 02-02_fisheyeUndistort.py
python 03-02_omnidirUndistort.py

実行時には、以下のオプションが指定可能です。

オプション指定
  • --device
    カメラデバイス番号の指定
    デフォルト:
    • 01-01_calibrateCamera:0
    • 02-01_fisheyeCalibrateCamera.py:0
    • 03-01_omnidirCalibrateCamera.py:0
  • --file
    動画ファイル名の指定 ※指定時はカメラデバイスより優先し動画を読み込む
    デフォルト:
    • 01-01_calibrateCamera:None
    • 02-01_fisheyeCalibrateCamera.py:None
    • 03-01_omnidirCalibrateCamera.py:None
  • --width
    カメラキャプチャ時の横幅
    デフォルト:
    • 01-01_calibrateCamera:640
    • 02-01_fisheyeCalibrateCamera.py:640
    • 03-01_omnidirCalibrateCamera.py:640
  • --height
    カメラキャプチャ時の縦幅
    デフォルト:
    • 01-01_calibrateCamera:360
    • 02-01_fisheyeCalibrateCamera.py:360
    • 03-01_omnidirCalibrateCamera.py:360
  • --k_filename
    半径方向の歪み係数の読み込みファイル名(csv)
    デフォルト:
    • 01-01_calibrateCamera:K.csv
    • 02-01_fisheyeCalibrateCamera.py:K_fisheye.csv
    • 03-01_omnidirCalibrateCamera.py:K_omni.csv
  • --d_filename
    円周方向の歪み係数の読み込みファイル名(csv)
    デフォルト:
    • 01-01_calibrateCamera:d.csv
    • 02-01_fisheyeCalibrateCamera.py:d_fisheye.csv
    • 03-01_omnidirCalibrateCamera.py:d_omni.csv
  • --xi_filename
    Mei'sモデルパラメータxiの読み込みファイル名(csv)
    デフォルト:
    • 03-01_omnidirCalibrateCamera.py:xi_omni.csv
  • --k_new_param
    Knewパラメータ指定時のスケール
    デフォルト:
    • 01-01_calibrateCamera:1.0
    • 02-01_fisheyeCalibrateCamera.py:0.9
    • 03-01_omnidirCalibrateCamera.py:0.5

Reference

Author

高橋かずひと(https://twitter.com/KzhtTkhs)

License

OpenCV-CameraCalibration-Example is under Apache-2.0 License.

You might also like...
code for our ICCV 2021 paper
code for our ICCV 2021 paper "DeepCAD: A Deep Generative Network for Computer-Aided Design Models"

DeepCAD This repository provides source code for our paper: DeepCAD: A Deep Generative Network for Computer-Aided Design Models Rundi Wu, Chang Xiao,

[ICCV, 2021] Cloud Transformers: A Universal Approach To Point Cloud Processing Tasks

Cloud Transformers: A Universal Approach To Point Cloud Processing Tasks This is an official PyTorch code repository of the paper "Cloud Transformers:

Dataset and Code for ICCV 2021 paper
Dataset and Code for ICCV 2021 paper "Real-world Video Super-resolution: A Benchmark Dataset and A Decomposition based Learning Scheme"

Dataset and Code for RealVSR Real-world Video Super-resolution: A Benchmark Dataset and A Decomposition based Learning Scheme Xi Yang, Wangmeng Xiang,

An official PyTorch implementation of the paper "Learning by Aligning: Visible-Infrared Person Re-identification using Cross-Modal Correspondences", ICCV 2021.

PyTorch implementation of Learning by Aligning (ICCV 2021) This is an official PyTorch implementation of the paper "Learning by Aligning: Visible-Infr

APS 6º Semestre - UNIP (2021)
APS 6º Semestre - UNIP (2021)

UNIP - Universidade Paulista Ciência da Computação (CC) DESENVOLVIMENTO DE UM SISTEMA COMPUTACIONAL PARA ANÁLISE E CLASSIFICAÇÃO DE FORMAS Link do git

MediaPipeのPythonパッケージのサンプルです。2020/12/11時点でPython実装のある4機能(Hands、Pose、Face Mesh、Holistic)について用意しています。
MediaPipeのPythonパッケージのサンプルです。2020/12/11時点でPython実装のある4機能(Hands、Pose、Face Mesh、Holistic)について用意しています。

mediapipe-python-sample MediaPipeのPythonパッケージのサンプルです。 2020/12/11時点でPython実装のある以下4機能について用意しています。 Hands Pose Face Mesh Holistic Requirement mediapipe 0.

ProxyLogon Full Exploit Chain PoC (CVE-2021–26855, CVE-2021–26857, CVE-2021–26858, CVE-2021–27065)
ProxyLogon Full Exploit Chain PoC (CVE-2021–26855, CVE-2021–26857, CVE-2021–26858, CVE-2021–27065)

ExProlog ProxyLogon Full Exploit Chain PoC (CVE-2021–26855, CVE-2021–26857, CVE-2021–26858, CVE-2021–27065) Usage: exprolog.py [OPTIONS] ExProlog -

ProxyLogon(CVE-2021-26855+CVE-2021-27065) Exchange Server RCE(SSRF->GetWebShell)
ProxyLogon(CVE-2021-26855+CVE-2021-27065) Exchange Server RCE(SSRF-GetWebShell)

ProxyLogon For Python3 ProxyLogon(CVE-2021-26855+CVE-2021-27065) Exchange Server RCE(SSRF-GetWebShell) usage: python ProxyLogon.py --host=exchang

git git《Transformer Meets Tracker: Exploiting Temporal Context for Robust Visual Tracking》(CVPR 2021) GitHub:git2] 《Masksembles for Uncertainty Estimation》(CVPR 2021) GitHub:git3]
git git《Transformer Meets Tracker: Exploiting Temporal Context for Robust Visual Tracking》(CVPR 2021) GitHub:git2] 《Masksembles for Uncertainty Estimation》(CVPR 2021) GitHub:git3]

Transformer Meets Tracker: Exploiting Temporal Context for Robust Visual Tracking Ning Wang, Wengang Zhou, Jie Wang, and Houqiang Li Accepted by CVPR

Python implementation for PrintNightmare (CVE-2021-1675 / CVE-2021-34527) using standard Impacket.

PrintNightmare Python implementation for PrintNightmare (CVE-2021-1675 / CVE-2021-34527) using standard Impacket. Installtion $ pip3 install impacket

Code of the lileonardo team for the 2021 Emotion and Theme Recognition in Music task of MediaEval 2021

Emotion and Theme Recognition in Music The repository contains code for the submission of the lileonardo team to the 2021 Emotion and Theme Recognitio

Exploiting CVE-2021-42278 and CVE-2021-42287 to impersonate DA from standard domain user

Exploiting CVE-2021-42278 and CVE-2021-42287 to impersonate DA from standard domain user Known issues it will not work outside kali , i will update it

Exploiting CVE-2021-42278 and CVE-2021-42287

noPac Exploiting CVE-2021-42278 and CVE-2021-42287 原项目noPac在实现上可能有点问题,导致在本地没有打通,于是参考sam-the-admin项目进行修改。 使用 pip3 install -r requirements.txt # GetShel

Exploiting CVE-2021-42278 and CVE-2021-42287 to impersonate DA from standard domain user
Exploiting CVE-2021-42278 and CVE-2021-42287 to impersonate DA from standard domain user

About Exploiting CVE-2021-42278 and CVE-2021-42287 to impersonate DA from standard domain user Changed from sam-the-admin. Usage SAM THE ADMIN CVE-202

Details,PoC and patches for CVE-2021-45383 & CVE-2021-45384

CVE-2021-45383 & CVE-2021-45384 There are several network-layer vulnerabilities in the official server of Minecraft: Bedrock Edition (aka Bedrock Serv

Implementation of Geometric Vector Perceptron, a simple circuit for 3d rotation equivariance for learning over large biomolecules, in Pytorch. Idea proposed and accepted at ICLR 2021
Implementation of Geometric Vector Perceptron, a simple circuit for 3d rotation equivariance for learning over large biomolecules, in Pytorch. Idea proposed and accepted at ICLR 2021

Geometric Vector Perceptron Implementation of Geometric Vector Perceptron, a simple circuit with 3d rotation equivariance for learning over large biom

:hot_pepper: R²SQL: "Dynamic Hybrid Relation Network for Cross-Domain Context-Dependent Semantic Parsing." (AAAI 2021)

R²SQL The PyTorch implementation of paper Dynamic Hybrid Relation Network for Cross-Domain Context-Dependent Semantic Parsing. (AAAI 2021) Requirement

[ICLR 2021] "Neural Architecture Search on ImageNet in Four GPU Hours: A Theoretically Inspired Perspective" by Wuyang Chen, Xinyu Gong, Zhangyang Wang

Neural Architecture Search on ImageNet in Four GPU Hours: A Theoretically Inspired Perspective [PDF] Wuyang Chen, Xinyu Gong, Zhangyang Wang In ICLR 2

The official implementation of NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021].  https://arxiv.org/pdf/2101.12378.pdf
The official implementation of NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021]. https://arxiv.org/pdf/2101.12378.pdf

NeMo: Neural Mesh Models of Contrastive Features for Robust 3D Pose Estimation [ICLR-2021] Release Notes The offical PyTorch implementation of NeMo, p

Owner
KazuhitoTakahashi
KazuhitoTakahashi
Official implementation of "An Image is Worth 16x16 Words, What is a Video Worth?" (2021 paper)

An Image is Worth 16x16 Words, What is a Video Worth? paper Official PyTorch Implementation Gilad Sharir, Asaf Noy, Lihi Zelnik-Manor DAMO Academy, Al

null 213 Nov 12, 2022
Code for AAAI 2021 paper: Sequential End-to-end Network for Efficient Person Search

This repository hosts the source code of our paper: [AAAI 2021]Sequential End-to-end Network for Efficient Person Search. SeqNet achieves the state-of

Zj Li 218 Dec 31, 2022
CVPR 2021 Oral paper "LED2-Net: Monocular 360˚ Layout Estimation via Differentiable Depth Rendering" official PyTorch implementation.

LED2-Net This is PyTorch implementation of our CVPR 2021 Oral paper "LED2-Net: Monocular 360˚ Layout Estimation via Differentiable Depth Rendering". Y

Fu-En Wang 83 Jan 4, 2023
(CVPR 2021) Back-tracing Representative Points for Voting-based 3D Object Detection in Point Clouds

BRNet Introduction This is a release of the code of our paper Back-tracing Representative Points for Voting-based 3D Object Detection in Point Clouds,

null 86 Oct 5, 2022
Scale-aware Automatic Augmentation for Object Detection (CVPR 2021)

SA-AutoAug Scale-aware Automatic Augmentation for Object Detection Yukang Chen, Yanwei Li, Tao Kong, Lu Qi, Ruihang Chu, Lei Li, Jiaya Jia [Paper] [Bi

Jia Research Lab 182 Dec 29, 2022
(CVPR 2021) ST3D: Self-training for Unsupervised Domain Adaptation on 3D Object Detection

ST3D Code release for the paper ST3D: Self-training for Unsupervised Domain Adaptation on 3D Object Detection, CVPR 2021 Authors: Jihan Yang*, Shaoshu

CVMI Lab 224 Dec 28, 2022
Distilling Knowledge via Knowledge Review, CVPR 2021

ReviewKD Distilling Knowledge via Knowledge Review Pengguang Chen, Shu Liu, Hengshuang Zhao, Jiaya Jia This project provides an implementation for the

DV Lab 194 Dec 28, 2022
QuanTaichi: A Compiler for Quantized Simulations (SIGGRAPH 2021)

QuanTaichi: A Compiler for Quantized Simulations (SIGGRAPH 2021) Yuanming Hu, Jiafeng Liu, Xuanda Yang, Mingkuan Xu, Ye Kuang, Weiwei Xu, Qiang Dai, W

Taichi Developers 119 Dec 2, 2022
SceneCollisionNet This repo contains the code for "Object Rearrangement Using Learned Implicit Collision Functions", an ICRA 2021 paper. For more info

SceneCollisionNet This repo contains the code for "Object Rearrangement Using Learned Implicit Collision Functions", an ICRA 2021 paper. For more info

NVIDIA Research Projects 31 Nov 22, 2022
Code for the head detector (HeadHunter) proposed in our CVPR 2021 paper Tracking Pedestrian Heads in Dense Crowd.

Head Detector Code for the head detector (HeadHunter) proposed in our CVPR 2021 paper Tracking Pedestrian Heads in Dense Crowd. The head_detection mod

Ramana Subramanyam 76 Dec 6, 2022