Skip to content

Commit 845cf70

Browse files
committed
make sure monitor polys are restored after detect, restore old values after abnormal exit as well
1 parent cc084b9 commit 845cf70

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

mlapi.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ def post(self):
124124
g.logger.Debug (1, 'Monitor ID {} provided & matching config found in mlapi, ignoring objectconfig.ini'.format(mid))
125125
config_copy = copy.copy(g.config)
126126
poly_copy = copy.copy(g.polygons)
127-
g.polygons = g.monitor_polygons[mid]
127+
g.polygons = copy.copy(g.monitor_polygons[mid])
128128

129129

130130
for key in g.monitor_config[mid]:
@@ -183,6 +183,10 @@ def post(self):
183183
else:
184184
stream_options = req.get('stream_options')
185185
if not stream_options:
186+
if config_copy:
187+
g.log.Debug(2, 'Restoring global config & ml_options')
188+
g.config = config_copy
189+
g.polygons = poly_copy
186190
abort(400, msg='No stream options found')
187191
stream_options['api'] = zmapi
188192
stream_options['polygons'] = g.polygons
@@ -199,6 +203,10 @@ def post(self):
199203
g.log.Debug (1,'Object Recognition requested')
200204
#m = ObjectDetect.Object()
201205
else:
206+
if config_copy:
207+
g.log.Debug(2, 'Restoring global config & ml_options')
208+
g.config = config_copy
209+
g.polygons = poly_copy
202210
abort(400, msg='Invalid Model:{}'.format(args['type']))
203211

204212
if not stream:

0 commit comments

Comments
 (0)