{"id":22268454,"url":"https://github.com/abhijit-2592/camera_calibration_api","last_synced_at":"2025-10-06T13:31:31.927Z","repository":{"id":51001550,"uuid":"124087248","full_name":"Abhijit-2592/camera_calibration_API","owner":"Abhijit-2592","description":"A simple Python API for single camera calibration using opencv","archived":false,"fork":false,"pushed_at":"2018-03-19T11:38:40.000Z","size":7234,"stargazers_count":67,"open_issues_count":1,"forks_count":24,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-01-14T05:10:41.245Z","etag":null,"topics":["api","asymmetric-grid","camera","camera-calibration","chessboard","circular-grid","matlab","opencv","python","python2","python3","single-camera","symmetric-grid"],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Abhijit-2592.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-03-06T14:06:41.000Z","updated_at":"2024-08-05T13:47:48.000Z","dependencies_parsed_at":"2022-09-25T00:50:12.191Z","dependency_job_id":null,"html_url":"https://github.com/Abhijit-2592/camera_calibration_API","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abhijit-2592%2Fcamera_calibration_API","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abhijit-2592%2Fcamera_calibration_API/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abhijit-2592%2Fcamera_calibration_API/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Abhijit-2592%2Fcamera_calibration_API/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Abhijit-2592","download_url":"https://codeload.github.com/Abhijit-2592/camera_calibration_API/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":235527725,"owners_count":19004371,"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":["api","asymmetric-grid","camera","camera-calibration","chessboard","circular-grid","matlab","opencv","python","python2","python3","single-camera","symmetric-grid"],"created_at":"2024-12-03T11:12:53.299Z","updated_at":"2025-10-06T13:31:26.052Z","avatar_url":"https://github.com/Abhijit-2592.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# camera_calibration_API\n\n**A repository containing the camera calibration API**\n\n### Repository Overview:\n\n[camera_calibration.py](./camera_calibration.py):contains an API which tries to minic the MATLAB's camera calibration app functionality. This API is a thin wrapper around the opencv's camera calibration functionalities.\n\n[examples](./examples): A directory containing various examples\n\n\n### Camera_Calibration_API:\n\n#### Introduction:\nThe Camera Calibration API is a wrapper around the opencv's camera calibration functionalities. This tries to mimic the MATLAB camera calibration app's functionality in `python`. The API supports all the 3 calibration patterns supported by opencv namely: **Chessboards**, **Asymmetric circular grids** and **Symmetric circular grids.**  The API by default runs on 4 threads for speedup. The speed-up may not be marginal in the case of **chessboard** calibration because in most cases the bottle neck will be a single chessboard image (run on a single core) which the algorithm takes time to detect.\n\n#### Dependencies:\n* `works in both python-3 and python-2`\n* `opencv (Tested in version 3.3.0)`\n* `numpy`\n* `matplotlib`\n* `pickle`\n* `argparse`\n* `glob`\n* `pickle`\n* `multiprocessing`\n* `os`\n* `pandas`\n\n#### Example:\nExamples to use the Camera_Calibration_API() for calibration using chessboard, symmetric circular grids and asymmetric circular grids can be found in the [example_notebooks](./examples/example_notebooks) folder\n\n#### Features:\n* Supports all the 3 calibration patterns supported by opencv : **Chessboards**, **Asymmetric circular grids** and **Symmetric circular grids.**\n* Additionally a **custom** calibration pattern can also be implemented. (Look at the next section for how to calibrate using custom pattern.)\n* Visualizes the **Reprojection error plot**\n* Ability to **Recalibrate** the camera by neglecting the images with very high reprojection errors.\n* **Camera centric and Pattern centric** views can be visualized using the `visualize_calibration_boards` method after calibration. \n* `Blob detection parameters` for detecting asymmetric and symmetric circular grids can be accessed and modified via the **Camera_Calibration_API's object** prior to calling the `calibrate_camera` method\n* Also has `terminal` support with **minimal control** on the variables. Use it as an importable module for better control over the variables \n* Can also be easily extended to support other unimplemented calibration patterns\n\n#### Using custom calibration board with the Camera_Calibration_API.\n\nSo you want to extend the API for a custom calibration pattern? Well... OK! Just follow the follow the steps below\n\n* The `calibrate_camera` accepts two additional arguments called `custom_world_points_function` and `custom_image_points_function`.\n* You must implement the above two custom methods and pass it as an argument to the `calibrate_camera` method\n\n\n        \n##### custom_world_points_function(pattern_rows,pattern_columns):\n    \n* This function is responsible for calculating the 3-D world points of the given custom calibration pattern.\n* Should take in two keyword arguments in the following order: Number of rows in pattern(int), Number of columns in pattern(int)\n* Must return only a single numpy array of shape (M,3) and type np.float32 or np.float64 with M being the number of control points of the custom calibration pattern. The last column of the array (z axis) should be an array of 0\n* The distance_in_world_units is not multiplied in this case. Hence, account for that inside the function before returning\n* The world points must be ordered in this specific order : row by row, left to right in every row\n\n##### custom_image_points_function(img,pattern_rows,pattern_columns):\n    \n* This function is responsible for finding the 2-D image points from the custom calibration image.\n* Should take in 3 keyword arguments in the following order: image(numpy array),Number of rows in pattern(int), Number of columns in pattern(int)\n* This must return 2 variables: return_value, image_points\n* The first one is a boolean Representing whether all the control points in the calibration images are found\n* The second one is a numpy array of shape (N,2) of type np.float32 containing the pixel coordinates or the image points of the control points. where N is the number of control points.\n* This function should return True only if all the control points are detected (M = N)\n* If all the control points are not detected, fillup the 2-D numpy array with 0s entirely and return with bool == False.\n* The custom image points must be ordered in this specific order: : row by row, left to right in every row\n\n**NOTE: 'Custom' pattern is not supported when accessed from terminal**\n\n\n\n#### Supported Calibration patterns (rows x columns) bydefault:\n\n##### Chessboard or Checkerboard pattern (6 x 9):\n![chessboard](https://raw.githubusercontent.com/LongerVision/OpenCV_Examples/master/markers/pattern_chessboard.png)\n\n##### Asymmetrical circular grid/pattern (4 x 11):\n![Asymmetric circular grid](https://raw.githubusercontent.com/LongerVision/OpenCV_Examples/master/markers/pattern_acircles.png). \n\n#### NOTE for calibrating using Asymmetric circular grid:\n* The code assumes that each asymmetric circle is placed at half the `distance_in_world_units` in both (x,y) from each other.\n\n* The `distance_in_world_units` is specified as the distance between 2 adjacent circle centers at the **same y coordinate** \n\n* The above is a **4 x 11 (r x c)** asymmetrical circular grid. \n\n* If you are using the same orientation as the above, Then this orientation is termed as **double_count_in_column** which is by default set to `True`. \n\n* If you are using an orientation which is 90deg to the above orientation **11 x 4 (r x c)** then the `double count` is along the **rows**. In this case, set `object.double_count_in_column = False` prior to calling   `object.calibrate_camera` method.\n\n##### Symmetric circular grid/pattern (7 x 6):\n![Symmetrical circular pattern](http://answers.opencv.org/upfiles/13785495544653926.jpg)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhijit-2592%2Fcamera_calibration_api","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fabhijit-2592%2Fcamera_calibration_api","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fabhijit-2592%2Fcamera_calibration_api/lists"}