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
'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']),
# 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']),
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'],
# 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']),
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 */
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, '%');
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() {
<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>