Skip to content

Commit

Permalink
All good now, hopefully
Browse files Browse the repository at this point in the history
  • Loading branch information
davidpagnon committed Sep 2, 2024
1 parent 1a6ebf3 commit 908d662
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 16 deletions.
11 changes: 0 additions & 11 deletions Sports2D/Sports2D.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,19 +264,13 @@ def base_params(config_dict):
# video_files
video_files = config_dict.get('project').get('video_input')
if isinstance(video_files, str):
print('VIDEO FILE IS STRING')
video_files = [Path(video_files)]
else:
print('VIDEO FILE IS NOT STRING')
video_files = [Path(v) for v in video_files]
print('video_files base_params: ', video_files)

# frame_rates
frame_rates = []
for video_file in video_files:
print('video_dir: ', video_dir)
print('video_file: ', video_file)
print('video_dir/video_file: ', str(video_dir / video_file))
video = cv2.VideoCapture(str(video_dir / video_file)) if video_dir else cv2.VideoCapture(str(video_file))
if not video.isOpened():
raise FileNotFoundError(f'Error: Could not open {video_dir/video_file}. Check that the file exists.')
Expand Down Expand Up @@ -369,8 +363,6 @@ def process(config='Config_demo.toml'):
config_dict = config
else:
config_dict = read_config_file(config)
print('config_dict: ', config_dict['project']['video_input'])
print('config_dict: ', config_dict['project']['video_dir'])
video_dir, video_files, frame_rates, time_ranges, result_dir = base_params(config_dict)

result_dir.mkdir(parents=True, exist_ok=True)
Expand All @@ -387,8 +379,6 @@ def process(config='Config_demo.toml'):
logging.info(f"On {currentDateAndTime.strftime('%A %d. %B %Y, %H:%M:%S')}")
logging.info("---------------------------------------------------------------------")

print('process ', video_file)
print(config_dict)
process_fun(config_dict, video_file, time_range, frame_rate, result_dir)

elapsed_time = (datetime.now() - currentDateAndTime).total_seconds()
Expand Down Expand Up @@ -452,7 +442,6 @@ def main():
set_nested_value(new_config, leaf_key, cli_value)

# Run process with the new configuration dictionary
print('after nesting ', new_config)
Sports2D.process(new_config)


Expand Down
6 changes: 1 addition & 5 deletions Sports2D/Utilities/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,10 @@ def test_workflow():

# From command line (CLI) with config file
cli_config_path = Path(__file__).resolve().parent.parent / 'Demo' / 'Config_demo.toml'
cli_video_file = 'demo.mp4'
cli_video_dir = Path(__file__).resolve().parent.parent / 'Demo'
config_dict = toml.load(cli_config_path)
print('cli_video_file: ', cli_video_file)
cli_video_file = 'demo.mp4'
config_dict.get("project").update({"video_input": cli_video_file})
config_dict.get("project").update({"video_dir": cli_video_dir})
with open(cli_config_path, 'w') as f: toml.dump(config_dict, f)
print('config_dict: ', config_dict)

demo_config_cmd = ["sports2d", "--config", str(cli_config_path), "--show_realtime_results", "False", "--show_plots", "False"]
subprocess.run(demo_config_cmd, check=True, capture_output=True, text=True)

0 comments on commit 908d662

Please sign in to comment.