Skip to content

Commit da75a37

Browse files
committed
updated settings.ini for easier reading
moved advanced settings to /utils
1 parent 78a8e61 commit da75a37

File tree

4 files changed

+39
-22
lines changed

4 files changed

+39
-22
lines changed

DeepLabStream.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
import click
1919

2020
from utils.configloader import RESOLUTION, FRAMERATE, OUT_DIR, MODEL, MULTI_CAM, STACK_FRAMES, \
21-
ANIMALS_NUMBER, STREAMS, VIDEO, IPWEBCAM
21+
ANIMALS_NUMBER, STREAMS, STREAMING_SOURCE
2222
from utils.poser import load_deeplabcut, get_pose, find_local_peaks_new, calculate_skeletons
2323
from utils.plotter import plot_bodyparts, plot_metadata_frame
2424

@@ -127,18 +127,17 @@ def set_camera_manager():
127127
:return: the chosen camera manager
128128
"""
129129

130-
if VIDEO:
130+
if STREAMING_SOURCE.lower() == 'video':
131131
from utils.generic import VideoManager
132132
manager = VideoManager()
133133
return manager
134134

135-
elif IPWEBCAM:
135+
elif STREAMING_SOURCE.lower() == 'ipwebcam':
136136
from utils.generic import WebCamManager
137137
manager = WebCamManager()
138138
return manager
139139

140-
141-
else:
140+
elif STREAMING_SOURCE.lower() == 'camera':
142141
manager_list = []
143142
# loading realsense manager, if installed
144143
realsense = find_spec("pyrealsense2") is not None
@@ -174,6 +173,9 @@ def check_for_cameras(camera_manager):
174173
from utils.generic import GenericManager
175174
generic_manager = GenericManager()
176175
return generic_manager
176+
else:
177+
raise ValueError(f'Streaming source {STREAMING_SOURCE} is not a valid option. \n'
178+
f'Please choose from "video", "camera" or "ipwebcam".')
177179

178180
@property
179181
def cameras(self):

settings.ini

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
[Streaming]
2-
RESOLUTION = 320, 256
2+
RESOLUTION = 848, 480
33
FRAMERATE = 30
4-
STREAMS = color, depth, infrared
54
OUTPUT_DIRECTORY = /Output
6-
MULTIPLE_DEVICES = False
5+
#if you have connected multiple cameras (USB), you will need to select the number OpenCV has given them.
6+
#Default is "0", which takes the first available camera.
77
CAMERA_SOURCE = 0
8+
#you can use camera, ipwebcam or video to select your input source
9+
STREAMING_SOURCE = camera
810

911
[DeepLabCut]
1012
DLC_PATH = DLC_PATH
1113
MODEL = MODEL_NAME
1214

1315
[Experiment]
14-
EXP_ORIGIN = CUSTOM/BASE
16+
#Available parameters are "CUSTOM" and "BASE"
17+
EXP_ORIGIN = BASE
18+
#Name of the experiment config in /experiments/configs or name of the custom experiment in /experiments/custom/experiments.py
1519
EXP_NAME = CONFIG_NAME
20+
#if you want the experiment to be recorded as a raw video set this to "True".
1621
RECORD_EXP = True
1722

1823
[Video]
24+
#Full path to video that you want to use as input. Needs "STREAMING_SOURCE" set to "video"!
1925
VIDEO_SOURCE = PATH_TO_PRERECORDED_VIDEO
20-
VIDEO = False
2126

2227
[IPWEBCAM]
28+
#Standard Port is 5555 if you followed the SmoothStream setup
2329
PORT = 5555
24-
IPWEBCAM = True

utils/advanced_settings.ini

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#advanced settings only change them if you know what you do!
2+
3+
[Streaming]
4+
STREAMS = color, depth, infrared
5+
MULTIPLE_DEVICES = False
6+
STACK_FRAMES = False
7+
ANIMALS_NUMBER = 1

utils/configloader.py

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
# loading DeepLabStream configuration
1414
# remember when it was called DSC?
1515
dsc_config = cfg.ConfigParser()
16+
adv_dsc_config = cfg.ConfigParser()
1617

1718

1819
def get_script_path():
@@ -23,6 +24,9 @@ def get_script_path():
2324
with open(cfg_path) as cfg_file:
2425
dsc_config.read_file(cfg_file)
2526

27+
adv_cfg_path = os.path.join(os.path.dirname(__file__), 'advanced_settings.ini')
28+
with open(adv_cfg_path) as adv_cfg_file:
29+
adv_dsc_config.read_file(adv_cfg_file)
2630
# DeepLabCut
2731
deeplabcut_config = dict(dsc_config.items('DeepLabCut'))
2832

@@ -36,22 +40,13 @@ def get_script_path():
3640
MODEL = dsc_config['Streaming'].get('MODEL')
3741
FRAMERATE = dsc_config['Streaming'].getint('FRAMERATE')
3842
OUT_DIR = dsc_config['Streaming'].get('OUTPUT_DIRECTORY')
39-
STREAM = dsc_config['Streaming'].getboolean('STREAM')
40-
MULTI_CAM = dsc_config['Streaming'].getboolean('MULTIPLE_DEVICES')
41-
STACK_FRAMES = dsc_config['Streaming'].getboolean('STACK_FRAMES') if dsc_config['Streaming'].getboolean(
42-
'STACK_FRAMES') is not None else False
43-
ANIMALS_NUMBER = dsc_config['Streaming'].getint('ANIMALS_NUMBER') if dsc_config['Streaming'].getint(
44-
'ANIMALS_NUMBER') is not None else 1
45-
STREAMS = [str(part).strip() for part in dsc_config['Streaming'].get('STREAMS').split(',')]
4643
CAMERA_SOURCE = dsc_config['Streaming'].get('CAMERA_SOURCE')
47-
44+
STREAMING_SOURCE = dsc_config['Streaming'].get('STREAMING_SOURCE')
4845
# Video
4946
VIDEO_SOURCE = dsc_config['Video'].get('VIDEO_SOURCE')
50-
VIDEO = dsc_config['Video'].getboolean('VIDEO')
5147

5248
#IPWEBCAM
5349
PORT = dsc_config['IPWEBCAM'].get('PORT')
54-
IPWEBCAM = dsc_config['IPWEBCAM'].getboolean('IPWEBCAM')
5550

5651

5752
# experiment
@@ -60,4 +55,12 @@ def get_script_path():
6055
RECORD_EXP = dsc_config['Experiment'].getboolean('RECORD_EXP')
6156

6257
START_TIME = time.time()
63-
EGG = "".join(format(ord(x), 'b') for x in "Hello there!")
58+
59+
60+
"""advanced settings"""
61+
STREAMS = [str(part).strip() for part in adv_dsc_config['Streaming'].get('STREAMS').split(',')]
62+
MULTI_CAM = adv_dsc_config['Streaming'].getboolean('MULTIPLE_DEVICES')
63+
STACK_FRAMES = adv_dsc_config['Streaming'].getboolean('STACK_FRAMES') if adv_dsc_config['Streaming'].getboolean(
64+
'STACK_FRAMES') is not None else False
65+
ANIMALS_NUMBER = adv_dsc_config['Streaming'].getint('ANIMALS_NUMBER') if adv_dsc_config['Streaming'].getint(
66+
'ANIMALS_NUMBER') is not None else 1

0 commit comments

Comments
 (0)