aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorThéo de la Hogue2022-04-20 14:37:42 +0200
committerThéo de la Hogue2022-04-20 14:37:42 +0200
commit824c00abfa923b58d82e23615ce7c18db3ca152f (patch)
tree4303660b48e66872ff725cd8b3d89edc9087f60b /src
parent31519a8cb5e444243db3dece1bee30a44097af0a (diff)
downloadargaze-824c00abfa923b58d82e23615ce7c18db3ca152f.zip
argaze-824c00abfa923b58d82e23615ce7c18db3ca152f.tar.gz
argaze-824c00abfa923b58d82e23615ce7c18db3ca152f.tar.bz2
argaze-824c00abfa923b58d82e23615ce7c18db3ca152f.tar.xz
Adding dimension information to aruco camera calibration data.
Diffstat (limited to 'src')
-rw-r--r--src/argaze/ArUcoMarkers/ArUcoCamera.py15
-rw-r--r--src/argaze/utils/calibrate_tobii_camera.py10
-rw-r--r--src/argaze/utils/export_calibration_board.py4
3 files changed, 17 insertions, 12 deletions
diff --git a/src/argaze/ArUcoMarkers/ArUcoCamera.py b/src/argaze/ArUcoMarkers/ArUcoCamera.py
index 3871d77..6aa602c 100644
--- a/src/argaze/ArUcoMarkers/ArUcoCamera.py
+++ b/src/argaze/ArUcoMarkers/ArUcoCamera.py
@@ -12,9 +12,12 @@ class ArUcoCamera():
def __init__(self):
"""Define optical parameters."""
- self.__rms = 0 # root mean square error
- self.__K = [] # camera matrix (focal lengths and principal point)
- self.__D = [] # distortion coefficients
+ self.__rms = 0 # root mean square error
+
+ self.__dimensions = [0, 0] # dimensions of frame where to apply optical parameters (in pixel)
+
+ self.__K = [] # camera matrix (focal lengths and principal point)
+ self.__D = [] # distortion coefficients
# define calibration data
self.__corners_set_number = 0
@@ -32,13 +35,14 @@ class ArUcoCamera():
calibration_data = json.load(calibration_file)
self.__rms = calibration_data['rms']
+ self.__dimensions = calibration_data['dimensions']
self.__K = numpy.asarray(calibration_data['camera matrix'])
self.__D = numpy.asarray(calibration_data['distortion coefficients'])
def save_calibration_file(self, camera_calibration_filepath):
"""Save optical parameters into .json file."""
- calibration_data = {'rms': self.__rms, 'camera matrix': self.__K.tolist(), 'distortion coefficients': self.__D.tolist()}
+ calibration_data = {'rms': self.__rms, 'dimensions': self.__dimensions, 'camera matrix': self.__K.tolist(), 'distortion coefficients': self.__D.tolist()}
with open(camera_calibration_filepath, 'w', encoding='utf-8') as calibration_file:
@@ -61,7 +65,8 @@ class ArUcoCamera():
if self.__corners_set_number > 0:
- self.__rms, self.__K, self.__D, r, t = aruco.calibrateCameraCharuco(self.__corners_set, self.__corners_set_ids, board.get_model(), [frame_width, frame_height], None, None)
+ self.__dimensions = [frame_width, frame_height]
+ self.__rms, self.__K, self.__D, r, t = aruco.calibrateCameraCharuco(self.__corners_set, self.__corners_set_ids, board.get_model(), self.__dimensions, None, None)
def reset_calibration_data(self):
"""Clear all calibration data."""
diff --git a/src/argaze/utils/calibrate_tobii_camera.py b/src/argaze/utils/calibrate_tobii_camera.py
index cb4c792..61fc56c 100644
--- a/src/argaze/utils/calibrate_tobii_camera.py
+++ b/src/argaze/utils/calibrate_tobii_camera.py
@@ -29,13 +29,15 @@ def main():
parser.add_argument('square_size', metavar='SQUARE_SIZE', type=float, default=5, help='square size (cm)')
parser.add_argument('marker_size', metavar='MARKER_SIZE', type=float, default=3, help='marker size (cm)')
parser.add_argument('-t', '--tobii_ip', metavar='TOBII_IP', type=str, default='192.168.1.10', help='tobii glasses ip')
- parser.add_argument('-o', '--output', metavar='OUT', type=str, default='.', help='destination filepath')
- parser.add_argument('-d', '--dictionary', metavar='DICT', type=str, default='DICT_4X4_50', help='aruco marker dictionnary')
+ parser.add_argument('-o', '--output', metavar='OUT', type=str, default='camera.json', help='destination filepath')
+ parser.add_argument('-d', '--dictionary', metavar='DICT', type=str, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL,DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
args = parser.parse_args()
# Create tobii controller
tobii_controller = TobiiController.TobiiController(args.tobii_ip, 'myProject', 'mySelf')
+ tobii_controller.set_video_freq_25()
+
# Enable tobii video stream
tobii_video_stream = tobii_controller.enable_video_stream()
@@ -54,9 +56,6 @@ def main():
print("Camera calibration starts")
print("Waiting for calibration board...")
- frame_width = 0
- frame_height = 0
-
expected_markers_number = aruco_board.get_markers_number()
expected_corners_number = aruco_board.get_corners_number()
@@ -108,6 +107,7 @@ def main():
print('\nCalibration succeeded!')
print(f'\nRMS:\n{aruco_camera.get_rms()}')
+ print(f'\nDimensions:\n{video_frame.width}x{video_frame.height}')
print(f'\nCamera matrix:\n{aruco_camera.get_K()}')
print(f'\nDistortion coefficients:\n{aruco_camera.get_D()}')
diff --git a/src/argaze/utils/export_calibration_board.py b/src/argaze/utils/export_calibration_board.py
index 2bcdef2..6d925bd 100644
--- a/src/argaze/utils/export_calibration_board.py
+++ b/src/argaze/utils/export_calibration_board.py
@@ -13,9 +13,9 @@ def main():
parser.add_argument('columns', metavar='COLS_NUMBER', type=int, default=7, help='number of columns')
parser.add_argument('rows', metavar='ROWS_NUMBER', type=int, default=5, help='number of rows')
parser.add_argument('square_size', metavar='SQUARE_SIZE', type=int, default=5, help='square size (cm)')
- parser.add_argument('marker_size', metavar='MARKER_SIZE', type=int, default=5, help='marker size (cm)')
+ parser.add_argument('marker_size', metavar='MARKER_SIZE', type=int, default=3, help='marker size (cm)')
parser.add_argument('-o', '--output', metavar='OUT', type=str, default='.', help='destination path')
- parser.add_argument('-d', '--dictionary', metavar='DICT', type=str, default='DICT_4X4_50', help='aruco marker dictionnary')
+ parser.add_argument('-d', '--dictionary', metavar='DICT', type=str, default='DICT_ARUCO_ORIGINAL', help='aruco marker dictionnary (DICT_4X4_50, DICT_4X4_100, DICT_4X4_250, DICT_4X4_1000, DICT_5X5_50, DICT_5X5_100, DICT_5X5_250, DICT_5X5_1000, DICT_6X6_50, DICT_6X6_100, DICT_6X6_250, DICT_6X6_1000, DICT_7X7_50, DICT_7X7_100, DICT_7X7_250, DICT_7X7_1000, DICT_ARUCO_ORIGINAL,DICT_APRILTAG_16h5, DICT_APRILTAG_25h9, DICT_APRILTAG_36h10, DICT_APRILTAG_36h11)')
parser.add_argument('-r', '--resolution', metavar='RES', type=int, default=50, help='picture resolution in dpi')
args = parser.parse_args()