summaryrefslogtreecommitdiff
path: root/bjoern/videoanalyse/combine_ocr-logs.py
diff options
context:
space:
mode:
authorNiclas Dobbertin <niclas.dobbertin@stud.tu-darmstadt.de>2023-10-02 19:11:24 +0200
committerNiclas Dobbertin <niclas.dobbertin@stud.tu-darmstadt.de>2023-10-02 19:11:24 +0200
commitddab7c6cc5ba7e785aadb224f294284b0564acd6 (patch)
tree11e2eab853ee35a9d621c5d350cde9cfc9f74393 /bjoern/videoanalyse/combine_ocr-logs.py
parent7266e2787bfa661d490be9c4463e707e6ffe1715 (diff)
refactor post processing into single script
Diffstat (limited to 'bjoern/videoanalyse/combine_ocr-logs.py')
-rw-r--r--bjoern/videoanalyse/combine_ocr-logs.py52
1 files changed, 0 insertions, 52 deletions
diff --git a/bjoern/videoanalyse/combine_ocr-logs.py b/bjoern/videoanalyse/combine_ocr-logs.py
deleted file mode 100644
index 1d99629..0000000
--- a/bjoern/videoanalyse/combine_ocr-logs.py
+++ /dev/null
@@ -1,52 +0,0 @@
-#!/usr/bin/env python3
-
-import argparse
-from pathlib import Path
-from datetime import datetime, timedelta
-import pandas as pd
-import csv
-
-argparser = argparse.ArgumentParser(
- description="Combines results of OCR analysis with log files"
-)
-argparser.add_argument(
- "vp_dir", help="Directory containing analysis_results.csv and VPCODE.csv"
-)
-
-args = argparser.parse_args()
-
-vp_path = Path(args.vp_dir)
-
-video_path = next(vp_path.glob("*.mkv"))
-date_format = "%Y-%m-%d %H-%M-%S"
-video_date = datetime.strptime(video_path.stem, date_format)
-print(video_date)
-# video_delta = timedelta(hours=video_date.hour, minutes=video_date.minute, seconds=video_date.second)
-
-def add_video_time_to_start(x, video_date):
- start = timedelta(seconds=int(round(x)))
- return (start + video_date).time().isoformat()
-
-analysis = pd.read_csv(vp_path / "analysis_results.csv")
-analysis["Starttime"] = analysis["start_time"].apply(add_video_time_to_start, args=(video_date,))
-
-logs = pd.read_csv(vp_path / f"{vp_path.name}.csv")
-
-def get_log_url(start_time):
- start_time = datetime.strptime(start_time, "%H:%M:%S")
-
- for _, row in logs.iterrows():
- log_start = datetime.strptime(row[0], "%H:%M:%S")
- log_end = datetime.strptime(row[1], "%H:%M:%S")
- if start_time >= log_start and start_time <= log_end:
- return row[3]
- return 0
-
-
-
-analysis["log_url"] = analysis.apply(
- lambda row: get_log_url(row.Starttime), axis=1
- )
-
-
-analysis.to_csv(vp_path / "merged.csv", quoting=csv.QUOTE_NONNUMERIC)