]> www.vanbest.org Git - motioneye-debian/commitdiff
threshold is now configured as percent of the image
authorCalin Crisan <ccrisan@gmail.com>
Fri, 7 Mar 2014 20:34:04 +0000 (22:34 +0200)
committerCalin Crisan <ccrisan@gmail.com>
Fri, 7 Mar 2014 20:34:04 +0000 (22:34 +0200)
src/config.py
static/js/main.js
templates/main.html

index 236bdcd4b59b1ab95adeed0f7ef0944a55c16048..9cd00e6453161d0e33bb88c648d688ff39c79735 100644 (file)
@@ -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']),
index d1cb2381e1d0ff803e4a5aa474d65f1fdd9f69c6..76b563d0c49efbece145f3283115cce987c1b534 100644 (file)
@@ -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() {
index 89b54efd353d6b571f5918ed32bea5fa55b28959..7bdf83c108de118da4dd9e75df15db1bc33d7087 100644 (file)
                     <tr class="settings-item advanced-setting">
                         <td class="settings-item-label"><span class="settings-item-label">Frame Change Threshold</span></td>
                         <td class="settings-item-value"><input type="text" class="range styled motion-detection" id="frameChangeThresholdSlider"></td>
-                        <td><span class="help-mark" title="indicates the minimal number of pixels that must change between to frames in order for motion to be detected (smaller values give a more sensitive detection, but are prone to false positives)">?</span></td>
+                        <td><span class="help-mark" title="indicates the minimal percent of the image that must change between two successive frames in order for motion to be detected (smaller values give a more sensitive detection, but are prone to false positives)">?</span></td>
                     </tr>
                     <tr class="settings-item advanced-setting">
                         <td class="settings-item-label"><span class="settings-item-label">Automatic Noise Detection</span></td>