From c04df78697c6e047f042f689e20b6894ddb92df2 Mon Sep 17 00:00:00 2001 From: davidpagnon Date: Tue, 5 Mar 2024 02:59:25 +0100 Subject: [PATCH] added datetime to logs --- Pose2Sim/Pose2Sim.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/Pose2Sim/Pose2Sim.py b/Pose2Sim/Pose2Sim.py index a106cbe..ff54b41 100644 --- a/Pose2Sim/Pose2Sim.py +++ b/Pose2Sim/Pose2Sim.py @@ -46,6 +46,7 @@ import os import time from copy import deepcopy import logging, logging.handlers +from datetime import datetime ## AUTHORSHIP INFORMATION @@ -193,11 +194,13 @@ def calibration(config=None): # Set up logging setup_logging(session_dir) + currentDateAndTime = datetime.now() # Run calibration 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("Camera calibration") + logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}") logging.info("---------------------------------------------------------------------") logging.info(f"\nCalibration directory: {calib_dir}") start = time.time() @@ -231,18 +234,20 @@ def poseEstimation(config=None): # # Set up logging # session_dir = os.path.realpath(os.path.join(config_dicts[0].get('project').get('project_dir'), '..', '..')) - # setup_logging(session_dir) + # setup_logging(session_dir) # # Batch process all trials # for config_dict in config_dicts: # start = time.time() + # currentDateAndTime = datetime.now() # project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) # seq_name = os.path.basename(project_dir) # 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] # 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(f"\nProject directory: {project_dir}") @@ -280,6 +285,7 @@ def synchronization(config=None): # # Batch process all trials # for config_dict in config_dicts: # start = time.time() + # currentDateAndTime = datetime.now() # project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) # seq_name = os.path.basename(project_dir) # frame_range = config_dict.get('project').get('frame_range') @@ -287,6 +293,7 @@ def synchronization(config=None): # logging.info("\n\n---------------------------------------------------------------------") # logging.info("Camera synchronization") + # logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}") # logging.info("---------------------------------------------------------------------") # logging.info(f"\nProject directory: {project_dir}") @@ -324,6 +331,7 @@ def personAssociation(config=None): # Batch process all trials for config_dict in config_dicts: start = time.time() + currentDateAndTime = datetime.now() project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) seq_name = os.path.basename(project_dir) frame_range = config_dict.get('project').get('frame_range') @@ -331,6 +339,7 @@ def personAssociation(config=None): logging.info("\n\n---------------------------------------------------------------------") 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(f"\nProject directory: {project_dir}") @@ -367,6 +376,7 @@ def triangulation(config=None): # Batch process all trials for config_dict in config_dicts: start = time.time() + currentDateAndTime = datetime.now() project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) seq_name = os.path.basename(project_dir) frame_range = config_dict.get('project').get('frame_range') @@ -374,6 +384,7 @@ def triangulation(config=None): logging.info("\n\n---------------------------------------------------------------------") 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(f"\nProject directory: {project_dir}") @@ -413,6 +424,7 @@ def filtering(config=None): # Batch process all trials for config_dict in config_dicts: + currentDateAndTime = datetime.now() project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) seq_name = os.path.basename(project_dir) frame_range = config_dict.get('project').get('frame_range') @@ -420,6 +432,7 @@ def filtering(config=None): logging.info("\n\n---------------------------------------------------------------------") 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(f"\nProject directory: {project_dir}\n") @@ -450,6 +463,7 @@ def markerAugmentation(config=None): for config_dict in config_dicts: start = time.time() + currentDateAndTime = datetime.now() project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) seq_name = os.path.basename(project_dir) frame_range = config_dict.get('project').get('frame_range') @@ -457,6 +471,7 @@ def markerAugmentation(config=None): logging.info("\n\n---------------------------------------------------------------------") 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(f"\nProject directory: {project_dir}\n") @@ -466,7 +481,6 @@ def markerAugmentation(config=None): logging.info(f'\nAugmentation took {end - start:.2f} s.') - def opensimProcessing(config=None): ''' Uses OpenSim to run scaling based on a static trc pose @@ -497,6 +511,7 @@ def opensimProcessing(config=None): # # Batch process all trials # for config_dict in config_dicts: + # currentDateAndTime = datetime.now() # start = time.time() # project_dir = os.path.realpath(config_dict.get('project').get('project_dir')) # seq_name = os.path.basename(project_dir) @@ -508,6 +523,7 @@ def opensimProcessing(config=None): # # logging.info(f"Scaling model with .") # # else: # # logging.info(f"Running inverse kinematics .") + # logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}") # logging.info("---------------------------------------------------------------------") # logging.info(f"\nOpenSim output directory: {project_dir}")