Skip to content
This repository was archived by the owner on Aug 22, 2024. It is now read-only.
Prev Previous commit
Next Next commit
Minor cleanup of the printing, template file fixes, and one edge case…
… detection bug.
  • Loading branch information
Kyle Rendon committed Feb 1, 2021
commit c56daf4c0dd0eccccc7d0a2c999316ff1f57e56e
7 changes: 6 additions & 1 deletion examples/calibration_registration/PlaneFiles/plane.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,12 @@
"square_length": 40,
"marker_length": 30,
"margin_size": 20,
"aruco_dict_name": 6
"aruco_dict_name": 6,
"width": 600,
"height": 400,
"x": -20,
"y": -20,
"dpi_factor": 5
}
]
}
10 changes: 5 additions & 5 deletions examples/calibration_registration/PlaneFiles/plane_large.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"shapes": [
{
"shape": "charuco",
"squaresX": 14,
"squaresY": 9,
"squareLength_mm": 80,
"markerLength_mm": 60,
"marginSize_mm": 40,
"squares_x": 14,
"squares_y": 9,
"square_length": 80,
"marker_length": 60,
"margin_size": 40,
"width": 1200,
"height": 800,
"x": -40,
Expand Down
10 changes: 5 additions & 5 deletions examples/calibration_registration/PlaneFiles/plane_small.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
"shapes": [
{
"shape": "charuco",
"squaresX": 10,
"squaresY": 7,
"squareLength_mm": 25,
"markerLength_mm": 19,
"marginSize_mm": 12,
"squares_x": 10,
"squares_y": 7,
"square_length": 25,
"marker_length": 19,
"margin_size": 12,
"width": 274,
"height": 199,
"x": -12,
Expand Down
9 changes: 4 additions & 5 deletions examples/calibration_registration/README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Camera Calibration and Registration ReadMe

Here we supply examples for the user to run camera calibration on a single camera, and registration
to identify spacial relationships between different cameras.
to identify spatial relationships between different cameras.

## Installation

Expand Down Expand Up @@ -43,7 +43,7 @@ These scripts enable developers to do two things: Calibrate a given camera, and

2. How to calibrate a camera.
1. Calibration typically requires about 30 images and relies on the Brown Conrady distortion model.
2. The script `calibrate.py` is designed to take in command line arguments so it can be used personally collected data without modification. If you want to work with the provided example, simply run: python `calibrate.py.` For further details please see [Camera Calibration](https://docs.opencv.org/master/dc/dbb/tutorial_py_calibration.html) in the OpenCV documentation.
2. The script `calibrate.py` is designed to take in command line arguments so it can be used personally collected data without modification. For further details please see [Camera Calibration](https://docs.opencv.org/master/dc/dbb/tutorial_py_calibration.html) in the OpenCV documentation.
3. If you already have a collected set of data, run the calibration code this way:

``` windows
Expand All @@ -61,13 +61,12 @@ The script `register.py`, like `calibrate.py` is designed to take in command lin
* Example: RGB and IR images taken simultaneously.
* ![Color Image](example_files/registration/color-0.jpg "Color Image")
* ![IR Image](example_files\registration/ir-0.png "IR Image")
3. To run the onboard example, run: `full_path\register.py`
4. If you already have a collected set of data, run the calibration code this way:
3. If you already have a collected set of data, run the calibration code this way:

``` windows
python <full_path>\register.py --img-a <full_path_img_a> --img-b <full_path_img_b> `
--template <full_path_tempate> --calib-a <full_path_calibration_a> `
--calib-b <full_path_calibration_b> --out-dir <full_path_calibration_b>
```

5. If successful, the code will print out the rotation and translation matrix from camera B to camera A and save the calibration blob as a json.
4. If successful, the code will print out the rotation and translation matrix from camera B to camera A and save the calibration blob as a json.
4 changes: 2 additions & 2 deletions examples/calibration_registration/calibrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,5 @@ def parse_args():
args.template,
init_calfile=args.calib_file)
print(f"RMS: the overall RMS re-projection error in pixels: {rms}")
print(f"opencv cal calibration matrix: {calib_matrix}")
print(f"opencv cal distortion coeffs: {dist_coeffs}")
print(f"\nopencv cal calibration matrix:\n{calib_matrix}")
print(f"\nopencv cal distortion coeffs:\n{dist_coeffs}")
6 changes: 5 additions & 1 deletion examples/calibration_registration/camera_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -262,7 +262,11 @@ def detect_markers(img: np.ndarray,
aruco_ids,
img,
board)
if charuco_corners is None:
if charuco_corners is None:
charuco_corners = []
charuco_ids = []
warnings.warn("No charuco corners detected in image.")
else:
charuco_corners = []
charuco_ids = []
warnings.warn("No charuco corners detected in image.")
Expand Down