Free Motion Capture for Everyone 💀✨
TypeScript
Charuco groundplane (#691)
Aaron Cherian4c4248ee5a76
diff --git a/experimental/batch_process/headless_calibration.py b/experimental/batch_process/headless_calibration.pyindex 4388bcba..563ba4bb 100644--- a/experimental/batch_process/headless_calibration.py+++ b/experimental/batch_process/headless_calibration.py@@ -27,8 +27,8 @@ def headless_calibration(if __name__ == "__main__":- path_to_folder_of_calibration_videos = Path("/PATH/TO/CALIBRATION/VIDEOS")- charuco_square_size = 110 # size of a black square on your charuco board in mm+ path_to_folder_of_calibration_videos = Path(r"C:\Users\aaron\freemocap_data\recording_sessions\freemocap_test_data\synchronized_videos")+ charuco_square_size = 58 # size of a black square on your charuco board in mmheadless_calibration(path_to_folder_of_calibration_videos=path_to_folder_of_calibration_videos,diff --git a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/anipose_camera_calibrator.py b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/anipose_camera_calibrator.pyindex deafc1e4..eda68af6 100644--- a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/anipose_camera_calibrator.py+++ b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/anipose_camera_calibrator.py@@ -18,8 +18,26 @@ from freemocap.system.paths_and_filenames.path_getters import ()from freemocap.utilities.get_video_paths import get_video_paths++from freemocap.core_processes.capture_volume_calibration.anipose_camera_calibration.charuco_groundplane_utils import (+ compute_basis_vectors_of_new_reference,+ find_good_frame,+ skellyforge_data,+ CharucoVisibilityError,+ CharucoVelocityError+)++from dataclasses import dataclass++from collections import namedtuplelogger = logging.getLogger(__name__)+Extrinsics = namedtuple("Extrinsics", ["rvecs", "tvecs"])++@dataclass+class GroundPlaneSuccess:+ success: bool+ error: str = Noneclass AniposeCameraCalibrator:def __init__(@@ -69,7 +87,7 @@ class AniposeCameraCalibrator:dict_size=250,)- def calibrate_camera_capture_volume(self, pin_camera_0_to_origin: bool = False) -> Path:+ def calibrate_camera_capture_volume(self, pin_camera_0_to_origin: bool = False, use_charuco_as_groundplane: bool = False) -> tuple[Path, GroundPlaneSuccess]:video_paths_list_of_list_of_strings = [[str(this_path)] for this_path in self._list_of_video_paths](@@ -82,10 +100,16 @@ class AniposeCameraCalibrator:success_str = "Anipose Calibration Successful!"logger.info(success_str)self._progress_callback(success_str)+ self._anipose_camera_group_object.metadata["groundplane_calibration"] = False+if pin_camera_0_to_origin:- self._anipose_camera_group_object = self.pin_camera_zero_to_origin(- cam_group=self._anipose_camera_group_object)- # save calibration info to files+ self._anipose_camera_group_object = self.pin_camera_zero_to_origin(self._anipose_camera_group_object)+ groundplane_success = None++ if use_charuco_as_groundplane:+ self._anipose_camera_group_object, groundplane_success = self.set_charuco_board_as_groundplane(self._anipose_camera_group_object)+ if groundplane_success.success:+ self._anipose_camera_group_object.metadata["groundplane_calibration"] = Truecalibration_toml_filename = create_camera_calibration_file_name(recording_name=self._calibration_videos_folder_path.parent.stem)@@ -112,7 +136,7 @@ class AniposeCameraCalibrator:"Anipose camera calibration data saved to calibrations folder, recording folder, and `Last Successful Calibration` file")- return calibration_folder_toml_path+ return calibration_folder_toml_path, groundplane_successdef pin_camera_zero_to_origin(self, cam_group: freemocap_anipose.CameraGroup):"""@@ -178,3 +202,91 @@ class AniposeCameraCalibrator:# Update the translation vectornew_tvecs[cam_i, :] = tvecs[cam_i, :] + delta_to_origin_camera_ireturn new_tvecs++ def set_charuco_board_as_groundplane(self, cam_group:freemocap_anipose.CameraGroup):+ import multiprocessing+ # Get the camera group object+ logger.info("Getting 2d Charuco data")++ charuco_2d_xy:np.ndarray = cam_group.charuco_2d_data++ if charuco_2d_xy is None:+ error_message = "Charuco 2d data was not retrieved successfully. Check for an error during calibration."+ logger.error(error_message)+ raise ValueError(error_message)+ logger.info("Charuco 2d data retrieved successfully with shape: "+ f"{charuco_2d_xy.shape}")+ charuco_2d_xy = charuco_2d_xy.astype(np.float64)+ num_cameras, num_frames, num_tracked_points,_ = charuco_2d_xy.shape+ charuco_2d_flat = charuco_2d_xy.reshape(num_cameras, -1, 2)++ logger.info("Getting 3d Charuco data")+ charuco_3d_flat = self._anipose_camera_group_object.triangulate(+ charuco_2d_flat)++ charuco_3d_xyz = charuco_3d_flat.reshape(num_frames, num_tracked_points, 3)+ logger.info(f"Charuco 3d data reconstructed with shape: {charuco_3d_xyz.shape}")++ charuco_3d_xyz_interpolated = skellyforge_data(raw_charuco_data=charuco_3d_xyz)++ charuco_save_path = self._recording_folder_path / "output_data" / "charuco_3d_xyz.npy"+ np.save(charuco_save_path, charuco_3d_xyz_interpolated) #NOTE - there may be a more robust way to get this path but this is the simplest for now+ logger.info(f"Charuco 3d data saved to {charuco_save_path}")++ try:+ charuco_still_frame_idx = find_good_frame(charuco_data=charuco_3d_xyz_interpolated,+ number_of_squares_width=self._charuco_board_object.number_of_squares_width,+ number_of_squares_height=self._charuco_board_object.number_of_squares_height,)+ except CharucoVisibilityError as e:+ logger.warning(+ "Ground-plane alignment skipped – reverting to original calibration: %s",+ e,+ exc_info=True, )+ success = GroundPlaneSuccess(success=False, error=str(e))+ return cam_group, success+ except CharucoVelocityError as e:+ logger.warning(+ "Ground-plane alignment skipped – reverting to original calibration: %s",+ e,+ exc_info=True, )+ success = GroundPlaneSuccess(success=False, error=str(e))+ return cam_group,success++ charuco_frame = charuco_3d_xyz_interpolated[charuco_still_frame_idx]++ x_hat, y_hat, z_hat = compute_basis_vectors_of_new_reference(charuco_frame,+ number_of_squares_width=self._charuco_board_object.number_of_squares_width,+ number_of_squares_height=self._charuco_board_object.number_of_squares_height)+ charuco_origin_in_world = charuco_frame[0]+ rmat_charuco_to_world = np.column_stack([x_hat, y_hat, z_hat]) #rotation matrix that transforms a point in the new world reference frame(defined by the charuco) into legacy world frame++ extrinsics = self.adjust_world_reference_frame_to_charuco(cam_group=cam_group,+ charuco_origin_in_world=charuco_origin_in_world,+ rmat_charuco_to_world=rmat_charuco_to_world)+ cam_group.set_rotations(extrinsics.rvecs)+ cam_group.set_translations(extrinsics.tvecs)+ success = GroundPlaneSuccess(success=True)+ logger.info("Anipose camera calibration data adjusted to set charuco board as ground plane")+ return cam_group, success++ def adjust_world_reference_frame_to_charuco(self,+ cam_group:freemocap_anipose.CameraGroup,+ charuco_origin_in_world:np.ndarray,+ rmat_charuco_to_world:np.ndarray):++ tvecs = cam_group.get_translations()+ rvecs = cam_group.get_rotations()++ tvecs_new = np.zeros_like(tvecs)+ rvecs_new = np.zeros_like(rvecs)++ for i in range(tvecs.shape[0]):+ rmat_world_to_cam_i, _ = cv2.Rodrigues(rvecs[i])+ #Xcam = Rc->w*Xworld + tvec (base formula for this transformation)+ t_delta = rmat_world_to_cam_i @ charuco_origin_in_world #Rc->w*Xworld (rmat is Rc->w)+ tvecs_new[i] = t_delta + tvecs[i] #Rc->w*Xworld + tvec++ new_rmat = rmat_world_to_cam_i @ rmat_charuco_to_world #composes w' -> w (rotation matrix) with w -> c (rmat) to get w' -> c+ new_rvec, _ = cv2.Rodrigues(new_rmat)+ rvecs_new[i] = new_rvec.flatten()+ return Extrinsics(rvecs_new, tvecs_new)\ No newline at end of filediff --git a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/charuco_groundplane_utils.py b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/charuco_groundplane_utils.pynew file mode 100644index 00000000..cb7a82df--- /dev/null+++ b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/charuco_groundplane_utils.py@@ -0,0 +1,107 @@+import numpy as np+from skellyforge.freemocap_utils.postprocessing_widgets.postprocessing_functions import interpolate_data+++class CharucoVisibilityError(RuntimeError):+ """Raised when no frame satisfies the ‘all-corners-visible & stationary’ criteria."""+++class CharucoVelocityError(RuntimeError):+ """Raised when the velocity of the ChArUco corners is too high to be considered stationary."""+++def get_charuco_x_and_y_idx(number_of_squares_width: int, number_of_squares_height: int):+ """+ For a given board definition, get the corner marker indexes needed to make the x and y vectors+ """++ num_cols = number_of_squares_width - 1 # corner columns+ num_rows = number_of_squares_height - 1 # corner rows++ idx_x = num_cols * (num_rows - 1)+ idx_y = num_cols - 1++ return idx_x, idx_y+++def get_unit_vector(vector: np.ndarray) -> np.ndarray:+ return vector / np.linalg.norm(vector)+++def compute_basis_vectors_of_new_reference(+ charuco_frame: np.ndarray, number_of_squares_width: int, number_of_squares_height: int+) -> tuple[np.ndarray, np.ndarray, np.ndarray]:+ origin = charuco_frame[0]++ idx_x, idx_y = get_charuco_x_and_y_idx(+ number_of_squares_width=number_of_squares_width, number_of_squares_height=number_of_squares_height+ )++ x_vec = charuco_frame[idx_x] - origin+ y_vec = charuco_frame[idx_y] - origin++ x_hat = get_unit_vector(x_vec)+ y_hat_raw = get_unit_vector(y_vec)+ z_hat = get_unit_vector(np.cross(x_hat, y_hat_raw))+ y_hat = get_unit_vector(np.cross(z_hat, x_hat))++ return x_hat, y_hat, z_hat+++def find_still_frame(points_velocity: np.ndarray, max_allowed_velocity: float = 1.0) -> int:+ visible_frames = ~np.isnan(points_velocity).any(axis=1)+ if not np.any(visible_frames):+ raise CharucoVisibilityError(+ "No frame found where all three required ChArUco corners are on the ground and visible."+ )++ max_velocity_per_frame = np.nanmax(points_velocity[visible_frames], axis=1)+ if np.nanmin(max_velocity_per_frame) > max_allowed_velocity:+ raise CharucoVelocityError(+ f"All frames have ChArUco corner velocity > {max_allowed_velocity:.2f} mm/s — check that the board is stationary."+ )++ best_visible_index = int(np.nanargmin(max_velocity_per_frame))+ best_velocity_index = np.where(visible_frames)[0][+ best_visible_index+ ] # maps back to the original array (which we sliced earlier to get rid of rows with nans)+ return best_velocity_index+++def find_good_frame(+ charuco_data: np.ndarray,+ number_of_squares_width: int,+ number_of_squares_height: int,+ frame_to_use: int = 0,+ search_range: int = 120,+):++ if frame_to_use == 0:+ slice_to_search = slice(0, search_range)+ elif frame_to_use == -1:+ slice_to_search = slice(-search_range, None)+ elif frame_to_use > 0:+ start_frame = max(0, frame_to_use - search_range)+ end_frame = min(charuco_data.shape[0], frame_to_use + search_range)+ slice_to_search = slice(start_frame, end_frame)+ else:+ raise ValueError(f"Invalid value for frame_to_use: {frame_to_use}")++ idx_x, idx_y = get_charuco_x_and_y_idx(+ number_of_squares_width=number_of_squares_width, number_of_squares_height=number_of_squares_height+ )++ charuco_corners = charuco_data[slice_to_search, [0, idx_y, idx_x]]+ charuco_corners_velocity = np.linalg.norm(np.diff(charuco_corners, axis=0), axis=2)+ best_velocity_frame = find_still_frame(points_velocity=charuco_corners_velocity)++ frame_offset = slice_to_search.start or 0+ best_position_frame = best_velocity_frame + frame_offset + 1+ return best_position_frame+++def skellyforge_data(raw_charuco_data: np.ndarray):+ interpolated_data = interpolate_data.interpolate_skeleton_data(+ skeleton_data=raw_charuco_data+ )+ return interpolated_datadiff --git a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.py b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.pyindex cfe47086..eeafa6df 100644--- a/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.py+++ b/freemocap/core_processes/capture_volume_calibration/anipose_camera_calibration/freemocap_anipose.py@@ -15,6 +15,7 @@ import tomlfrom aniposelib.boards import extract_points, extract_rtvecs, get_video_params, merge_rows, CharucoBoardfrom aniposelib.utils import get_rtvec, make_Mfrom numba import jit+from pathlib import Pathfrom scipy import optimizefrom scipy import signalfrom scipy.cluster.hierarchy import linkage, fcluster@@ -22,6 +23,10 @@ from scipy.cluster.vq import whitenfrom scipy.linalg import inv as inversefrom scipy.sparse import dok_matrixfrom tqdm import trange+from typing import List++from skellytracker.trackers.charuco_tracker.charuco_model_info import CharucoModelInfo, CharucoTrackingParams+from skellytracker.process_folder_of_videos import process_list_of_videosnumba_logger = logging.getLogger("numba")numba_logger.setLevel(logging.WARNING)@@ -29,6 +34,27 @@ numba_logger.setLevel(logging.WARNING)logger = logging.getLogger(__name__)++ARUCO_DICTS = {+ (4, 50): cv2.aruco.DICT_4X4_50,+ (5, 50): cv2.aruco.DICT_5X5_50,+ (6, 50): cv2.aruco.DICT_6X6_50,+ (7, 50): cv2.aruco.DICT_7X7_50,+ (4, 100): cv2.aruco.DICT_4X4_100,+ (5, 100): cv2.aruco.DICT_5X5_100,+ (6, 100): cv2.aruco.DICT_6X6_100,+ (7, 100): cv2.aruco.DICT_7X7_100,+ (4, 250): cv2.aruco.DICT_4X4_250,+ (5, 250): cv2.aruco.DICT_5X5_250,+ (6, 250): cv2.aruco.DICT_6X6_250,+ (7, 250): cv2.aruco.DICT_7X7_250,+ (4, 1000): cv2.aruco.DICT_4X4_1000,+ (5, 1000): cv2.aruco.DICT_5X5_1000,+ (6, 1000): cv2.aruco.DICT_6X6_1000,+ (7, 1000): cv2.aruco.DICT_7X7_1000,+}++@jit(nopython=True, parallel=False)def triangulate_simple(points, camera_mats):num_cams = len(camera_mats)@@ -649,6 +675,7 @@ class CameraGroup:def __init__(self, cameras, metadata={}):self.cameras = camerasself.metadata = metadata+ self.charuco_2d_data = Nonedef subset_cameras(self, indices):cams = [self.cameras[ix].copy() for ix in indices]@@ -1836,22 +1863,63 @@ class CameraGroup:return error, merged, charuco_frames- def get_rows_videos(self, videos, board, verbose=True):+ def get_rows_videos(self, videos: List[List[str]], board: "AniposeCharucoBoard", verbose: bool = True):+ num_corners = board.total_size+ self._get_charuco_2d_data(videos=videos, board=board)++ if self.charuco_2d_data is None:+ raise ValueError("Charuco 2D data has not been initialized. Call _get_charuco_2d_data() first, or check for errors in the video processing.")+all_rows = []- for cix, (cam, cam_videos) in enumerate(zip(self.cameras, videos)):- rows_cam = []- for vnum, vidname in enumerate(cam_videos):- if verbose:- print(vidname)- rows = board.detect_video(vidname, prefix=vnum, progress=verbose)- if verbose:- print("{} boards detected".format(len(rows)))- rows_cam.extend(rows)- all_rows.append(rows_cam)+ num_cameras, num_frames, _, _ = self.charuco_2d_data.shape+ for camera_number in range(num_cameras):+ camera_rows = []+ for frame in range(num_frames):+ filled = self.charuco_2d_data[camera_number, frame, :, :]+ filled = filled.astype(np.float32)+ filled = np.reshape(filled, (num_corners, 1, 2)) # Add empty column anipose expects+ mask = (~np.isnan(filled[:, :, 0])) & (~np.isnan(filled[:, :, 1]))+ non_empty_ids = np.where(mask)[0]+ corners = filled[non_empty_ids, :, :]+ non_empty_ids = non_empty_ids.reshape(-1, 1) # Add empty column anipose expects+ if corners.shape[0] != 0:+ row = {+ "framenum": (0, frame),+ "corners": corners,+ "ids": non_empty_ids,+ "filled": filled,+ }+ camera_rows.append(row)+ all_rows.append(camera_rows)+ if verbose:+ print(f"Charuco detection results:")+ for i, rows in enumerate(all_rows):+ print(f"\tCamera {i} has {len(rows)} frames with detected corners.")+return all_rows+ def _get_charuco_2d_data(self, videos: List[List[str]], board: "AniposeCharucoBoard"):+ """+ Processes a list of a list of videos to extract Charuco 2D data.++ Should be called once during the initial calibration, and then referenced with self.charuco_2d_data+ """+ video_paths = [Path(video[0]) for video in videos]+ charuco_2d_data = process_list_of_videos(+ model_info=CharucoModelInfo(),+ tracking_params=CharucoTrackingParams(+ charuco_squares_x_in=board.squaresX,+ charuco_squares_y_in=board.squaresY,+ charuco_dict_id=ARUCO_DICTS[(board.marker_bits, board.dict_size)]+ ),+ video_paths=video_paths,+ num_processes=min(len(videos), multiprocessing.cpu_count() - 1),+ )++ self.charuco_2d_data = charuco_2d_data+def set_camera_sizes_videos(self, videos):for cix, (cam, cam_videos) in enumerate(zip(self.cameras, videos)):rows_cam = []@@ -1863,7 +1931,7 @@ class CameraGroup:def calibrate_videos(self,videos,- board,+ board: "AniposeCharucoBoard",init_intrinsics=True,init_extrinsics=True,verbose=True,@@ -1957,25 +2025,9 @@ class AniposeCharucoBoard(CharucoBoard):self.square_length = square_lengthself.marker_length = marker_lengthself.manually_verify = manually_verify+ self.marker_bits = marker_bits+ self.dict_size = dict_size- ARUCO_DICTS = {- (4, 50): cv2.aruco.DICT_4X4_50,- (5, 50): cv2.aruco.DICT_5X5_50,- (6, 50): cv2.aruco.DICT_6X6_50,- (7, 50): cv2.aruco.DICT_7X7_50,- (4, 100): cv2.aruco.DICT_4X4_100,- (5, 100): cv2.aruco.DICT_5X5_100,- (6, 100): cv2.aruco.DICT_6X6_100,- (7, 100): cv2.aruco.DICT_7X7_100,- (4, 250): cv2.aruco.DICT_4X4_250,- (5, 250): cv2.aruco.DICT_5X5_250,- (6, 250): cv2.aruco.DICT_6X6_250,- (7, 250): cv2.aruco.DICT_7X7_250,- (4, 1000): cv2.aruco.DICT_4X4_1000,- (5, 1000): cv2.aruco.DICT_5X5_1000,- (6, 1000): cv2.aruco.DICT_6X6_1000,- (7, 1000): cv2.aruco.DICT_7X7_1000,- }dkey = (marker_bits, dict_size)self.dictionary = cv2.aruco.getPredefinedDictionary(ARUCO_DICTS[dkey])diff --git a/freemocap/core_processes/capture_volume_calibration/charuco_stuff/charuco_board_definition.py b/freemocap/core_processes/capture_volume_calibration/charuco_stuff/charuco_board_definition.pyindex 83f983b7..5d240f13 100644--- a/freemocap/core_processes/capture_volume_calibration/charuco_stuff/charuco_board_definition.py+++ b/freemocap/core_processes/capture_volume_calibration/charuco_stuff/charuco_board_definition.py@@ -6,13 +6,13 @@ import cv2@dataclassclass CharucoBoardDefinition:+ name: str+ number_of_squares_width: int+ number_of_squares_height: int+ black_square_side_length: int+ aruco_marker_length_proportional: floataruco_marker_dict: Dict = cv2.aruco.getPredefinedDictionary(cv2.aruco.DICT_4X4_250)- number_of_squares_width: int = 7- number_of_squares_height: int = 5- black_square_side_length: int = 1- aruco_marker_length_proportional: float = 0.8-def __post_init__(self):self.charuco_board = cv2.aruco.CharucoBoard(size=[self.number_of_squares_width, self.number_of_squares_height],@@ -22,3 +22,29 @@ class CharucoBoardDefinition:)self.number_of_charuco_corners = (self.number_of_squares_width - 1) * (self.number_of_squares_height - 1)+++def charuco_7x5() -> CharucoBoardDefinition:+ return CharucoBoardDefinition(+ name="full_board_7x5",+ number_of_squares_width=7,+ number_of_squares_height=5,+ black_square_side_length=1,+ aruco_marker_length_proportional=0.8,+ )+++def charuco_5x3() -> CharucoBoardDefinition:+ return CharucoBoardDefinition(+ name="mini_board_5x3",+ number_of_squares_width=5,+ number_of_squares_height=3,+ black_square_side_length=1,+ aruco_marker_length_proportional=0.8,+ )+++CHARUCO_BOARDS = {+ "Full Charuco (7x5)": charuco_7x5,+ "Mini Charuco (5x3)": charuco_5x3,+}diff --git a/freemocap/core_processes/capture_volume_calibration/run_anipose_capture_volume_calibration.py b/freemocap/core_processes/capture_volume_calibration/run_anipose_capture_volume_calibration.pyindex db9447d3..1004f320 100644--- a/freemocap/core_processes/capture_volume_calibration/run_anipose_capture_volume_calibration.py+++ b/freemocap/core_processes/capture_volume_calibration/run_anipose_capture_volume_calibration.py@@ -3,6 +3,7 @@ from typing import Callable, Unionfrom freemocap.core_processes.capture_volume_calibration.anipose_camera_calibration.anipose_camera_calibrator import (AniposeCameraCalibrator,+ GroundPlaneSuccess,)from freemocap.core_processes.capture_volume_calibration.charuco_stuff.charuco_board_definition import (CharucoBoardDefinition,@@ -18,14 +19,17 @@ def run_anipose_capture_volume_calibration(charuco_square_size: float,calibration_videos_folder_path: Union[str, Path],pin_camera_0_to_origin: bool = True,+ use_charuco_as_groundplane: bool = False,progress_callback: Callable[[str], None] = lambda _: None,-) -> Path:+) -> tuple[Path, GroundPlaneSuccess]:anipose_camera_calibrator = AniposeCameraCalibrator(charuco_board_definition,charuco_square_size=charuco_square_size,calibration_videos_folder_path=calibration_videos_folder_path,progress_callback=progress_callback,)- toml_path = anipose_camera_calibrator.calibrate_camera_capture_volume(pin_camera_0_to_origin=pin_camera_0_to_origin)+ toml_path, groundplane_success = anipose_camera_calibrator.calibrate_camera_capture_volume(+ pin_camera_0_to_origin=pin_camera_0_to_origin, use_charuco_as_groundplane=use_charuco_as_groundplane+ )- return toml_path+ return toml_path, groundplane_successdiff --git a/freemocap/core_processes/post_process_skeleton_data/process_single_camera_skeleton_data.py b/freemocap/core_processes/post_process_skeleton_data/process_single_camera_skeleton_data.pyindex a3498918..048da6dd 100644--- a/freemocap/core_processes/post_process_skeleton_data/process_single_camera_skeleton_data.py+++ b/freemocap/core_processes/post_process_skeleton_data/process_single_camera_skeleton_data.py@@ -8,6 +8,8 @@ from freemocap.core_processes.capture_volume_calibration.save_3d_data_to_npy impsave_3d_data_to_npy,)from freemocap.utilities.geometry.project_3d_data_to_z_plane import project_3d_data_to_z_plane+from freemocap.utilities.geometry.rotate_by_90_degrees_around_x_axis import rotate_by_90_degrees_around_x_axis+logger = logging.getLogger(__name__)@@ -39,5 +41,6 @@ def process_single_camera_skeleton_data(processing_level="raw",file_prefix=file_prefix,)+ rotated_raw_skel3d_frame_marker_xyz = rotate_by_90_degrees_around_x_axis(raw_skel3d_frame_marker_xyz)- return raw_skel3d_frame_marker_xyz, skeleton_reprojection_error_fr_mar+ return rotated_raw_skel3d_frame_marker_xyz, skeleton_reprojection_error_fr_mardiff --git a/freemocap/core_processes/process_motion_capture_videos/process_recording_folder.py b/freemocap/core_processes/process_motion_capture_videos/process_recording_folder.pyindex 66c55b59..3da86159 100644--- a/freemocap/core_processes/process_motion_capture_videos/process_recording_folder.py+++ b/freemocap/core_processes/process_motion_capture_videos/process_recording_folder.py@@ -22,7 +22,6 @@ from freemocap.data_layer.data_saver.data_saver import DataSaverfrom freemocap.data_layer.recording_models.post_processing_parameter_models import ProcessingParameterModelfrom freemocap.system.logging.configure_logging import log_view_logging_format_stringfrom freemocap.system.logging.queue_logger import DirectQueueHandler-from freemocap.utilities.geometry.rotate_by_90_degrees_around_x_axis import rotate_by_90_degrees_around_x_axisfrom freemocap.utilities.kill_event_exception import KillEventExceptionlogger = logging.getLogger(__name__)@@ -105,12 +104,10 @@ def process_recording_folder(raise exceptiontry:- # TODO: move the rotate by 90 function into skellyforge to skip duplication of responsibility- rotated_raw_skel3d_frame_marker_xyz = rotate_by_90_degrees_around_x_axis(raw_skel3d_frame_marker_xyz)# TODO: find out if skellyforge does all the error handling we need - if not add it to post_process_dataskel3d_frame_marker_xyz = post_process_data(recording_processing_parameter_model=recording_processing_parameter_model,- raw_skel3d_frame_marker_xyz=rotated_raw_skel3d_frame_marker_xyz,+ raw_skel3d_frame_marker_xyz=raw_skel3d_frame_marker_xyz,queue=logging_queue,)except (RuntimeError, ValueError, AttributeError) as e:diff --git a/freemocap/diagnostics/calibration/run_calibration.py b/freemocap/diagnostics/calibration/run_calibration.pyindex 39fe1a1c..368a4960 100644--- a/freemocap/diagnostics/calibration/run_calibration.py+++ b/freemocap/diagnostics/calibration/run_calibration.py@@ -7,7 +7,7 @@ import numpy as npfrom freemocap.core_processes.capture_volume_calibration.anipose_camera_calibration import \freemocap_aniposefrom freemocap.core_processes.capture_volume_calibration.charuco_stuff.charuco_board_definition import \- CharucoBoardDefinition+ charuco_7x5from freemocap.core_processes.capture_volume_calibration.run_anipose_capture_volume_calibration import \run_anipose_capture_volume_calibrationfrom freemocap.core_processes.capture_volume_calibration.triangulate_3d_data import \@@ -55,8 +55,8 @@ def setup_session():board_info = json.load(fh)charuco_square_size = board_info["square_size_mm"]- calibration_toml_path = run_anipose_capture_volume_calibration(- charuco_board_definition=CharucoBoardDefinition(),+ calibration_toml_path, _ = run_anipose_capture_volume_calibration(+ charuco_board_definition=charuco_7x5(),calibration_videos_folder_path=get_synchronized_video_folder_path(),charuco_square_size=charuco_square_size,progress_callback=lambda _: None,diff --git a/freemocap/gui/qt/main_window/freemocap_main_window.py b/freemocap/gui/qt/main_window/freemocap_main_window.pyindex ce677f20..2ca0e89e 100644--- a/freemocap/gui/qt/main_window/freemocap_main_window.py+++ b/freemocap/gui/qt/main_window/freemocap_main_window.py@@ -176,7 +176,9 @@ class MainWindow(QMainWindow):elif self._controller_group_box.calibration_videos_radio_button_checked:logger.info("Processing calibration videos")self._process_motion_capture_data_panel.calibrate_from_active_recording(- charuco_square_size_mm=float(self._controller_group_box.charuco_square_size)+ charuco_square_size_mm=float(self._controller_group_box.charuco_square_size),+ use_charuco_as_groundplane=self._controller_group_box.use_charuco_as_groundplane,+ charuco_board_name=self._controller_group_box.charuco_board_name,)def _handle_processing_finished_signal(self):diff --git a/freemocap/gui/qt/utilities/save_and_load_gui_state.py b/freemocap/gui/qt/utilities/save_and_load_gui_state.pyindex 93987e3b..cd02d812 100644--- a/freemocap/gui/qt/utilities/save_and_load_gui_state.py+++ b/freemocap/gui/qt/utilities/save_and_load_gui_state.py@@ -7,6 +7,7 @@ from freemocap.core_processes.export_data.blender_stuff.get_best_guess_of_blendeget_best_guess_of_blender_path,)from freemocap.system.paths_and_filenames.file_and_folder_names import BASE_FREEMOCAP_DATA_FOLDER_NAME+from freemocap.core_processes.capture_volume_calibration.charuco_stuff.charuco_board_definition import CHARUCO_BOARDSclass GuiState(BaseModel):@@ -17,9 +18,11 @@ class GuiState(BaseModel):generate_jupyter_notebook: bool = Trueauto_open_in_blender: bool = Truecharuco_square_size: float = 39+ use_charuco_as_groundplane: bool = Falseannotate_charuco_images: bool = Falsefreemocap_data_folder_path: str = str(Path(Path.home(), BASE_FREEMOCAP_DATA_FOLDER_NAME))blender_path: str = str(get_best_guess_of_blender_path())+ charuco_board_name: str = next(iter(CHARUCO_BOARDS))show_data_quality_warning: bool = Falseshown_latest_release_notes: bool = Falsediff --git a/freemocap/gui/qt/widgets/camera_controller_group_box.py b/freemocap/gui/qt/widgets/camera_controller_group_box.pyindex 4edf9447..ba310436 100644--- a/freemocap/gui/qt/widgets/camera_controller_group_box.py+++ b/freemocap/gui/qt/widgets/camera_controller_group_box.py@@ -11,6 +11,7 @@ from PySide6.QtWidgets import (QLabel,QRadioButton,QCheckBox,+ QComboBox,)from skellycam import SkellyCamControllerWidget, SkellyCamWidget@@ -21,8 +22,9 @@ from freemocap.system.paths_and_filenames.path_getters import (create_new_default_recording_name,get_gui_state_json_path,)+from freemocap.core_processes.capture_volume_calibration.charuco_stuff.charuco_board_definition import CHARUCO_BOARDS-CALIBRATION_RECORDING_BUTTON_TEXT = "\U0001F534 \U0001F4D0 Start Calibration Recording"+CALIBRATION_RECORDING_BUTTON_TEXT = "\U0001f534 \U0001f4d0 Start Calibration Recording"MOCAP_RECORDING_BUTTON_TEXT = f"{SKULL_EMOJI_STRING} {SPARKLES_EMOJI_STRING} Start Motion Capture Recording"logger = logging.getLogger(__name__)@@ -60,6 +62,8 @@ class CameraControllerGroupBox(QGroupBox):self._generate_jupyter_notebook_checkbox.toggled.connect(self._on_generate_jupyter_notebook_checkbox_changed)self._auto_open_in_blender_checkbox.toggled.connect(self._on_auto_open_in_blender_checkbox_changed)self._charuco_square_size_line_edit.textChanged.connect(self._on_charuco_square_size_line_edit_changed)+ self._use_charuco_as_groundplane_checkbox.toggled.connect(self._on_use_charuco_groundplane_checkbox_changed)+ self._board_dropdown.currentTextChanged.connect(self._on_charuco_board_dropdown_changed)@propertydef mocap_videos_radio_button_checked(self) -> bool:@@ -85,6 +89,14 @@ class CameraControllerGroupBox(QGroupBox):def charuco_square_size(self) -> float:return float(self._charuco_square_size_line_edit.text())+ @property+ def use_charuco_as_groundplane(self) -> bool:+ return self._use_charuco_as_groundplane_checkbox.isChecked()++ @property+ def charuco_board_name(self) -> str:+ return self._board_dropdown.currentText()+def check_recording_type(self):if self._mocap_videos_radio_button.isChecked():return "mocap"@@ -117,28 +129,49 @@ class CameraControllerGroupBox(QGroupBox):return hboxdef _create_calibration_recording_option_layout(self):- hbox = QHBoxLayout()- hbox.setAlignment(Qt.AlignmentFlag.AlignLeft)+ vbox = QVBoxLayout()++ # -------- First Row (Calibration Radio, Board Dropdown, Square Size) --------+ hbox_top = QHBoxLayout()+ hbox_top.setAlignment(Qt.AlignmentFlag.AlignLeft)self._calibration_videos_radio_button = QRadioButton("Record Calibration Videos")- hbox.addWidget(self._calibration_videos_radio_button)- hbox.addWidget(QLabel(" - "))+ hbox_top.addWidget(self._calibration_videos_radio_button)+ hbox_top.addWidget(QLabel(" - "))- hbox.addWidget(QLabel("Charuco square size (mm)", parent=self))+ hbox_top.addWidget(QLabel("Charuco square size (mm)", parent=self))self._charuco_square_size_line_edit = QLineEdit(parent=self)- self._charuco_square_size_line_edit.setFixedWidth(100)+ self._charuco_square_size_line_edit.setFixedWidth(60)self._charuco_square_size_line_edit.setText(str(self.gui_state.charuco_square_size))self._charuco_square_size_line_edit.setToolTip("The length of one of the edges of the black squares in the calibration board in mm")- hbox.addWidget(self._charuco_square_size_line_edit)+ hbox_top.addWidget(self._charuco_square_size_line_edit)++ hbox_top.addWidget(QLabel("Charuco Board:"))+ self._board_dropdown = self._create_board_dropdown()+ self._board_dropdown.setCurrentText(self.gui_state.charuco_board_name)+ hbox_top.addWidget(self._board_dropdown)+ hbox_top.addStretch()++ hbox_bottom = QHBoxLayout()+ hbox_bottom.setAlignment(Qt.AlignmentFlag.AlignLeft)self._annotate_charuco_checkbox = QCheckBox("Display Charuco Overlay")self._annotate_charuco_checkbox.setChecked(self.gui_state.annotate_charuco_images)self._skellycam_widget.annotate_images = self._annotate_charuco_checkbox.isChecked()- hbox.addWidget(self._annotate_charuco_checkbox)- hbox.addStretch()- return hbox+ hbox_bottom.addWidget(self._annotate_charuco_checkbox)++ self._use_charuco_as_groundplane_checkbox = QCheckBox("Use Charuco as groundplane")+ self._use_charuco_as_groundplane_checkbox.setChecked(self.gui_state.use_charuco_as_groundplane)+ hbox_bottom.addWidget(self._use_charuco_as_groundplane_checkbox)++ hbox_bottom.addStretch()++ vbox.addLayout(hbox_top)+ vbox.addLayout(hbox_bottom)++ return vboxdef _make_options_layout(self):options_vbox = QVBoxLayout()@@ -200,6 +233,16 @@ class CameraControllerGroupBox(QGroupBox):return vbox+ def _create_board_dropdown(self) -> QComboBox:+ board_dropdown = QComboBox()+ board_dropdown.setToolTip("Select the Charuco board to use for calibration")+ board_dropdown.setFixedWidth(150)+ board_dropdown.setStyleSheet("QComboBox { font-size: 12px; }")+ board_dropdown.setEnabled(True)+ board_dropdown.setEditable(False)+ board_dropdown.addItems(list(CHARUCO_BOARDS.keys()))+ return board_dropdown+def get_new_recording_path(self):return create_new_recording_folder_path(recording_name=self._get_recording_name())@@ -242,6 +285,10 @@ class CameraControllerGroupBox(QGroupBox):self.gui_state.annotate_charuco_images = self._annotate_charuco_checkbox.isChecked()save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())+ def _on_use_charuco_groundplane_checkbox_changed(self):+ self.gui_state.use_charuco_as_groundplane = self._use_charuco_as_groundplane_checkbox.isChecked()+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())+def _on_auto_process_videos_checkbox_changed(self):self.gui_state.auto_process_videos_on_save = self._auto_process_videos_checkbox.isChecked()save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())@@ -257,3 +304,8 @@ class CameraControllerGroupBox(QGroupBox):def _on_charuco_square_size_line_edit_changed(self):self.gui_state.charuco_square_size = float(self._charuco_square_size_line_edit.text())save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())++ def _on_charuco_board_dropdown_changed(self):+ selected_board_name = self._board_dropdown.currentText()+ self.gui_state.charuco_board_name = selected_board_name+ save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())diff --git a/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py b/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.pyindex a1a6de89..04609f75 100644--- a/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py+++ b/freemocap/gui/qt/widgets/control_panel/calibration_control_panel.py@@ -17,6 +17,8 @@ from PySide6.QtWidgets import (QWidget,QHBoxLayout,QLayout,+ QCheckBox,+ QComboBox,)from freemocap.data_layer.recording_models.recording_info_model import RecordingInfoModel@@ -29,16 +31,19 @@ from freemocap.system.paths_and_filenames.path_getters import (get_last_successful_calibration_toml_path,)+from freemocap.gui.qt.widgets.groundplane_failure_dialog import GroundPlaneCalibrationFailedDialog+from freemocap.core_processes.capture_volume_calibration.charuco_stuff.charuco_board_definition import CHARUCO_BOARDS+logger = logging.getLogger(__name__)class CalibrationControlPanel(QWidget):def __init__(- self,- get_active_recording_info: Callable[..., Union[RecordingInfoModel, Path]],- kill_thread_event: threading.Event,- gui_state: GuiState,- parent: Optional[QObject] = None,+ self,+ get_active_recording_info: Callable[..., Union[RecordingInfoModel, Path]],+ kill_thread_event: threading.Event,+ gui_state: GuiState,+ parent: Optional[QObject] = None,):super().__init__(parent=parent)self.gui_state = gui_state@@ -143,6 +148,10 @@ class CalibrationControlPanel(QWidget):else:self._show_selected_calibration_toml_path("-Calibration File Not Found-")+ def _bring_up_groundplane_calibration_failed_dialog(self, message: str):+ failure_dialog = GroundPlaneCalibrationFailedDialog(message=message)+ failure_dialog.exec()+def _add_calibrate_from_active_recording_radio_button(self):vbox = QVBoxLayout()hbox = QHBoxLayout()@@ -161,11 +170,37 @@ class CalibrationControlPanel(QWidget):self._calibrate_from_active_recording_button.setEnabled(False)self._calibrate_from_active_recording_button.clicked.connect(self.calibrate_from_active_recording)+ # Create existing form layoutself._charuco_square_size_form_layout = self._create_charuco_square_size_form_layout()++ # Create a horizontal layout to hold both form and checkboxhbox2 = QHBoxLayout()- hbox2.addStretch()+ hbox2.setAlignment(Qt.AlignmentFlag.AlignLeft)hbox2.addLayout(self._charuco_square_size_form_layout)++ # Create checkbox+ self._use_charuco_as_groundplane_checkbox = QCheckBox("Use Charuco board as groundplane")+ self._use_charuco_as_groundplane_checkbox.setToolTip(+ "Set the Charuco board's coordinate system as the global origin"+ )+ self._use_charuco_as_groundplane_checkbox.setChecked(False)+ self._use_charuco_as_groundplane_checkbox.setEnabled(False)++ hbox2.addSpacing(10)+ hbox2.addWidget(self._use_charuco_as_groundplane_checkbox)vbox.addLayout(hbox2)++ hbox3 = QHBoxLayout()+ hbox3.setAlignment(Qt.AlignmentFlag.AlignLeft)++ self._board_dropdown_label = QLabel("Charuco Board:")+ self._board_dropdown_label.setStyleSheet("QLabel { font-size: 12px; }")+ self._board_dropdown_label.setEnabled(False)+ self._board_dropdown = self._create_board_dropdown()+ hbox3.addWidget(self._board_dropdown_label)+ hbox3.addWidget(self._board_dropdown)+ vbox.addLayout(hbox3)+self._set_charuco_square_size_form_layout_visibility(False)return vbox@@ -217,9 +252,13 @@ class CalibrationControlPanel(QWidget):if checked and active_recording_info is not None and active_recording_info.synchronized_videos_status_check:self._calibrate_from_active_recording_button.setEnabled(True)self._set_charuco_square_size_form_layout_visibility(True)+ self._use_charuco_as_groundplane_checkbox.setEnabled(True)+ self._set_charuco_board_dropdown_visibility(True)else:self._calibrate_from_active_recording_button.setEnabled(False)self._set_charuco_square_size_form_layout_visibility(False)+ self._use_charuco_as_groundplane_checkbox.setEnabled(False)+ self._set_charuco_board_dropdown_visibility(False)def _set_charuco_square_size_form_layout_visibility(self, visible):label_index = self._charuco_square_size_form_layout.indexOf(self._charuco_square_size_label)@@ -231,6 +270,10 @@ class CalibrationControlPanel(QWidget):self._charuco_square_size_form_layout.itemAt(label_index).widget().setEnabled(False)self._charuco_square_size_form_layout.itemAt(line_edit_index).widget().setEnabled(False)+ def _set_charuco_board_dropdown_visibility(self, visible: bool):+ self._board_dropdown.setEnabled(visible)+ self._board_dropdown_label.setEnabled(visible)+def open_load_camera_calibration_toml_dialog(self) -> str:# from this tutorial - https://www.youtube.com/watch?v=gg5TepTc2Jg&t=649sdialog = QFileDialog()@@ -260,7 +303,7 @@ class CalibrationControlPanel(QWidget):self._charuco_square_size_line_edit = QLineEdit()self._charuco_square_size_line_edit.setValidator(QDoubleValidator())- self._charuco_square_size_line_edit.setFixedWidth(100)+ self._charuco_square_size_line_edit.setFixedWidth(80)self._charuco_square_size_label = QLabel("Charuco square size (mm)")self._charuco_square_size_label.setStyleSheet("QLabel { font-size: 12px; }")@@ -274,6 +317,16 @@ class CalibrationControlPanel(QWidget):charuco_square_size_form_layout.setAlignment(Qt.AlignmentFlag.AlignRight)return charuco_square_size_form_layout+ def _create_board_dropdown(self) -> QComboBox:+ board_dropdown = QComboBox()+ board_dropdown.setToolTip("Select the Charuco board to use for calibration")+ board_dropdown.setFixedWidth(150)+ board_dropdown.setStyleSheet("QComboBox { font-size: 12px; }")+ board_dropdown.setEnabled(False)+ board_dropdown.setEditable(False)+ board_dropdown.addItems(list(CHARUCO_BOARDS.keys()))+ return board_dropdown+def _on_charuco_square_size_line_edit_changed(self):self.gui_state.charuco_square_size = float(self._charuco_square_size_line_edit.text())save_gui_state(gui_state=self.gui_state, file_pathstring=get_gui_state_json_path())@@ -282,10 +335,23 @@ class CalibrationControlPanel(QWidget):def _log_calibration_progress_callbacks(self, message: str):logger.info(message)- def calibrate_from_active_recording(self, charuco_square_size_mm: float = None):+ def calibrate_from_active_recording(+ self,+ charuco_square_size_mm: float = None,+ use_charuco_as_groundplane: bool = None,+ charuco_board_name: str = None,+ ):if not charuco_square_size_mm:charuco_square_size_mm = float(self._charuco_square_size_line_edit.text())+ if not use_charuco_as_groundplane:+ use_charuco_as_groundplane = self._use_charuco_as_groundplane_checkbox.isChecked()++ if not charuco_board_name:+ charuco_board_name = self._board_dropdown.currentText()++ charuco_board_definition = CHARUCO_BOARDS[charuco_board_name]()+active_recording_info = self._get_active_recording_info()if active_recording_info is None:logger.error("Cannot calibrate from active recording - no active recording selected")@@ -305,6 +371,8 @@ class CalibrationControlPanel(QWidget):self._anipose_calibration_frame_worker = AniposeCalibrationThreadWorker(calibration_videos_folder_path=active_recording_info.synchronized_videos_folder_path,charuco_square_size=float(charuco_square_size_mm),+ use_charuco_as_groundplane=use_charuco_as_groundplane,+ charuco_board_definition=charuco_board_definition,kill_thread_event=self._kill_thread_event,)@@ -314,6 +382,10 @@ class CalibrationControlPanel(QWidget):self._anipose_calibration_frame_worker.finished.connect(self.update_calibration_toml_path)+ self._anipose_calibration_frame_worker.groundplane_failed.connect(+ self._bring_up_groundplane_calibration_failed_dialog+ )+def _check_active_recording_for_calibration_toml(self):active_rec = self._get_active_recording_info()if active_rec is not None:diff --git a/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py b/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.pyindex 60632880..d31a6888 100644--- a/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py+++ b/freemocap/gui/qt/widgets/control_panel/control_panel_dock_widget.py@@ -39,6 +39,8 @@ class ControlPanelWidget(QWidget):):super().__init__(parent=parent)+ self.setMinimumWidth(500)+self._layout = QVBoxLayout()self.setLayout(self._layout)diff --git a/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/process_motion_capture_data_panel.py b/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/process_motion_capture_data_panel.pyindex e08fa7bb..fb0a2616 100644--- a/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/process_motion_capture_data_panel.py+++ b/freemocap/gui/qt/widgets/control_panel/process_mocap_data_panel/process_motion_capture_data_panel.py@@ -93,8 +93,14 @@ class ProcessMotionCaptureDataPanel(QWidget):def process_motion_capture_data_button(self):return self._process_motion_capture_data_button- def calibrate_from_active_recording(self, charuco_square_size_mm: float):- self._calibration_control_panel.calibrate_from_active_recording(charuco_square_size_mm=charuco_square_size_mm)+ def calibrate_from_active_recording(+ self, charuco_square_size_mm: float, use_charuco_as_groundplane: bool, charuco_board_name: str+ ):+ self._calibration_control_panel.calibrate_from_active_recording(+ charuco_square_size_mm=charuco_square_size_mm,+ use_charuco_as_groundplane=use_charuco_as_groundplane,+ charuco_board_name=charuco_board_name,+ )def update_calibration_path(self) -> None:self._calibration_control_panel.update_calibrate_from_active_recording_button_text()@@ -250,9 +256,7 @@ class ProcessMotionCaptureDataPanel(QWidget):shutil.copyfile(selected_camera_calibration_toml_path, copied_toml_path)# set active tracker in recording model to the currently selected tracker- session_parameter_model.recording_info_model.active_tracker = (- session_parameter_model.tracking_model_info.name- )+ session_parameter_model.recording_info_model.active_tracker = session_parameter_model.tracking_model_info.nameself._process_motion_capture_data_thread_worker = ProcessMotionCaptureDataThreadWorker(session_parameter_model, kill_event=self._kill_thread_eventdiff --git a/freemocap/gui/qt/widgets/groundplane_failure_dialog.py b/freemocap/gui/qt/widgets/groundplane_failure_dialog.pynew file mode 100644index 00000000..c43a2bab--- /dev/null+++ b/freemocap/gui/qt/widgets/groundplane_failure_dialog.py@@ -0,0 +1,55 @@+from __future__ import annotations+from PySide6.QtWidgets import QDialog, QLabel, QPushButton, QVBoxLayout, QSizePolicy+from PySide6.QtCore import Qt+++class GroundPlaneCalibrationFailedDialog(QDialog):+ def __init__(self, message: str):+ super().__init__()+ self.setWindowTitle("Ground Plane Calibration Failed")+ self.setWindowModality(Qt.WindowModality.ApplicationModal)+ self.setMinimumSize(500, 200)+ self.setWindowFlags(self.windowFlags() | Qt.WindowType.WindowStaysOnTopHint)++ # Entire dialog styling (includes title bar area)+ self.setStyleSheet(+ """+ QDialog {+ background-color: #ffe0dc;+ }+ QLabel#titleLabel {+ font-weight: bold;+ font-size: 12pt;+ color: black;+ }+ QLabel#messageLabel {+ font-size: 10.5pt;+ color: black;+ }+ """+ )++ layout = QVBoxLayout()+ layout.setContentsMargins(20, 20, 20, 20)+ layout.setSpacing(15)++ # Title+ title = QLabel("Ground Plane Calibration Failed")+ title.setObjectName("titleLabel")++ # Message+ message_label = QLabel(message)+ message_label.setObjectName("messageLabel")+ message_label.setWordWrap(True)+ message_label.setSizePolicy(QSizePolicy.Policy.Expanding, QSizePolicy.Policy.Expanding)++ # OK Button+ ok_button = QPushButton("OK")+ ok_button.clicked.connect(self.accept)++ layout.addWidget(title)+ layout.addWidget(message_label)+ layout.addStretch(1)+ layout.addWidget(ok_button, alignment=Qt.AlignmentFlag.AlignRight)++ self.setLayout(layout)diff --git a/freemocap/gui/qt/workers/anipose_calibration_thread_worker.py b/freemocap/gui/qt/workers/anipose_calibration_thread_worker.pyindex e0ea7ffd..26c0f207 100644--- a/freemocap/gui/qt/workers/anipose_calibration_thread_worker.py+++ b/freemocap/gui/qt/workers/anipose_calibration_thread_worker.py@@ -18,26 +18,28 @@ logger = logging.getLogger(__name__)class AniposeCalibrationThreadWorker(QThread):finished = Signal(str)in_progress = Signal(str)+ groundplane_failed = Signal(str)def __init__(- self,- calibration_videos_folder_path: Union[str, Path],- charuco_square_size: Union[int, float],- kill_thread_event: threading.Event,- charuco_board_definition: CharucoBoardDefinition = None,+ self,+ calibration_videos_folder_path: Union[str, Path],+ charuco_square_size: Union[int, float],+ kill_thread_event: threading.Event,+ charuco_board_definition: CharucoBoardDefinition,+ use_charuco_as_groundplane: bool = False,):super().__init__()logger.info(f"Initializing Anipose Calibration Thread Worker for videos in path {calibration_videos_folder_path}")- if charuco_board_definition is None:- charuco_board_definition = CharucoBoardDefinition()+ # if charuco_board_definition is None: #removing because with the new dropdown, we should always have a charuco board definition+ # charuco_board_definition = CharucoBoardDefinition()self._kill_thread_event = kill_thread_eventself._charuco_board_definition = charuco_board_definitionself._charuco_square_size = charuco_square_sizeself._calibration_videos_folder_path = calibration_videos_folder_path-+ self._use_charuco_as_groundplane = use_charuco_as_groundplaneself._work_done = False@property@@ -51,14 +53,20 @@ class AniposeCalibrationThreadWorker(QThread):logger.info("Beginning Anipose calibration with Charuco Square Size (mm): {}".format(self._charuco_square_size))try:- toml_path = run_anipose_capture_volume_calibration(+ toml_path, groundplane_success = run_anipose_capture_volume_calibration(charuco_board_definition=self._charuco_board_definition,charuco_square_size=self._charuco_square_size,calibration_videos_folder_path=self._calibration_videos_folder_path,pin_camera_0_to_origin=True,+ use_charuco_as_groundplane=self._use_charuco_as_groundplane,progress_callback=self._emit_in_progress_data,)self.finished.emit(str(toml_path))+ if groundplane_success:+ if groundplane_success.success is False:+ self.groundplane_failed.emit(+ f"Groundplane calibration failed: {groundplane_success.error} \n\n Using original camera calibration instead."+ )except Exception as e:logger.exception("something went wrong in the anipose calibration")diff --git a/pyproject.toml b/pyproject.tomlindex f2661889..3a27169e 100644--- a/pyproject.toml+++ b/pyproject.toml@@ -70,8 +70,8 @@ dependencies = ["skelly_viewer==2025.04.1028","skellyforge==2024.12.1009","skelly_synchronize==2025.04.1037",- "skellytracker[all]==2025.5.1022",- "ajc27_freemocap_blender_addon==v2025.1.1035",+ "skellytracker[all]==2025.6.1023",+ "ajc27_freemocap_blender_addon==v2025.8.1037","opencv-contrib-python==4.8.*","toml==0.10.2","aniposelib==0.4.3",