Commit a579145b authored by Guillaume CLIVAZ's avatar Guillaume CLIVAZ
Browse files

[calibration/wip] Small fix in the config and calibration.py script

parent 6f3f0fdc
Pipeline #48612 failed with stage
in 8 minutes and 24 seconds
......@@ -99,9 +99,9 @@ def compute_intrinsics(im_pts, image_size, obj_pts=None, ids=None, charuco_board
if params['fix_center_point']:
flags += cv2.CALIB_FIX_PRINCIPAL_POINT
if params['fix_focal_length']:
flags = cv2.CALIB_FIX_FOCAL_LENGTH
flags += cv2.CALIB_FIX_FOCAL_LENGTH
if params['zero_tang_dist']:
flags = cv2.CALIB_ZERO_TANGENT_DIST
flags += cv2.CALIB_ZERO_TANGENT_DIST
image_size = (image_size[1], image_size[0])
if not isinstance(im_pts, list):
......@@ -153,20 +153,22 @@ def compute_relative_extrinsics(obj_pts,
flags=flags,
criteria=criteria
)
#)[1:]
if R is None or T is None:
print("WARNING: No target pair was detected in the same capture")
return reprojection_error, R, T
def detect_patterns(directory_path, data_config_path,
pattern_type, pattern_size, charuco_board = None,
cv_flags=None, frames_dict=None, verbosity=0):
params=None, verbosity=0):
if charuco_board is None and pattern_type == "charuco":
raise ValueError("Charuco board not specified.")
frames_dict = params["frames_list"]
files = [os.path.join(directory_path, file) for file in frames_dict.keys()]
frames = list(v for v in frames_dict.values())
threshold = params["threshold"]
closing_size = params["closing_size"]
capture_dict = {}
image_size = {}
......@@ -215,9 +217,9 @@ def detect_patterns(directory_path, data_config_path,
image = cv2.cvtColor(image, cv2.COLOR_BGR2GRAY)
image = image.squeeze()
if pattern_type == "chessboard":
prep_image = prepocess_image(image, closing_size=10, threshold=181)
prep_image = prepocess_image(image, closing_size, threshold)
if pattern_type == "charuco":
prep_image = prepocess_image(image, closing_size=2, threshold=151)
prep_image = prepocess_image(image, closing_size, threshold)
image_size[stream.name] = image.shape
capture_name = capture + ":" + str(frame)
......@@ -395,7 +397,7 @@ def main():
pts, image_data = detect_patterns(capture_dir_path, data_config_path,
pattern_type, pattern_size, charuco_board=charuco_board,
frames_dict=frames, verbosity=verbosity)
params=config, verbosity=verbosity)
# Create 3D object points for 1 frame
if pattern_type == "chessboard":
......
......@@ -6,9 +6,10 @@
"pattern_columns": 7,
"square_size" : 21,
"marker_size" : 10.5,
"threshold" : 151,
"closing_size" : 2,
"intrinsics":
{
"fix_center_point" : false,
"fix_aspect_ratio" : false,
"fix_focal_length" : false,
......
......@@ -5,6 +5,8 @@
"pattern_rows": 10,
"pattern_columns": 7,
"square_size" : 21,
"threshold" : 181,
"closing_size" : 10,
"intrinsics":
{
"fix_center_point" : false,
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment