{"id":13584893,"url":"https://github.com/smidm/video2calibration","last_synced_at":"2026-03-08T17:39:02.418Z","repository":{"id":41675598,"uuid":"41801406","full_name":"smidm/video2calibration","owner":"smidm","description":"Camera intrinsic parameters calibration from chessboard video sequence.","archived":false,"fork":false,"pushed_at":"2022-07-21T05:47:39.000Z","size":41124,"stargazers_count":139,"open_issues_count":0,"forks_count":67,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-01T17:16:49.976Z","etag":null,"topics":["camera-calibration","opencv","video"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/smidm.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-02T13:04:56.000Z","updated_at":"2025-03-31T13:57:50.000Z","dependencies_parsed_at":"2022-08-10T09:20:18.916Z","dependency_job_id":null,"html_url":"https://github.com/smidm/video2calibration","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smidm%2Fvideo2calibration","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smidm%2Fvideo2calibration/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smidm%2Fvideo2calibration/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/smidm%2Fvideo2calibration/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/smidm","download_url":"https://codeload.github.com/smidm/video2calibration/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248045233,"owners_count":21038553,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["camera-calibration","opencv","video"],"created_at":"2024-08-01T15:04:35.305Z","updated_at":"2026-03-08T17:39:02.389Z","avatar_url":"https://github.com/smidm.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"[![Build Status](https://travis-ci.com/smidm/video2calibration.svg?branch=master)](https://travis-ci.com/smidm/video2calibration)\n\n\nCamera Calibration Using OpenCV\n===============================\n\nPython scripts for camera intrinsic parameters calibration and image undistortion.\n\nIt finds following parameters:\n\n  * focal length\n  * principal point\n  * radial distortion coefficients\n\nusing video of a moving chessboard pattern or a sequence of images as an input.\n\nExample input: \n\n![input video](doc/input_video.jpg \"Screenshot of an input video.\")\n\nExample output YAML file:\n\n~~~\ncamera_matrix:\n- [1016.5691777733053, 0.0, 632.3505845656954]\n- [0.0, 1013.9401023559311, 351.0453222243043]\n- [0.0, 0.0, 1.0]\ndist_coefs:\n- [-0.3797582960152331, 0.20896823985868346, -0.0003239082442461539, -0.0019027617884934114,\n  -0.0668551319250156]\nrms: 1.1814231691868478\n~~~\n\nInstallation\n------------\n\n```\npip install video2calibration\n```\n\nYou can also install the in-development version with::\n\n```\npip install https://github.com/smidm/video2calibration/archive/master.zip\n```\n\n\nCamera Calibration\n------------------\n\n 1. print the [pattern](pattern.png) without any distortions\n 2. check if the printed squares are correct squares\n 3. glue the pattern to a solid board\n 4. fix the camera lens zoom, the calibration values change with the lens zoom changes\n 5. record a video with the pattern moving in front of the camera\n    * the pattern should be most of the time completely visible\n    * try to move the pattern to cover all parts of the camera view, pay attention to the corners\n    * the length of the video should be 1 or 2 minutes\n 6. run the calibration.py to extract chessboard pattern corners from the video and perform camera calibration\n\nExample usage (you can actually run the example, the input data is present in the ./example_input):\n\n~~~\n$ calibrate.py --help\nusage: calibrate.py [-h] [--debug-dir DEBUG_DIR] [-c CORNERS] [-fs FRAMESTEP]\n                    input out\n\nCalibrate camera using a video of a chessboard or a sequence of images.\n\npositional arguments:\n  input                 input video file or glob mask\n  out                   output calibration yaml file\n\noptional arguments:\n  -h, --help            show this help message and exit\n  --debug-dir DEBUG_DIR\n                        path to directory where images with detected\n                        chessboard will be written\n  -c CORNERS, --corners CORNERS\n                        output corners file\n  -fs FRAMESTEP, --framestep FRAMESTEP\n                        use every nth frame in the video\n\n\n$ mkdir out\n$ calibrate.py example_input/chessboard.avi calibration.yaml --debug-dir out\nSearching for chessboard in frame 0... not found\nSearching for chessboard in frame 20... not found\nSearching for chessboard in frame 40... not found\nSearching for chessboard in frame 60... not found\nSearching for chessboard in frame 80... not found\nSearching for chessboard in frame 100... not found\nSearching for chessboard in frame 120... not found\nSearching for chessboard in frame 140... ok\nSearching for chessboard in frame 160... ok\nSearching for chessboard in frame 180... ok\nSearching for chessboard in frame 200... ok\nSearching for chessboard in frame 220... ok\nSearching for chessboard in frame 240... ok\nSearching for chessboard in frame 260... ok\nSearching for chessboard in frame 280... ok\n...\nSearching for chessboard in frame 1980... ok\nSearching for chessboard in frame 2000... ok\nSearching for chessboard in frame 2020... ok\nSearching for chessboard in frame 2040... not found\nSearching for chessboard in frame 2060... not found\nSearching for chessboard in frame 2080... not found\nSearching for chessboard in frame 2100... ok\nSearching for chessboard in frame 2120... not found\nSearching for chessboard in frame 2140... not found\nSearching for chessboard in frame 2160... not found\nSearching for chessboard in frame 2180... not found\n\nPerforming calibration...\nRMS: 1.01973939405\ncamera matrix:\n[[ 774.55857698    0.          619.69416634]\n [   0.          772.96410156  352.49790333]\n [   0.            0.            1.        ]]\ndistortion coefficients:  [ -3.65385859e-01   1.63224385e-01  -2.67163331e-03   3.38261891e-04\n  -3.81711948e-02]\n\n~~~\n\nRemoving Radial Distortion\n--------------------------\n\nYou can test the found radial distortion coefficients by removing distortion from an image and checking if straight lines are really straight.\n\n~~~\n$ undistort.py --help\nusage: undistort.py [-h] calibration input_mask out\n\nUndistort images based on camera calibration.\n\npositional arguments:\n  calibration  input video file\n  input_mask   input mask\n  out          output directory\n\noptional arguments:\n  -h, --help   show this help message and exit\n\n$ undistort.py calibration.yaml 'example_input/*.png' out/\nprocessing example_input/distorted.png... ok\n\n~~~\n\nDevelopment\n-----------\n\nTo run all the tests run:\n\n```\ntox\n```\n\nLicense\n-------\n\nMIT License, except `pattern.png` from OpenCV (3-clause BSD License).\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmidm%2Fvideo2calibration","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fsmidm%2Fvideo2calibration","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fsmidm%2Fvideo2calibration/lists"}