Exemplo n.º 1
0
# ============ Base imports ======================
import os
import glob
from datetime import datetime, timedelta
# ====== External package imports ================
import pandas as pd
# ====== Internal package imports ================
# ============== Logging  ========================
import logging
from src.modules.utils.setup import setup, IndentLogger

logger = IndentLogger(logging.getLogger(''), {})
# =========== Config File Loading ================
from src.modules.utils.config_loader import get_config

conf, confp = get_config()
# ======== Load Configuration Parameters =========
subs_path = confp.dirs.subtitles
vid_run_path = confp.paths.video_runs_old
subtitles_dirs = confp.dirs.subtitles
# ================================================

setup("meta_data_contiguous")

# threshold for run length
run_len = 15
frame_skip_tolerance = 0.01  # how close do the video times have to be between subtitles? ideally they should be 1 second apart

run_len += 0  # add buffer to run length to shave off later
all_sub_files = [
    fn for fn in glob.glob(subs_path + "/*.csv")
# ============ Base imports ======================
from io import StringIO
from functools import partial
# ====== External package imports ================
import numpy as np
import psycopg2 as psy
# ====== Internal package imports ================
# ============== Logging  ========================
import logging
from src.modules.utils.setup import setup, IndentLogger
logger = IndentLogger(logging.getLogger(''), {})
# =========== Config File Loading ================
from src.modules.utils.config_loader import get_config
conf = get_config()
# ================================================


class DatabaseIO:
    """Class which mediates all interactions with the database
    """
    def __init__(self, testing=False):
        """Defines the schemas, and creates psycopg2 connection to the database

        Note: the schema in this class should always match that in the database

        :param testing: boolean, if True, nothing is written to the database, it just prints the commands which will be run
        """
        self.write_role = conf.db.write_role
        self.conn = psy.connect(
            database=conf.db.db_name,
            user=conf.db.user,
Exemplo n.º 3
0
# ============ Base imports ======================
import os
# ====== External package imports ================
import pandas as pd
# ====== Internal package imports ================
# ============== Logging  ========================
import logging
from src.modules.utils.setup import setup, IndentLogger
logger = IndentLogger(logging.getLogger(''), {})
# =========== Config File Loading ================
from src.modules.utils.config_loader import get_config
conf, confp = get_config()
# ======== Load Configuration Parameters =========
path = confp.dirs.subtitles
out_dir = confp.dirs.output
vid_run_path = confp.paths.video_runs
# ================================================

setup("video_sampling")

outpath = os.path.join(out_dir, "video_sample.csv")

logger.info("Loading Data")
vids = pd.read_csv(vid_run_path)
#vids = pd.read_csv(vid_run_path)

logger.info("Adding Columns")


all_cams = vids["camera"].unique()
logger.info(f"Found {len(all_cams)} cameras")