added datetime to logs

This commit is contained in:
davidpagnon 2024-03-05 02:59:25 +01:00
parent 3ffd39fe17
commit c04df78697

View File

@ -46,6 +46,7 @@ import os
import time import time
from copy import deepcopy from copy import deepcopy
import logging, logging.handlers import logging, logging.handlers
from datetime import datetime
## AUTHORSHIP INFORMATION ## AUTHORSHIP INFORMATION
@ -193,11 +194,13 @@ def calibration(config=None):
# Set up logging # Set up logging
setup_logging(session_dir) setup_logging(session_dir)
currentDateAndTime = datetime.now()
# Run calibration # Run calibration
calib_dir = [os.path.join(session_dir, c) for c in os.listdir(session_dir) if ('Calib' or 'calib') in c][0] calib_dir = [os.path.join(session_dir, c) for c in os.listdir(session_dir) if ('Calib' or 'calib') in c][0]
logging.info("\n\n---------------------------------------------------------------------") logging.info("\n\n---------------------------------------------------------------------")
logging.info("Camera calibration") logging.info("Camera calibration")
logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
logging.info("---------------------------------------------------------------------") logging.info("---------------------------------------------------------------------")
logging.info(f"\nCalibration directory: {calib_dir}") logging.info(f"\nCalibration directory: {calib_dir}")
start = time.time() start = time.time()
@ -236,13 +239,15 @@ def poseEstimation(config=None):
# # Batch process all trials # # Batch process all trials
# for config_dict in config_dicts: # for config_dict in config_dicts:
# start = time.time() # start = time.time()
# currentDateAndTime = datetime.now()
# project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) # project_dir = os.path.realpath(config_dict.get('project').get('project_dir'))
# seq_name = os.path.basename(project_dir) # seq_name = os.path.basename(project_dir)
# frame_range = config_dict.get('project').get('frame_range') # frame_range = config_dict.get('project').get('frame_range')
# frames = ["all frames" if frame_range == [] else f"frames {frame_range[0]} to {frame_range[1]}"][0] # frames = ["all frames" if frame_range == [] else f"frames {frame_range[0]} to {frame_range[1]}"][0]
# logging.info("\n\n---------------------------------------------------------------------") # logging.info("\n\n---------------------------------------------------------------------")
# logging.info("Camera synchronization") # logging.info("Pose estimation")
# logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
# logging.info("---------------------------------------------------------------------") # logging.info("---------------------------------------------------------------------")
# logging.info(f"\nProject directory: {project_dir}") # logging.info(f"\nProject directory: {project_dir}")
@ -280,6 +285,7 @@ def synchronization(config=None):
# # Batch process all trials # # Batch process all trials
# for config_dict in config_dicts: # for config_dict in config_dicts:
# start = time.time() # start = time.time()
# currentDateAndTime = datetime.now()
# project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) # project_dir = os.path.realpath(config_dict.get('project').get('project_dir'))
# seq_name = os.path.basename(project_dir) # seq_name = os.path.basename(project_dir)
# frame_range = config_dict.get('project').get('frame_range') # frame_range = config_dict.get('project').get('frame_range')
@ -287,6 +293,7 @@ def synchronization(config=None):
# logging.info("\n\n---------------------------------------------------------------------") # logging.info("\n\n---------------------------------------------------------------------")
# logging.info("Camera synchronization") # logging.info("Camera synchronization")
# logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
# logging.info("---------------------------------------------------------------------") # logging.info("---------------------------------------------------------------------")
# logging.info(f"\nProject directory: {project_dir}") # logging.info(f"\nProject directory: {project_dir}")
@ -324,6 +331,7 @@ def personAssociation(config=None):
# Batch process all trials # Batch process all trials
for config_dict in config_dicts: for config_dict in config_dicts:
start = time.time() start = time.time()
currentDateAndTime = datetime.now()
project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) project_dir = os.path.realpath(config_dict.get('project').get('project_dir'))
seq_name = os.path.basename(project_dir) seq_name = os.path.basename(project_dir)
frame_range = config_dict.get('project').get('frame_range') frame_range = config_dict.get('project').get('frame_range')
@ -331,6 +339,7 @@ def personAssociation(config=None):
logging.info("\n\n---------------------------------------------------------------------") logging.info("\n\n---------------------------------------------------------------------")
logging.info(f"Associating persons for {seq_name}, for {frames}.") logging.info(f"Associating persons for {seq_name}, for {frames}.")
logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
logging.info("---------------------------------------------------------------------") logging.info("---------------------------------------------------------------------")
logging.info(f"\nProject directory: {project_dir}") logging.info(f"\nProject directory: {project_dir}")
@ -367,6 +376,7 @@ def triangulation(config=None):
# Batch process all trials # Batch process all trials
for config_dict in config_dicts: for config_dict in config_dicts:
start = time.time() start = time.time()
currentDateAndTime = datetime.now()
project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) project_dir = os.path.realpath(config_dict.get('project').get('project_dir'))
seq_name = os.path.basename(project_dir) seq_name = os.path.basename(project_dir)
frame_range = config_dict.get('project').get('frame_range') frame_range = config_dict.get('project').get('frame_range')
@ -374,6 +384,7 @@ def triangulation(config=None):
logging.info("\n\n---------------------------------------------------------------------") logging.info("\n\n---------------------------------------------------------------------")
logging.info(f"Triangulation of 2D points for {seq_name}, for {frames}.") logging.info(f"Triangulation of 2D points for {seq_name}, for {frames}.")
logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
logging.info("---------------------------------------------------------------------") logging.info("---------------------------------------------------------------------")
logging.info(f"\nProject directory: {project_dir}") logging.info(f"\nProject directory: {project_dir}")
@ -413,6 +424,7 @@ def filtering(config=None):
# Batch process all trials # Batch process all trials
for config_dict in config_dicts: for config_dict in config_dicts:
currentDateAndTime = datetime.now()
project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) project_dir = os.path.realpath(config_dict.get('project').get('project_dir'))
seq_name = os.path.basename(project_dir) seq_name = os.path.basename(project_dir)
frame_range = config_dict.get('project').get('frame_range') frame_range = config_dict.get('project').get('frame_range')
@ -420,6 +432,7 @@ def filtering(config=None):
logging.info("\n\n---------------------------------------------------------------------") logging.info("\n\n---------------------------------------------------------------------")
logging.info(f"Filtering 3D coordinates for {seq_name}, for {frames}.") logging.info(f"Filtering 3D coordinates for {seq_name}, for {frames}.")
logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
logging.info("---------------------------------------------------------------------") logging.info("---------------------------------------------------------------------")
logging.info(f"\nProject directory: {project_dir}\n") logging.info(f"\nProject directory: {project_dir}\n")
@ -450,6 +463,7 @@ def markerAugmentation(config=None):
for config_dict in config_dicts: for config_dict in config_dicts:
start = time.time() start = time.time()
currentDateAndTime = datetime.now()
project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) project_dir = os.path.realpath(config_dict.get('project').get('project_dir'))
seq_name = os.path.basename(project_dir) seq_name = os.path.basename(project_dir)
frame_range = config_dict.get('project').get('frame_range') frame_range = config_dict.get('project').get('frame_range')
@ -457,6 +471,7 @@ def markerAugmentation(config=None):
logging.info("\n\n---------------------------------------------------------------------") logging.info("\n\n---------------------------------------------------------------------")
logging.info(f"Augmentation process for {seq_name}, for {frames}.") logging.info(f"Augmentation process for {seq_name}, for {frames}.")
logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
logging.info("---------------------------------------------------------------------") logging.info("---------------------------------------------------------------------")
logging.info(f"\nProject directory: {project_dir}\n") logging.info(f"\nProject directory: {project_dir}\n")
@ -466,7 +481,6 @@ def markerAugmentation(config=None):
logging.info(f'\nAugmentation took {end - start:.2f} s.') logging.info(f'\nAugmentation took {end - start:.2f} s.')
def opensimProcessing(config=None): def opensimProcessing(config=None):
''' '''
Uses OpenSim to run scaling based on a static trc pose Uses OpenSim to run scaling based on a static trc pose
@ -497,6 +511,7 @@ def opensimProcessing(config=None):
# # Batch process all trials # # Batch process all trials
# for config_dict in config_dicts: # for config_dict in config_dicts:
# currentDateAndTime = datetime.now()
# start = time.time() # start = time.time()
# project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) # project_dir = os.path.realpath(config_dict.get('project').get('project_dir'))
# seq_name = os.path.basename(project_dir) # seq_name = os.path.basename(project_dir)
@ -508,6 +523,7 @@ def opensimProcessing(config=None):
# # logging.info(f"Scaling model with <STATIC TRC FILE>.") # # logging.info(f"Scaling model with <STATIC TRC FILE>.")
# # else: # # else:
# # logging.info(f"Running inverse kinematics <MOTION TRC FILE>.") # # logging.info(f"Running inverse kinematics <MOTION TRC FILE>.")
# logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
# logging.info("---------------------------------------------------------------------") # logging.info("---------------------------------------------------------------------")
# logging.info(f"\nOpenSim output directory: {project_dir}") # logging.info(f"\nOpenSim output directory: {project_dir}")