Skip to content

Commit

Permalink
make sure monitor polys are restored after detect, restore old values…
Browse files Browse the repository at this point in the history
… after abnormal exit as well
  • Loading branch information
pliablepixels committed May 29, 2021
1 parent cc084b9 commit 845cf70
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion mlapi.py
Expand Up @@ -124,7 +124,7 @@ def post(self):
g.logger.Debug (1, 'Monitor ID {} provided & matching config found in mlapi, ignoring objectconfig.ini'.format(mid))
config_copy = copy.copy(g.config)
poly_copy = copy.copy(g.polygons)
g.polygons = g.monitor_polygons[mid]
g.polygons = copy.copy(g.monitor_polygons[mid])


for key in g.monitor_config[mid]:
Expand Down Expand Up @@ -183,6 +183,10 @@ def post(self):
else:
stream_options = req.get('stream_options')
if not stream_options:
if config_copy:
g.log.Debug(2, 'Restoring global config & ml_options')
g.config = config_copy
g.polygons = poly_copy
abort(400, msg='No stream options found')
stream_options['api'] = zmapi
stream_options['polygons'] = g.polygons
Expand All @@ -199,6 +203,10 @@ def post(self):
g.log.Debug (1,'Object Recognition requested')
#m = ObjectDetect.Object()
else:
if config_copy:
g.log.Debug(2, 'Restoring global config & ml_options')
g.config = config_copy
g.polygons = poly_copy
abort(400, msg='Invalid Model:{}'.format(args['type']))

if not stream:
Expand Down

0 comments on commit 845cf70

Please sign in to comment.