From: Calin Crisan Date: Fri, 7 Mar 2014 20:34:04 +0000 (+0200) Subject: threshold is now configured as percent of the image X-Git-Url: http://www.vanbest.org/gitweb/?a=commitdiff_plain;h=9f6be9ddf49e48081b6db2dd56e3835ce051b8da;p=motioneye-debian threshold is now configured as percent of the image --- diff --git a/src/config.py b/src/config.py index 236bdcd..9cd00e6 100644 --- a/src/config.py +++ b/src/config.py @@ -459,6 +459,10 @@ def main_dict_to_ui(data): def camera_ui_to_dict(ui): if not ui['resolution']: # avoid errors for empty resolution setting ui['resolution'] = '352x288' + + width = int(ui['resolution'].split('x')[0]) + height = int(ui['resolution'].split('x')[1]) + threshold = int(ui['frame_change_threshold']) * width * height / 100 data = { # device @@ -468,8 +472,8 @@ def camera_ui_to_dict(ui): 'videodevice': ui['device_uri'], 'lightswitch': int(ui['light_switch_detect']) * 50, 'auto_brightness': ui['auto_brightness'], - 'width': int(ui['resolution'].split('x')[0]), - 'height': int(ui['resolution'].split('x')[1]), + 'width': width, + 'height': height, 'framerate': int(ui['framerate']), 'rotate': int(ui['rotation']), @@ -513,7 +517,7 @@ def camera_ui_to_dict(ui): # motion detection 'text_changes': ui['show_frame_changes'], 'locate_motion_mode': ui['show_frame_changes'], - 'threshold': ui['frame_change_threshold'], + 'threshold': threshold, 'noise_tune': ui['auto_noise_detect'], 'noise_level': max(1, int(round(int(ui['noise_level']) * 2.55))), 'gap': int(ui['gap']), @@ -626,6 +630,8 @@ def camera_dict_to_ui(data): resolutions = v4l2ctl.list_resolutions(data['videodevice']) resolutions = [(str(w) + 'x' + str(h)) for (w, h) in resolutions] + threshold = data['threshold'] * 100 / (data['width'] * data['height']) + ui = { # device 'name': data['@name'], @@ -683,7 +689,7 @@ def camera_dict_to_ui(data): # motion detection 'show_frame_changes': data['text_changes'] or data['locate_motion_mode'], - 'frame_change_threshold': data['threshold'], + 'frame_change_threshold': threshold, 'auto_noise_detect': data['noise_tune'], 'noise_level': int(int(data['noise_level']) / 2.55), 'gap': int(data['gap']), diff --git a/static/js/main.js b/static/js/main.js index d1cb238..76b563d 100644 --- a/static/js/main.js +++ b/static/js/main.js @@ -2,7 +2,6 @@ var pushConfigs = {}; var refreshDisabled = {}; /* dictionary indexed by cameraId, tells if refresh is disabled for a given camera */ var fullScreenCameraId = null; -var thresholdSlider = null; var inProgress = false; var refreshInterval = 50; /* milliseconds */ @@ -188,7 +187,7 @@ function initUI() { makeSlider($('#streamingResolutionSlider'), 0, 100, 2, null, 5, 0, '%'); makeSlider($('#imageQualitySlider'), 0, 100, 2, null, 5, 0, '%'); makeSlider($('#movieQualitySlider'), 0, 100, 2, null, 5, 0, '%'); - thresholdSlider = makeSlider($('#frameChangeThresholdSlider'), 0, 20000, 0, null, 3, 0, 'px'); + makeSlider($('#frameChangeThresholdSlider'), 0, 10, 0, null, 6, 1, '%'); makeSlider($('#noiseLevelSlider'), 0, 100, 2, null, 5, 0, '%'); @@ -465,18 +464,6 @@ function updateConfigUi() { this.selectedIndex = 0; } }); - - /* update change threshold max limit */ - var resolution = $('#resolutionSelect').val(); - if (resolution) { - resolution = resolution.split('x'); - - var width = parseInt(resolution[0]); - var height = parseInt(resolution[1]); - var valStr = '' + (width * height * 0.5); /* up to 50% */ - var maxVal = parseInt(valStr[0] + new Array(valStr.length).join('0')); - thresholdSlider.setMaxVal(maxVal); - } } function configUiValid() { diff --git a/templates/main.html b/templates/main.html index 89b54ef..7bdf83c 100644 --- a/templates/main.html +++ b/templates/main.html @@ -352,7 +352,7 @@ Frame Change Threshold - ? + ? Automatic Noise Detection