-
Notifications
You must be signed in to change notification settings - Fork 12
Expand file tree
/
Copy pathconfigloader.py
More file actions
70 lines (55 loc) · 2.44 KB
/
configloader.py
File metadata and controls
70 lines (55 loc) · 2.44 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
"""
DeepLabStream
© J.Schweihoff, M. Loshakov
University Bonn Medical Faculty, Germany
https://github.com/SchwarzNeuroconLab/DeepLabStream
Licensed under GNU General Public License v3.0
"""
import time
import os
import configparser as cfg
# loading DeepLabStream configuration
# remember when it was called DSC?
dsc_config = cfg.ConfigParser()
adv_dsc_config = cfg.ConfigParser()
def get_script_path():
return os.path.dirname(os.path.join(os.path.dirname(__file__), '..'))
cfg_path = os.path.join(os.path.dirname(__file__), '..', 'settings.ini')
with open(cfg_path) as cfg_file:
dsc_config.read_file(cfg_file)
adv_cfg_path = os.path.join(os.path.dirname(__file__), 'advanced_settings.ini')
with open(adv_cfg_path) as adv_cfg_file:
adv_dsc_config.read_file(adv_cfg_file)
#poseestimation
MODEL_ORIGIN = dsc_config['Pose Estimation'].get('MODEL_ORIGIN')
MODEL_PATH = dsc_config['Pose Estimation'].get('MODEL_PATH')
MODEL_NAME = dsc_config['Pose Estimation'].get('MODEL_NAME')
ALL_BODYPARTS = tuple(part for part in dsc_config['Pose Estimation'].get('ALL_BODYPARTS').split(','))
# Streaming items
try:
RESOLUTION = tuple(int(part) for part in dsc_config['Streaming'].get('RESOLUTION').split(','))
except ValueError:
print('Incorrect resolution in config!\n'
'Using default value "RESOLUTION = 848, 480"')
RESOLUTION = (848, 480)
FRAMERATE = dsc_config['Streaming'].getint('FRAMERATE')
OUT_DIR = dsc_config['Streaming'].get('OUTPUT_DIRECTORY')
CAMERA_SOURCE = dsc_config['Streaming'].get('CAMERA_SOURCE')
STREAMING_SOURCE = dsc_config['Streaming'].get('STREAMING_SOURCE')
# Video
VIDEO_SOURCE = dsc_config['Video'].get('VIDEO_SOURCE')
#IPWEBCAM
PORT = dsc_config['IPWEBCAM'].get('PORT')
# experiment
EXP_ORIGIN = dsc_config['Experiment'].get('EXP_ORIGIN')
EXP_NAME = dsc_config['Experiment'].get('EXP_NAME')
RECORD_EXP = dsc_config['Experiment'].getboolean('RECORD_EXP')
START_TIME = time.time()
"""advanced settings"""
STREAMS = [str(part).strip() for part in adv_dsc_config['Streaming'].get('STREAMS').split(',')]
MULTI_CAM = adv_dsc_config['Streaming'].getboolean('MULTIPLE_DEVICES')
STACK_FRAMES = adv_dsc_config['Streaming'].getboolean('STACK_FRAMES') if adv_dsc_config['Streaming'].getboolean(
'STACK_FRAMES') is not None else False
ANIMALS_NUMBER = adv_dsc_config['Streaming'].getint('ANIMALS_NUMBER') if adv_dsc_config['Streaming'].getint(
'ANIMALS_NUMBER') is not None else 1
RECORD_RAW = adv_dsc_config['Video'].getboolean('RECORD_RAW')