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.

Owner
KazuhitoTakahashi
KazuhitoTakahashi
2 telegram-bots: for image recognition and for text generation

💻 📱 Telegram_Bots 🔎 & 📖 2 telegram-bots: for image recognition and for text generation. About Image recognition bot: User sends a photo and bot de

Marina Polukoshko 1 Jan 27, 2022
Aloception is a set of package for computer vision: aloscene, alodataset, alonet.

Aloception is a set of package for computer vision: aloscene, alodataset, alonet.

Visual Behavior 86 Dec 28, 2022
Apply different text recognition services to images of handwritten documents.

Handprint The Handwritten Page Recognition Test is a command-line program that invokes HTR (handwritten text recognition) services on images of docume

Caltech Library 117 Jan 02, 2023
Optical character recognition for Japanese text, with the main focus being Japanese manga

Manga OCR Optical character recognition for Japanese text, with the main focus being Japanese manga. It uses a custom end-to-end model built with Tran

Maciej Budyś 327 Jan 01, 2023
This repository contains codes on how to handle mouse event using OpenCV

Handling-Mouse-Click-Events-Using-OpenCV This repository contains codes on how t

Happy N. Monday 3 Feb 15, 2022
A simple Digits Recogniser made in Python

⭐ Python Digit Recogniser A simple digit Recogniser made in Python Demo Run Locally Clone the project git clone https://github.com/yashraj-n/python-

Yashraj narke 4 Nov 29, 2021
Official code for :rocket: Unsupervised Change Detection of Extreme Events Using ML On-Board :rocket:

RaVAEn The RaVÆn system We introduce the RaVÆn system, a lightweight, unsupervised approach for change detection in satellite data based on Variationa

SpaceML 35 Jan 05, 2023
Erosion and dialation using structure element in OpenCV python

Erosion and dialation using structure element in OpenCV python

Tamzid hasan 2 Nov 11, 2021
Script para controlar o movimento do mouse usando Python e openCV com câmera em tempo real que detecta pontos de referência da mão, rastreia padrões de gestos em vez de um mouse físico.

mouserController Script para controlar o movimento do mouse usando Python e openCV com câmera em tempo real que detecta pontos de referência da mão, r

Vinícius Azevedo 6 Jun 28, 2022
Discord QR Scam Code Generator + Token grab mobile device.

A Python script that automatically generates a Nitro scam QR code and grabs the Discord token when scanned.

Visual 9 Nov 22, 2022
Qrcode Attendence System with Opencv and Pyzbar

Setup process Creates a virtual environment (Scripts that ensure executed Python code uses the Python interpreter and site packages installed inside t

Ganesh 5 Aug 01, 2022
A python screen recorder for low-end computers, provides high quality video output.

RecorderX - v1.0 A screen recorder made in Python with the help of OpenCv, it has ability to record your screen in high quality. No matter what your P

Priyanshu Jindal 4 Nov 10, 2021
Controlling the computer volume with your hands // OpenCV

HandsControll-AI Controlling the computer volume with your hands // OpenCV Step 1 git clone https://github.com/Hayk-21/HandsControll-AI.git pip instal

Hayk 1 Nov 04, 2021
Automatically resolve RidderMaster based on TensorFlow & OpenCV

AutoRiddleMaster Automatically resolve RidderMaster based on TensorFlow & OpenCV 基于 TensorFlow 和 OpenCV 实现的全自动化解御迷士小马谜题 Demo How to use Deploy the ser

神龙章轩 5 Nov 19, 2021
Links to awesome OCR projects

Awesome OCR This list contains links to great software tools and libraries and literature related to Optical Character Recognition (OCR). Contribution

Konstantin Baierer 2.2k Jan 02, 2023
The Open Source Framework for Machine Vision

SimpleCV Quick Links: About Installation [Docker] (#docker) Ubuntu Virtual Environment Arch Linux Fedora MacOS Windows Raspberry Pi SimpleCV Shell Vid

Sight Machine 2.6k Dec 31, 2022
Learning Camera Localization via Dense Scene Matching, CVPR2021

This repository contains code of our CVPR 2021 paper - "Learning Camera Localization via Dense Scene Matching" by Shitao Tang, Chengzhou Tang, Rui Hua

tangshitao 65 Dec 01, 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 06, 2022
A synthetic data generator for text recognition

TextRecognitionDataGenerator A synthetic data generator for text recognition What is it for? Generating text image samples to train an OCR software. N

Edouard Belval 2.5k Jan 04, 2023
Code for the "Sensing leg movement enhances wearable monitoring of energy expenditure" paper.

EnergyExpenditure Code for the "Sensing leg movement enhances wearable monitoring of energy expenditure" paper. Additional data for replicating this s

Patrick S 42 Oct 26, 2022