From fc15a165c8ff5bd6e61d911b7a10cc213117a756 Mon Sep 17 00:00:00 2001 From: Antoine Falisse Date: Mon, 1 Jul 2024 11:40:26 -0700 Subject: [PATCH] add times for testing --- main.py | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 0c9f6707..3eda05c4 100644 --- a/main.py +++ b/main.py @@ -15,6 +15,7 @@ import logging logging.basicConfig(level=logging.INFO) +import time from utils import importMetadata, loadCameraParameters, getVideoExtension from utils import getDataDirectory, getOpenPoseDirectory, getMMposeDirectory @@ -43,6 +44,9 @@ def main(sessionName, trialName, trial_id, cameras_to_use=['all'], filter_frequency='default', overwriteFilterFrequency=False, scaling_setup='upright_standing_pose', overwriteScalingSetup=False, overwriteCamerasToUse=False): + + # Start time. + start_time = time.time() # %% High-level settings. # Camera calibration. @@ -302,6 +306,9 @@ def main(sessionName, trialName, trial_id, cameras_to_use=['all'], # Trial relative path trialRelativePath = os.path.join('InputMedia', trialName, trial_id) + # Time. + time_before_pose_detection = time.time() + logging.info('Before pose detection elapsed time: {}'.format(time_before_pose_detection - start_time)) if runPoseDetection: # Detect if checkerboard is upside down. upsideDownChecker = isCheckerboardUpsideDown(CamParamDict) @@ -389,7 +396,9 @@ def main(sessionName, trialName, trial_id, cameras_to_use=['all'], Visit https://www.opencap.ai/best-pratices to learn more about data collection and https://www.opencap.ai/troubleshooting for potential causes for a failed trial.""" raise Exception(exception, traceback.format_exc()) - + + time_before_synchronization = time.time() + logging.info('Pose estimation elapsed time: {}'.format(time_before_synchronization - time_before_pose_detection)) if runSynchronization: # Synchronize videos. try: @@ -424,7 +433,9 @@ def main(sessionName, trialName, trial_id, cameras_to_use=['all'], if scaleModel and calibrationOptions is not None and alternateExtrinsics is None: # Automatically select the camera calibration to use CamParamDict = autoSelectExtrinsicSolution(sessionDir,keypoints2D,confidence,calibrationOptions) - + + time_before_triangulation = time.time() + logging.info('Synchronization elapsed time: {}'.format(time_before_triangulation - time_before_synchronization)) if runTriangulation: # Triangulate. try: @@ -471,6 +482,8 @@ def main(sessionName, trialName, trial_id, cameras_to_use=['all'], pathAugmentedOutputFiles[trialName] = os.path.join( postAugmentationDir, trial_id + "_" + augmenterModelName +".trc") + time_before_augmentation = time.time() + logging.info('Triangulation elapsed time: {}'.format(time_before_augmentation - time_before_triangulation)) if runMarkerAugmentation: os.makedirs(postAugmentationDir, exist_ok=True) augmenterDir = os.path.join(baseDir, "MarkerAugmenter") @@ -494,6 +507,8 @@ def main(sessionName, trialName, trial_id, cameras_to_use=['all'], vertical_offset = 0.01 # %% OpenSim pipeline. + time_before_opensim = time.time() + logging.info('Augmentation elapsed time: {}'.format(time_before_opensim - time_before_augmentation)) if runOpenSimPipeline: openSimPipelineDir = os.path.join(baseDir, "opensimPipeline") @@ -618,3 +633,8 @@ def main(sessionName, trialName, trial_id, cameras_to_use=['all'], settings['verticalOffset'] = vertical_offset_settings with open(pathSettings, 'w') as file: yaml.dump(settings, file) + + # End time. + end_time = time.time() + logging.info('OpenSim elapsed time: {}'.format(end_time - time_before_opensim)) + logging.info('Total elapsed time: {}'.format(end_time - start_time))