Skip to content

Commit

Permalink
add times for testing
Browse files Browse the repository at this point in the history
  • Loading branch information
antoinefalisse committed Jul 1, 2024
1 parent 05a1f5e commit fc15a16
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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")
Expand All @@ -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")

Expand Down Expand Up @@ -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))

0 comments on commit fc15a16

Please sign in to comment.